Sfoglia il codice sorgente

Add marker count badge to locations page

Alan Lam 4 anni fa
parent
commit
258edaf2cd
2 ha cambiato i file con 15 aggiunte e 0 eliminazioni
  1. 10 0
      public/js/app-locations.js
  2. 5 0
      views/locations.php

+ 10 - 0
public/js/app-locations.js

@@ -31,6 +31,16 @@ function initialiseLocations() {
 
 
 		let bounds = new google.maps.LatLngBounds;
 		let bounds = new google.maps.LatLngBounds;
 
 
+		let locationCount = response.locations.length;
+		const $markerCountSpan = $("#map-marker-count");
+
+		if(locationCount > 0) {
+			$markerCountSpan.text(locationCount);
+		}
+		else {
+			$markerCountSpan.text("");
+		}
+
 		response.locations.forEach(location => {
 		response.locations.forEach(location => {
 
 
 			let position = {
 			let position = {

+ 5 - 0
views/locations.php

@@ -166,6 +166,11 @@ var customerId = <?=$customer->id?>;
 	<?php
 	<?php
 	if(!empty($locations)) {
 	if(!empty($locations)) {
 		?>
 		?>
+		<h3>
+			<?=htmlspecialchars(__("Map"))?>
+			<span id="map-marker-count" class="badge badge-pill badge-primary"></span>
+		</h3>
+
 		<div class="mb-3" id="map" data-maps data-lat="0" data-lng="0" data-zoom="7" style="height: 480px;" data-callback="initialiseLocations">
 		<div class="mb-3" id="map" data-maps data-lat="0" data-lng="0" data-zoom="7" style="height: 480px;" data-callback="initialiseLocations">
 		</div>
 		</div>
 		<?php
 		<?php