|
|
@@ -42,16 +42,42 @@ class Map {
|
|
|
|
|
|
const $map = $("#map");
|
|
|
const data = $map.data();
|
|
|
- const { customerId } = data;
|
|
|
+ const { customerId, locationsPage } = data;
|
|
|
if(customerId) {
|
|
|
this.plotForCustomerId(customerId);
|
|
|
}
|
|
|
+
|
|
|
+ if(locationsPage) {
|
|
|
+ const $customerIdDropdown = $("#customer-id");
|
|
|
+ const customerId = $customerIdDropdown.val();
|
|
|
+ if(customerId) {
|
|
|
+ this.plotForCustomerId(customerId);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $customerIdDropdown.find("option[value!='']").each((index, element) => {
|
|
|
+ this.plotForCustomerId(element.value);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
plotForCustomerId(customerId) {
|
|
|
- return $.post("/api/get-markers", {
|
|
|
+
|
|
|
+ const data = {
|
|
|
customer_id: customerId
|
|
|
- }).then(response => {
|
|
|
+ };
|
|
|
+
|
|
|
+ const locationId = $("#location-id").val();
|
|
|
+ if(locationId) {
|
|
|
+ data.location_id = locationId;
|
|
|
+ }
|
|
|
+
|
|
|
+ const name = $("#name").val();
|
|
|
+ if(name) {
|
|
|
+ data.name = name;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $.post("/api/get-markers", data).then(response => {
|
|
|
if(typeof this.markers[customerId] === "undefined") {
|
|
|
this.markers[customerId] = [];
|
|
|
}
|