Explorar el Código

Remove updateIngredient function from Merchant on frontend.
Updating ingredients is now done be removing and then re-adding.

Lee Morgan hace 5 años
padre
commit
bbc331cc4a

+ 0 - 13
views/dashboardPage/bundle.js

@@ -348,18 +348,6 @@ class Merchant{
         this._modules.ingredients.isPopulated = false;
     }
 
-    updateIngredient(ingredient, quantity){
-        const index = this._ingredients.indexOf(ingredient);
-        if(index === undefined){
-            return false;
-        }
-
-        this._ingredients[index].quantity = quantity;
-
-        this._modules.home.isPopulated = false;
-        this._modules.ingredients.isPopulated = false;
-    }
-
     getIngredient(id){
         for(let i = 0; i < this._ingredients.length; i++){
             if(this._ingredients[i].ingredient.id === id){
@@ -3432,7 +3420,6 @@ let home = {
                         banner.createError(response);
                     }else{
                         for(let i = 0; i < response.length; i++){
-                            // merchant.updateIngredient(changes[i].ingredient, changes[i].quantity);
                             merchant.removeIngredient(merchant.getIngredient(response[i].ingredient._id));
                             merchant.addIngredient(response[i].ingredient, response[i].quantity, response[i].defaultUnit);
                         }

+ 0 - 12
views/dashboardPage/js/classes/Merchant.js

@@ -221,18 +221,6 @@ class Merchant{
         this._modules.ingredients.isPopulated = false;
     }
 
-    updateIngredient(ingredient, quantity){
-        const index = this._ingredients.indexOf(ingredient);
-        if(index === undefined){
-            return false;
-        }
-
-        this._ingredients[index].quantity = quantity;
-
-        this._modules.home.isPopulated = false;
-        this._modules.ingredients.isPopulated = false;
-    }
-
     getIngredient(id){
         for(let i = 0; i < this._ingredients.length; i++){
             if(this._ingredients[i].ingredient.id === id){

+ 0 - 1
views/dashboardPage/js/strands/home.js

@@ -247,7 +247,6 @@ let home = {
                         banner.createError(response);
                     }else{
                         for(let i = 0; i < response.length; i++){
-                            // merchant.updateIngredient(changes[i].ingredient, changes[i].quantity);
                             merchant.removeIngredient(merchant.getIngredient(response[i].ingredient._id));
                             merchant.addIngredient(response[i].ingredient, response[i].quantity, response[i].defaultUnit);
                         }