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

Add global variable "state".
State contains functions to update various things.
Fix bugs in updating for new merchant.

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

+ 32 - 0
views/dashboardPage/js/dashboard.js

@@ -323,6 +323,38 @@ controller = {
     }
 }
 
+window.state = {
+    updateIngredients: function(){
+        ingredients.populateByProperty();
+        analytics.populateButtons();
+        home.drawInventoryCheckCard();
+    },
+
+    updateRecipes: function(){
+        recipeBook.populateRecipes();
+        analytics.populateButtons();
+    },
+
+    updateTransactions: function(){
+        home.isPopulated = false;
+        ingredients.populateByProperty();
+        analytics.displayIngredient();
+        analytics.displayRecipe();
+    },
+
+    updateOrders: function(){
+        ingredients.isPopulated = false;
+        ordersStrand.isPopulated = false;
+    },
+
+    updateMerchant(){
+        this.updateIngredients();
+        this.updateRecipes();
+        this.updateTransactions();
+        this.updateOrders();
+    }
+}
+
 //Add click listeners for menu buttons
 document.getElementById("homeBtn").onclick = ()=>{controller.openStrand("home")};
 document.getElementById("ingredientsBtn").onclick = ()=>{controller.openStrand("ingredients")};

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

@@ -85,6 +85,7 @@ let modal = {
 
                     state.updateMerchant();
                     controller.openStrand("home");
+                    controller.closeModal();
                 }
             })
             .catch((err)=>{