Sfoglia il codice sorgente

Displaying of recipe ingredients displays the proper quantity/unit.

Lee Morgan 5 anni fa
parent
commit
bc0f8bb83a

+ 3 - 1
views/dashboardPage/js/classes/Merchant.js

@@ -128,7 +128,9 @@ class Merchant{
                     if(ingredient.ingredient === this._inventory[k].ingredient.id){
                         ingredients.push({
                             ingredient: this._inventory[k].ingredient.id,
-                            quantity: ingredient.quantity
+                            quantity: ingredient.quantity,
+                            unit: ingredient.unit,
+                            baseUnitMultiplier: ingredient.baseUnitMultiplier
                         });
                         break;
                     }

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

@@ -14,27 +14,7 @@ class RecipeIngredient{
     }
 
     get quantity(){
-        switch(this._ingredient.unit){
-            case "g":return this._quantity;
-            case "kg": return this._quantity / 1000;
-            case "oz": return this._quantity / 28.3495;
-            case "lb": return this._quantity / 453.5924;
-            case "ml": return this._quantity * 1000;
-            case "l": return this._quantity;
-            case "tsp": return this._quantity * 202.8842;
-            case "tbsp": return this._quantity * 67.6278;
-            case "ozfl": return this._quantity * 33.8141;
-            case "cup": return this._quantity * 4.1667;
-            case "pt": return this._quantity * 2.1134;
-            case "qt": return this._quantity * 1.0567;
-            case "gal": return this._quantity / 3.7854;
-            case "mm": return this._quantity * 1000;
-            case "cm": return this._quantity * 100;
-            case "m": return this._quantity;
-            case "in": return this._quantity * 39.3701;
-            case "ft": return this._quantity * 3.2808;
-            default: return this._quantity;
-        }
+        return this._quantity;
     }
 
     set quantity(quantity){
@@ -42,7 +22,7 @@ class RecipeIngredient{
     }
 
     getQuantityDisplay(){
-        return `${this.quantity.toFixed(2)} ${this._ingredient.unit.toUpperCase()}`;
+        return `${this._quantity.toFixed(2)} ${this._unit.toUpperCase()}`;
     }
 }