|
|
@@ -73,11 +73,10 @@ let editIngredient = {
|
|
|
id: ingredient.ingredient.id,
|
|
|
name: document.getElementById("editIngName").value,
|
|
|
category: document.getElementById("editIngCategory").value,
|
|
|
- ingredients: []
|
|
|
+ ingredients: [],
|
|
|
+ quantity: controller.baseUnit(quantity, ingredient.ingredient.unit)
|
|
|
}
|
|
|
|
|
|
- data.quantity = controller.baseUnit(quantity, ingredient.ingredient.unit);
|
|
|
-
|
|
|
//Get the measurement unit
|
|
|
let units = document.getElementById("unitButtons");
|
|
|
for(let i = 0; i < units.children.length; i++){
|
|
|
@@ -87,15 +86,6 @@ let editIngredient = {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //Add the sub-ingredients
|
|
|
- for(let i = 0; i < ingredient.ingredient.subIngredients.length; i++){
|
|
|
- let subIngredient = ingredient.ingredient.subIngredients[i];
|
|
|
- data.ingredients.push({
|
|
|
- ingredient: subIngredient.ingredient.id,
|
|
|
- quantity: subIngredient.quantity
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
let loader = document.getElementById("loaderContainer");
|
|
|
loader.style.display = "flex";
|
|
|
|
|
|
@@ -109,8 +99,7 @@ let editIngredient = {
|
|
|
.then(response => response.json())
|
|
|
.then((response)=>{
|
|
|
if(typeof(response) === "string"){
|
|
|
- controller.createBanner("ERROR: CIRCULAR REFERENCE", "error");
|
|
|
- controller.openModal("circularReference", response);
|
|
|
+ controller.createBanner(response, "error");
|
|
|
}else{
|
|
|
merchant.removeIngredient(merchant.getIngredient(response.ingredient._id));
|
|
|
merchant.addIngredients([response]);
|