|
@@ -15,9 +15,11 @@ module.exports = {
|
|
|
tempList.push(recipe.ingredients[i].ingredient.id);
|
|
tempList.push(recipe.ingredients[i].ingredient.id);
|
|
|
|
|
|
|
|
let ingredient = template.cloneNode(true);
|
|
let ingredient = template.cloneNode(true);
|
|
|
|
|
+ ingredient.ingredient = recipe.ingredients[i].ingredient;
|
|
|
ingredient.children[0].children[0].innerText = recipe.ingredients[i].ingredient.name;
|
|
ingredient.children[0].children[0].innerText = recipe.ingredients[i].ingredient.name;
|
|
|
ingredient.children[0].children[1].onclick = ()=>{this.removeIngredient(recipe.ingredients[i])};
|
|
ingredient.children[0].children[1].onclick = ()=>{this.removeIngredient(recipe.ingredients[i])};
|
|
|
- ingredient.children[1].children[0].placeholder = "QUANTITY";
|
|
|
|
|
|
|
+ ingredient.children[1].children[0].value = recipe.ingredients[i].quantity;
|
|
|
|
|
+ ingredient.children[1].children[1].value = recipe.ingredients[i].unit;
|
|
|
used.appendChild(ingredient);
|
|
used.appendChild(ingredient);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -28,14 +30,30 @@ module.exports = {
|
|
|
button.innerText = merchant.inventory[i].ingredient.name;
|
|
button.innerText = merchant.inventory[i].ingredient.name;
|
|
|
button.classList.add("choosable");
|
|
button.classList.add("choosable");
|
|
|
button.classList.add("selection");
|
|
button.classList.add("selection");
|
|
|
- button.onclick = ()=>{this.addIngredient(merchant.inventory[i].ingredient)};
|
|
|
|
|
|
|
+ button.ingredient = merchant.inventory[i].ingredient;
|
|
|
|
|
+ button.onclick = ()=>{this.addIngredient(button)};
|
|
|
this.unused.push(button);
|
|
this.unused.push(button);
|
|
|
unused.appendChild(button);
|
|
unused.appendChild(button);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
addIngredient: function(ingredient){
|
|
addIngredient: function(ingredient){
|
|
|
- console.log(ingredient);
|
|
|
|
|
|
|
+ for(let i = 0; i < this.unused.length; i++){
|
|
|
|
|
+ if(this.unused[i] === ingredient){
|
|
|
|
|
+ this.unused.splice(i, 1);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let unused = document.getElementById("editRecipeUnused");
|
|
|
|
|
+ unused.removeChild(ingredient);
|
|
|
|
|
+ let used = document.getElementById("editRecipeUsed");
|
|
|
|
|
+
|
|
|
|
|
+ let newItem = document.getElementById("editRecipeInputItem").content.children[0].cloneNode(true);
|
|
|
|
|
+ newItem.ingredient = ingredient.ingredient;
|
|
|
|
|
+ newItem.children[0].children[0].innerText = ingredient.ingredient.name;
|
|
|
|
|
+ newItem.children[0].children[1].onclick = ()=>{this.removeIngredient(ingredient.ingredient)};
|
|
|
|
|
+ used.appendChild(newItem);
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
removeIngredient: function(ingredient){
|
|
removeIngredient: function(ingredient){
|