|
|
@@ -119,9 +119,9 @@ const Recipe = require("./Recipe.js");
|
|
|
const Transaction = require("./Transaction.js");
|
|
|
const Order = require("./Order.js");
|
|
|
|
|
|
-const home = require("../strands/home.js");
|
|
|
+const homeStrand = require("../strands/home.js");
|
|
|
const ingredientsStrand = require("../strands/ingredients.js");
|
|
|
-const recipeBook = require("../strands/recipeBook");
|
|
|
+const recipeBookStrand = require("../strands/recipeBook");
|
|
|
const analytics = require("../strands/analytics.js");
|
|
|
const orders = require("../strands/orders");
|
|
|
|
|
|
@@ -327,7 +327,7 @@ class Merchant{
|
|
|
|
|
|
this._ingredients.splice(index, 1);
|
|
|
|
|
|
- home.drawInventoryCheckCard();
|
|
|
+ homeStrand.drawInventoryCheckCard();
|
|
|
ingredientsStrand.populateByProperty();
|
|
|
}
|
|
|
|
|
|
@@ -343,12 +343,29 @@ class Merchant{
|
|
|
return this._recipes;
|
|
|
}
|
|
|
|
|
|
- addRecipe(id, name, price, ingredients){
|
|
|
- let recipe = new Recipe(id, name, price, ingredients, this);
|
|
|
-
|
|
|
- this._recipes.push(recipe);
|
|
|
+ /*
|
|
|
+ recipes: [{
|
|
|
+ _id: String
|
|
|
+ name: String
|
|
|
+ price: Number
|
|
|
+ ingredients: [{
|
|
|
+ ingredient: String (id)
|
|
|
+ quantity: Number
|
|
|
+ }]
|
|
|
+ }]
|
|
|
+ */
|
|
|
+ addRecipes(recipes){
|
|
|
+ for(let i = 0; i < recipes.length; i++){
|
|
|
+ this._recipes.push(new Recipe(
|
|
|
+ recipes[i]._id,
|
|
|
+ recipes[i].name,
|
|
|
+ recipes[i].price,
|
|
|
+ recipes[i].ingredients,
|
|
|
+ this
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
- recipeBook.isPopulated = false;
|
|
|
+ recipeBookStrand.populateRecipes();
|
|
|
}
|
|
|
|
|
|
removeRecipe(recipe){
|
|
|
@@ -359,7 +376,7 @@ class Merchant{
|
|
|
|
|
|
this._recipes.splice(index, 1);
|
|
|
|
|
|
- recipeBook.isPopulated = false;
|
|
|
+ recipeBookStrand.populateRecipes();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -396,7 +413,7 @@ class Merchant{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- recipeBook.isPopulated = false;
|
|
|
+ recipeBookStrand.isPopulated = false;
|
|
|
}
|
|
|
|
|
|
get transactions(){
|
|
|
@@ -455,7 +472,7 @@ class Merchant{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- home.isPopulated = false;
|
|
|
+ homeStrand.isPopulated = false;
|
|
|
ingredientsStrand.isPopulated = false;
|
|
|
analytics.newData = true;
|
|
|
}
|
|
|
@@ -491,7 +508,7 @@ class Merchant{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- home.isPopulated = false;
|
|
|
+ homeStrand.isPopulated = false;
|
|
|
ingredientsStrand.isPopulated = false;
|
|
|
analytics.newData = true;
|
|
|
}
|
|
|
@@ -2198,26 +2215,7 @@ let newRecipe = {
|
|
|
if(typeof(response) === "string"){
|
|
|
controller.createBanner(response, "error");
|
|
|
}else{
|
|
|
- let ingredients = [];
|
|
|
- for(let i = 0; i < response.ingredients.length; i++){
|
|
|
- for(let j = 0; j < merchant.ingredients.length; j++){
|
|
|
- if(merchant.ingredients[j].ingredient.id === response.ingredients[i].ingredient){
|
|
|
- ingredients.push({
|
|
|
- ingredient: merchant.ingredients[j].ingredient.id,
|
|
|
- quantity: response.ingredients[i].quantity
|
|
|
- });
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- merchant.addRecipe(
|
|
|
- response._id,
|
|
|
- response.name,
|
|
|
- response.price,
|
|
|
- ingredients
|
|
|
- );
|
|
|
+ merchant.addRecipes([response]);
|
|
|
|
|
|
controller.createBanner("RECIPE CREATED", "success");
|
|
|
controller.openStrand("recipeBook");
|
|
|
@@ -3864,6 +3862,7 @@ let recipeBook = {
|
|
|
if(merchant.pos !== "none"){
|
|
|
document.getElementById("posUpdateRecipe").onclick = ()=>{this.posUpdate()};
|
|
|
}
|
|
|
+
|
|
|
document.getElementById("recipeSearch").oninput = ()=>{this.search()};
|
|
|
|
|
|
this.populateRecipes();
|