Просмотр исходного кода

Square locations modal notifies user when they have no other locations.

Lee Morgan 5 лет назад
Родитель
Сommit
fd336d943a
2 измененных файлов с 10 добавлено и 1 удалено
  1. 1 1
      views/dashboardPage/ejs/modal.ejs
  2. 9 0
      views/dashboardPage/js/modal.js

+ 1 - 1
views/dashboardPage/ejs/modal.ejs

@@ -54,7 +54,7 @@
             </div>
 
             <div id="modalSquareLocations" style="display:none">
-                <h2>CHOOSE A LOCATION</h2>
+                <h2 id="squareLocationsTitle">CHOOSE A LOCATION</h2>
 
                 <div id="squareLocationsButtons"></div>
 

+ 9 - 0
views/dashboardPage/js/modal.js

@@ -98,7 +98,16 @@ let modal = {
     squareLocations: function(locations){
         document.getElementById("modalSquareLocations").style.display = "flex";
         document.getElementById("squareLocationsCancel").onclick = ()=>{controller.closeModal()};
+        if(locations.length === 0){
+            document.getElementById("squareLocationsTitle").innerText = "ALL OF YOUR LOCATIONS HAVE ALREADY BEEN ADDED TO THE SUBLINE";
+            return;
+        }
+
         let container = document.getElementById("squareLocationsButtons");
+
+        while(container.children.length > 0){
+            container.removeChild(container.firstChild);
+        }
         
         for(let i = 0; i < locations.length; i++){
             let button = document.createElement("button");