Jelajahi Sumber

Update to make home strand re-display when a unit is changed

Lee Morgan 6 tahun lalu
induk
melakukan
8e42a03966
2 mengubah file dengan 3 tambahan dan 9 penghapusan
  1. 2 6
      views/dashboardPage/home.js
  2. 1 3
      views/dashboardPage/sidebars/sidebars.js

+ 2 - 6
views/dashboardPage/home.js

@@ -1,16 +1,12 @@
 window.homeStrandObj = {
     isPopulated: false,
     graph: {},
-    popularWidth: 0,
-    popularHeight: 0,
 
     display: function(){
         if(!this.isPopulated){
             this.drawRevenueCard();
             this.drawRevenueGraph();
             this.drawInventoryCheckCard();
-            this.popularWidth = document.getElementById("popularIngredientsCard").offsetWidth;
-            this.popularHeight = document.getElementById("popularIngredientsCard").offsetHeight;
             this.drawPopularCard();
 
             this.isPopulated = true;
@@ -141,8 +137,8 @@ window.homeStrandObj = {
             }
 
             let thisCanvas = document.getElementById("popularCanvas");
-            thisCanvas.width = this.popularWidth;
-            thisCanvas.height = this.popularHeight;
+            thisCanvas.width = thisCanvas.parentElement.offsetWidth;
+            thisCanvas.height = thisCanvas.parentElement.offsetHeight;
 
             let popularGraph = new HorizontalBarGraph(thisCanvas);
             popularGraph.addData(dataArray);

+ 1 - 3
views/dashboardPage/sidebars/sidebars.js

@@ -563,9 +563,7 @@ let addIngredientsComp = {
         element.insertBefore(input, element.children[1]);
 
         let select = element.children[2];
-        console.log(select.style.display);
         select.style.display = "block";
-        console.log(select.style.display);
         let units = merchant.units[element.ingredient.unitType];
         for(let i = 0; i < units.length; i++){
             let option = document.createElement("option");
@@ -824,7 +822,7 @@ let ingredientDetailsComp = {
 
         newActive.classList.add("unitActive");
 
-        homeStrandObj.drawInventoryCheckCard();
+        homeStrandObj.isPopulated = false;
         ingredientsStrandObj.populateByProperty("category");
         document.getElementById("ingredientStock").innerText = `${this.ingredient.ingredient.convert(this.ingredient.quantity).toFixed(2)} ${this.ingredient.ingredient.unit.toUpperCase()}`;
     },