|
@@ -1,7 +1,11 @@
|
|
|
var locationMarkers = [];
|
|
var locationMarkers = [];
|
|
|
var testerMarkers = [];
|
|
var testerMarkers = [];
|
|
|
|
|
+var assignMarkers = [];
|
|
|
|
|
|
|
|
var selectedLocation;
|
|
var selectedLocation;
|
|
|
|
|
+var selectedTester;
|
|
|
|
|
+
|
|
|
|
|
+var assignLatLngBounds;
|
|
|
|
|
|
|
|
var map = null;
|
|
var map = null;
|
|
|
|
|
|
|
@@ -12,6 +16,10 @@ $(function() {
|
|
|
$(document).on("click", "button[data-find-testers-button]", handleFindTestersButtonClick);
|
|
$(document).on("click", "button[data-find-testers-button]", handleFindTestersButtonClick);
|
|
|
$(document).on("click", "button[data-assign-button]", handleAssignButtonClick);
|
|
$(document).on("click", "button[data-assign-button]", handleAssignButtonClick);
|
|
|
$(document).on("click", "#assign-confirm-button", handleConfirmAssignButtonClick);
|
|
$(document).on("click", "#assign-confirm-button", handleConfirmAssignButtonClick);
|
|
|
|
|
+ $("#modal-assign-tester").on("shown.bs.modal", function() {
|
|
|
|
|
+ console.log(assignLatLngBounds);
|
|
|
|
|
+ maps["assign-map"].fitBounds(assignLatLngBounds);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
function initialiseLocations() {
|
|
function initialiseLocations() {
|
|
@@ -111,7 +119,9 @@ function handleFindTestersButtonClick() {
|
|
|
var lng = parseFloat($(container).attr("data-longitude"));
|
|
var lng = parseFloat($(container).attr("data-longitude"));
|
|
|
|
|
|
|
|
selectedLocation = {
|
|
selectedLocation = {
|
|
|
- id: locationId
|
|
|
|
|
|
|
+ id: locationId,
|
|
|
|
|
+ lat: lat,
|
|
|
|
|
+ lng: lng
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
var latLng = {
|
|
var latLng = {
|
|
@@ -237,6 +247,14 @@ function handleAssignButtonClick(event) {
|
|
|
let addressId = parseInt($(container).data("address-id"));
|
|
let addressId = parseInt($(container).data("address-id"));
|
|
|
let testerId = parseInt($(container).data("tester-id"));
|
|
let testerId = parseInt($(container).data("tester-id"));
|
|
|
|
|
|
|
|
|
|
+ assignLatLngBounds = new google.maps.LatLngBounds;
|
|
|
|
|
+
|
|
|
|
|
+ for(var i in assignMarkers) {
|
|
|
|
|
+ let marker = assignMarkers[i];
|
|
|
|
|
+ marker.setMap(null);
|
|
|
|
|
+ marker = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Find location
|
|
// Find location
|
|
|
var location = false;
|
|
var location = false;
|
|
|
for(var i in locations) {
|
|
for(var i in locations) {
|
|
@@ -246,8 +264,26 @@ function handleAssignButtonClick(event) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ let map = maps["assign-map"];
|
|
|
|
|
+
|
|
|
if(location) {
|
|
if(location) {
|
|
|
- $("#modal-assign-tester").find("[data-location-photo]").css("background-image", "url(/account/locations/" + location.id + "/photo)");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ var position = {
|
|
|
|
|
+ lat: parseFloat(location.latitude),
|
|
|
|
|
+ lng: parseFloat(location.longitude)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ assignLatLngBounds.extend(position);
|
|
|
|
|
+
|
|
|
|
|
+ let options = {};
|
|
|
|
|
+ options.map = map;
|
|
|
|
|
+ options.position = position;
|
|
|
|
|
+ options.icon = "/img/markers/building-green.png";
|
|
|
|
|
+ options.title = location.name;
|
|
|
|
|
+
|
|
|
|
|
+ let marker = new google.maps.Marker(options);
|
|
|
|
|
+ assignMarkers.push(marker);
|
|
|
|
|
+
|
|
|
$("#modal-assign-tester").find("[data-location-name]").text(location.name);
|
|
$("#modal-assign-tester").find("[data-location-name]").text(location.name);
|
|
|
$("#modal-assign-tester").find("[data-location-address]").text(location.address);
|
|
$("#modal-assign-tester").find("[data-location-address]").text(location.address);
|
|
|
}
|
|
}
|
|
@@ -255,12 +291,29 @@ function handleAssignButtonClick(event) {
|
|
|
// Find tester
|
|
// Find tester
|
|
|
var tester = false;
|
|
var tester = false;
|
|
|
for(var i in testers) {
|
|
for(var i in testers) {
|
|
|
- if(testers[i].id == testerId) {
|
|
|
|
|
|
|
+ if(testers[i].addressId == addressId) {
|
|
|
tester = testers[i];
|
|
tester = testers[i];
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if(tester) {
|
|
if(tester) {
|
|
|
|
|
+
|
|
|
|
|
+ var position = {
|
|
|
|
|
+ lat: parseFloat(tester.latitude),
|
|
|
|
|
+ lng: parseFloat(tester.longitude)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ assignLatLngBounds.extend(position);
|
|
|
|
|
+
|
|
|
|
|
+ let options = {};
|
|
|
|
|
+ options.map = map;
|
|
|
|
|
+ options.position = position;
|
|
|
|
|
+ options.icon = "/img/markers/user-green.png";
|
|
|
|
|
+ options.title = tester.name;
|
|
|
|
|
+
|
|
|
|
|
+ let marker = new google.maps.Marker(options);
|
|
|
|
|
+ assignMarkers.push(marker);
|
|
|
|
|
+
|
|
|
$("#modal-assign-tester").find("[data-tester-photo]").css("background-image", "url(/account/users/" + tester.id + "/photo)");
|
|
$("#modal-assign-tester").find("[data-tester-photo]").css("background-image", "url(/account/users/" + tester.id + "/photo)");
|
|
|
$("#modal-assign-tester").find("[data-tester-name]").text(tester.name);
|
|
$("#modal-assign-tester").find("[data-tester-name]").text(tester.name);
|
|
|
$("#modal-assign-tester").find("[data-tester-age]").text(tester.age);
|
|
$("#modal-assign-tester").find("[data-tester-age]").text(tester.age);
|