فهرست منبع

Rename backend variable for greater clarity

Lee Morgan 5 سال پیش
والد
کامیت
28ab0e7c24

+ 1 - 1
controllers/ingredientData.js

@@ -45,7 +45,7 @@ module.exports = {
         if(validation !== true){
             return res.json(validation);
         }
-        validation = Validator.quantity(req.body.ingredient.bottleSize);
+        validation = Validator.quantity(req.body.ingredient.unitSize);
         if(validation !== true){
             return res.json(validation);
         }

+ 4 - 1
models/ingredient.js

@@ -14,7 +14,10 @@ const IngredientSchema = new mongoose.Schema({
         type: String,
         required: true
     },
-    bottleSize: Number
+    unitSize:{
+        type: Number,
+        required: false
+    }
 });
 
 module.exports = mongoose.model("Ingredient", IngredientSchema);

+ 4 - 3
views/dashboardPage/bundle.js

@@ -78,7 +78,7 @@ class Merchant{
                     oldMerchant.inventory[i].ingredient.unitType,
                     oldMerchant.inventory[i].defaultUnit,
                     this,
-                    oldMerchant.inventory[i].ingredient.bottleSize
+                    oldMerchant.inventory[i].ingredient.unitSize
                 ),
                 quantity: oldMerchant.inventory[i].quantity
             });
@@ -1876,7 +1876,7 @@ let newIngredient = {
             const bottleSize = controller.convertToMain(bottleUnit, document.getElementById("bottleSize").value);
 
             newIngredient.ingredient.unitType = "volume";
-            newIngredient.ingredient.bottleSize = bottleSize;
+            newIngredient.ingredient.unitSize = bottleSize;
             newIngredient.defaultUnit = bottleUnit;
         }
     
@@ -1902,7 +1902,8 @@ let newIngredient = {
                             response.ingredient.category,
                             response.ingredient.unitType,
                             response.defaultUnit,
-                            merchant
+                            merchant,
+                            response.ingredient.unitSize
                         ),
                         quantity: response.quantity
                     }]);

+ 1 - 1
views/dashboardPage/js/Merchant.js

@@ -27,7 +27,7 @@ class Merchant{
                     oldMerchant.inventory[i].ingredient.unitType,
                     oldMerchant.inventory[i].defaultUnit,
                     this,
-                    oldMerchant.inventory[i].ingredient.bottleSize
+                    oldMerchant.inventory[i].ingredient.unitSize
                 ),
                 quantity: oldMerchant.inventory[i].quantity
             });

+ 3 - 2
views/dashboardPage/js/newIngredient.js

@@ -39,7 +39,7 @@ let newIngredient = {
             const bottleSize = controller.convertToMain(bottleUnit, document.getElementById("bottleSize").value);
 
             newIngredient.ingredient.unitType = "volume";
-            newIngredient.ingredient.bottleSize = bottleSize;
+            newIngredient.ingredient.unitSize = bottleSize;
             newIngredient.defaultUnit = bottleUnit;
         }
     
@@ -65,7 +65,8 @@ let newIngredient = {
                             response.ingredient.category,
                             response.ingredient.unitType,
                             response.defaultUnit,
-                            merchant
+                            merchant,
+                            response.ingredient.unitSize
                         ),
                         quantity: response.quantity
                     }]);