فهرست منبع

Remove modal for recipe unit conversions.
Remove gatherData function from recipe creation.

Lee Morgan 5 سال پیش
والد
کامیت
2b0a1c0731
3فایلهای تغییر یافته به همراه8 افزوده شده و 68 حذف شده
  1. 0 32
      views/dashboardPage/ejs/modal.ejs
  2. 0 3
      views/dashboardPage/js/dashboard.js
  3. 8 33
      views/dashboardPage/js/sidebars/newRecipe.js

+ 0 - 32
views/dashboardPage/ejs/modal.ejs

@@ -97,38 +97,6 @@
 
                 <button id="circularReferenceButton" class="button">OK</button>
             </div>
-
-            <div id="modalUnitConversion" style="display:none">
-                <h2>Some of your ingredients' units do not match</h2>
-
-                <h3>Please enter conversion rates for the following ingredients in this recipe</h3>
-
-                <div id="unitConversions"></div>
-
-                <button id="submitAlternateUnits" class="button">SUBMIT</button>
-
-                <template id="convertUnitOption">
-                    <div class="convertUnitOption">
-                        <h2></h2>
-
-                        <div>
-                            <div class="convertInputBox">
-                                <input type="number" step="0.01">
-    
-                                <p></p>
-                            </div>
-    
-                            <h1>=</h1>
-    
-                            <div class="convertInputBox">
-                                <input type="number" step="0.01">
-    
-                                <p></p>
-                            </div>
-                        </div>
-                    </div>
-                </template>
-            </div>
         </div>
     </div>
 </div>

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

@@ -277,9 +277,6 @@ controller = {
             case "circularReference":
                 modalScript.circularReference(data);
                 break;
-            case "alternateUnitConversion":
-                modalScript.alternateUnit(data);
-                break;
         }
     },
 

+ 8 - 33
views/dashboardPage/js/sidebars/newRecipe.js

@@ -12,7 +12,7 @@ let newRecipe = {
             chosen.removeChild(chosen.firstChild);
         }
 
-        document.getElementById("submitNewRecipe").onclick = ()=>{this.gatherData()};
+        document.getElementById("submitNewRecipe").onclick = ()=>{this.submit()};
         document.getElementById("recipeFileUpload").onclick = ()=>{controller.openModal("recipeSpreadsheet")};
         document.getElementById("newRecipeSearch").onkeyup = ()=>{this.populateChoices()};
 
@@ -62,49 +62,24 @@ let newRecipe = {
         document.getElementById("newRecipeChosenList").appendChild(element);
     },
 
-    gatherData: function(){
+    submit: function(){
         let data = {
             name: document.getElementById("newRecipeName").value,
-            category: document.getElementById("newRecipeCategory").value,
             price: parseInt(document.getElementById("newRecipePrice").value * 100),
-            ingredients: []
-        };
-    
-        let mismatchUnits = [];
+            category: document.getElementById("newRecipeCategory").value,
+            ingredients = []
+        }
+
         let ingredients = document.getElementById("newRecipeChosenList").children;
         for(let i = 0; i < ingredients.length; i++){
             let ingredient = ingredients[i].ingredient;
-            let newIngredient = {
+            data.ingredients.push({
                 ingredient: ingredient.id,
                 quantity: ingredients[i].children[1].children[0].value,
                 unit: ingredients[i].children[1].children[1].value
-            }
-    
-            // if(ingredient.getPotentialUnits().includes(newIngredient.unit) === false){
-            //     mismatchUnits.push({ingredient: ingredient, newIngredient: newIngredient});
-            // }else{
-            //     newIngredient.baseUnitMultiplier = 1 / controller.baseUnit(1, newIngredient.unit);
-            // }
-            
-            if(["g", "kg", "oz", "lb"].includes(newIngredient.unit) && ingredient.toMass === undefined){
-                mismatchUnits.push({ingredient: ingredient, newIngredient: newIngredient});
-            }else if(["ml", "l", "tsp", "tbsp", "ozfl", "cup", "pt", "qt", "gal"].includes(newIngredient.unit) && ingredient.toVolume === undefined){
-                mismatchUnits.push({ingredient: ingredient, newIngredient: newIngredient});
-            }else if(["mm", "cm", "m", "in", "ft"].includes(newIngredient.unit) && ingredient.toLength === undefined){
-                mismatchUnits.push({ingredient: ingredient, newIngredient: newIngredient});
-            }
-    
-            data.ingredients.push(newIngredient);
-        }
-
-        if(mismatchUnits.length === 0){
-            this.submit(data);
-            return;
+            });
         }
-        controller.openModal("alternateUnitConversion", {mismatchUnits: mismatchUnits, recipe: data, submit: this.submit});
-    },
 
-    submit: function(data){
         let loader = document.getElementById("loaderContainer");
         loader.style.display = "flex";