Parcourir la source

Update recipe details sidebar to working state

Lee Morgan il y a 5 ans
Parent
commit
96ef3d6710

+ 9 - 1
views/dashboardPage/bundle.js

@@ -930,6 +930,14 @@ class RecipeIngredient{
         this_quantity = this.convertToBase(quantity);
     }
 
+    getQuantityDisplay(){
+        if(this._ingredient.specialUnit === "bottle"){
+            return `${this.quantity.toFixed(2)} BOTTLES`;
+        }
+
+        return `${this.quantity.toFixed(2)} ${this._ingredient.unit.toUpperCase()}`;
+    }
+
     convertToBase(quantity){
         switch(this._ingredient.unit){
             case "g": return quantity;
@@ -3231,7 +3239,7 @@ let recipeDetails = {
             ingredientDiv = template.cloneNode(true);
 
             ingredientDiv.children[0].innerText = recipe.ingredients[i].ingredient.name;
-            ingredientDiv.children[2].innerText = `${recipe.ingredients[i].ingredient.convert(recipe.ingredients[i].quantity).toFixed(2)} ${recipe.ingredients[i].ingredient.unit}`;
+            ingredientDiv.children[2].innerText = recipe.ingredients[i].getQuantityDisplay();
             ingredientDiv.ingredient = recipe.ingredients[i].ingredient;
             ingredientDiv.name = recipe.ingredients[i].ingredient.name;
 

+ 8 - 0
views/dashboardPage/js/Recipe.js

@@ -49,6 +49,14 @@ class RecipeIngredient{
         this_quantity = this.convertToBase(quantity);
     }
 
+    getQuantityDisplay(){
+        if(this._ingredient.specialUnit === "bottle"){
+            return `${this.quantity.toFixed(2)} BOTTLES`;
+        }
+
+        return `${this.quantity.toFixed(2)} ${this._ingredient.unit.toUpperCase()}`;
+    }
+
     convertToBase(quantity){
         switch(this._ingredient.unit){
             case "g": return quantity;

+ 1 - 1
views/dashboardPage/js/recipeDetails.js

@@ -18,7 +18,7 @@ let recipeDetails = {
             ingredientDiv = template.cloneNode(true);
 
             ingredientDiv.children[0].innerText = recipe.ingredients[i].ingredient.name;
-            ingredientDiv.children[2].innerText = `${recipe.ingredients[i].ingredient.convert(recipe.ingredients[i].quantity).toFixed(2)} ${recipe.ingredients[i].ingredient.unit}`;
+            ingredientDiv.children[2].innerText = recipe.ingredients[i].getQuantityDisplay();
             ingredientDiv.ingredient = recipe.ingredients[i].ingredient;
             ingredientDiv.name = recipe.ingredients[i].ingredient.name;