Преглед изворни кода

Add some of the submit function for new recipe sidebar.
Pausing to fix some stupid fucking code.

Lee Morgan пре 5 година
родитељ
комит
3b436338f6
1 измењених фајлова са 17 додато и 0 уклоњено
  1. 17 0
      views/dashboardPage/js/sidebars/newRecipe.js

+ 17 - 0
views/dashboardPage/js/sidebars/newRecipe.js

@@ -41,8 +41,25 @@ let newRecipe = {
             element.parentElement.removeChild(element);
             this.populateChoices();
         };
+        element.ingredient = ingredient;
         document.getElementById("newRecipeChosenList").appendChild(element);
     },
+
+    submit: function(){
+        let data = {
+            name: document.getElementById("newRecipeName").value,
+            price: document.getElementById("newRecipePrice").value,
+            ingredients: []
+        };
+
+        let ingredients = document.getElementById("newRecipeChosenList").children;
+        for(let i = 0; i < ingredients.length; i++){
+            data.ingredients.push({
+                ingredient: ingredients[i].ingredient,
+                quantity: ingredients[i].children[0].children[0].value
+            })
+        }
+    }
 };
 
 module.exports = newRecipe;