Sfoglia il codice sorgente

Update the frontend models.

Lee Morgan 5 anni fa
parent
commit
58d7058a91

+ 6 - 1
views/dashboardPage/js/classes/Ingredient.js

@@ -1,5 +1,5 @@
 class Ingredient{
-    constructor(id, name, category, unitType, unit, parent, unitSize = undefined){
+    constructor(id, name, category, unitType, unit, parent, unitSize = undefined, ingredients){
         this._id = id;
         this._name = name;
         this._category = category;
@@ -7,6 +7,11 @@ class Ingredient{
         this._unit = unit;
         this._parent = parent;
         this._unitSize = unitSize;
+        this._ingredients = [];
+
+        for(let i = 0; i < ingredients.length; i++){
+            ingredients.push(this._parent.getIngredient(ingredinets[i]));
+        }
     }
 
     get id(){

+ 4 - 2
views/dashboardPage/js/classes/Merchant.js

@@ -101,7 +101,8 @@ class Merchant{
                 ingredients[i].ingredient.unitType,
                 ingredients[i].defaultUnit,
                 this,
-                ingredients[i].ingredient.unitSize
+                ingredients[i].ingredient.unitSize,
+                ingredients[i].ingredient.ingredients
             );
 
             const merchantIngredient = new MerchantIngredient(
@@ -199,7 +200,8 @@ class Merchant{
                 ingredient.unitType,
                 defaultUnit,
                 this,
-                ingredient.unitSize
+                ingredient.unitSize,
+                ingredient.ingredients
             );
 
             const merchantIngredient = new MerchantIngredient(createdIngredient, quantity);