Parcourir la source

Update some of the recipes class to work with new conversion system.
Need to update sub-ingredients to handle unit conversion.

Lee Morgan il y a 5 ans
Parent
commit
12a608e1e1

+ 6 - 2
views/dashboardPage/js/classes/Recipe.js

@@ -28,8 +28,12 @@ class RecipeIngredient{
         return `${this._quantity.toFixed(2)} ${this._unit.toUpperCase()}`;
     }
 
-    // getQuantityAsBase(){
-    // }
+    getQuantityAsBase(){
+        if(controller.unitType(this._unit) === "mass") return this._quantity / this._ingredient.convert.toMass;
+        if(controller.unitType(this._unit) === "volume") return this._quantity / this._ingredient.convert.toVolume;
+        if(controller.unittype(this._unit) === "length") return this._quantity / this._ingredient.convert.toLength;
+        return this._quantity;
+    }
 }
 
 /*

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

@@ -81,7 +81,7 @@ let newIngredient = {
 
         if(controller.unitType(unit) === "mass") newIngredient.convert.toMass = 1;
         if(controller.unitType(unit) === "volume") newIngredient.convert.toVolume = 1;
-        if(controller.unittype(unit) === "length") newIngredient.convert.toLength = 1;
+        if(controller.unitType(unit) === "length") newIngredient.convert.toLength = 1;
 
         if(isNaN(newIngredient.convert.toMass)) newIngredient.convert.toMass = undefined;
         if(isNaN(newIngredient.convert.toVolume)) newIngredient.convert.toVolume = undefined;

+ 3 - 1
views/dashboardPage/js/strands/analytics.js

@@ -172,7 +172,7 @@ let analytics = {
     },
 
     displayIngredient: function(){
-        if(this.ingredient === undefined  || this.transactionsByDate.length === 0) return;
+        if(this.ingredient === undefined || this.transactionsByDate.length === 0) return;
 
         //break down data into dates and quantities
         let dates = [];
@@ -190,6 +190,8 @@ let analytics = {
             quantities.push(sum);
         }
 
+        console.log(quantities);
+
         //create and display the graph
         let trace = {
             x: dates,