Bladeren bron

Update newIngredient.js to reflect new bottles data structure.
Add unitSize to models and classes for bottles.

Lee Morgan 5 jaren geleden
bovenliggende
commit
2f7a823a56

+ 4 - 0
models/ingredient.js

@@ -24,6 +24,10 @@ const IngredientSchema = new mongoose.Schema({
     unitType: {
         type: String,
         required: [true, "UNIT TYPE IS REQUIRED"]
+    },
+    unitSize: {
+        type: Number,
+        min: [0, "SIZE CANNOT BE A NEGATIVE NUMBER"]
     }
 });
 

+ 3 - 5
views/dashboardPage/bundle.js

@@ -1,12 +1,13 @@
 (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
 class Ingredient{
-    constructor(id, name, category, unitType, unit, parent, specialUnit = undefined, unitSize = undefined){
+    constructor(id, name, category, unitType, unit, parent, unitSize = undefined){
         this._id = id;
         this._name = name;
         this._category = category;
         this._unitType = unitType;
         this._unit = unit;
         this._parent = parent;
+        this._unitSize = unitSize;
     }
 
     get id(){
@@ -1963,11 +1964,8 @@ let newIngredient = {
 
         //Change the ingredient if it is a special unit type (ie "bottle")
         if(unit === "bottle"){
-            newIngredient.ingredient.unitType = "volume";
+            newIngredient.ingredient.unitType = document.getElementById("bottleUnits").value;
             newIngredient.ingredient.unitSize = document.getElementById("bottleSize").value;
-            newIngredient.defaultUnit = document.getElementById("bottleUnits").value;
-            newIngredient.ingredient.specialUnit = unit;
-            newIngredient.quantity = quantityValue;
         }
     
         let loader = document.getElementById("loaderContainer");

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

@@ -1,11 +1,12 @@
 class Ingredient{
-    constructor(id, name, category, unitType, unit, parent, specialUnit = undefined, unitSize = undefined){
+    constructor(id, name, category, unitType, unit, parent, unitSize = undefined){
         this._id = id;
         this._name = name;
         this._category = category;
         this._unitType = unitType;
         this._unit = unit;
         this._parent = parent;
+        this._unitSize = unitSize;
     }
 
     get id(){

+ 1 - 4
views/dashboardPage/js/sidebars/newIngredient.js

@@ -42,11 +42,8 @@ let newIngredient = {
 
         //Change the ingredient if it is a special unit type (ie "bottle")
         if(unit === "bottle"){
-            newIngredient.ingredient.unitType = "volume";
+            newIngredient.ingredient.unitType = document.getElementById("bottleUnits").value;
             newIngredient.ingredient.unitSize = document.getElementById("bottleSize").value;
-            newIngredient.defaultUnit = document.getElementById("bottleUnits").value;
-            newIngredient.ingredient.specialUnit = unit;
-            newIngredient.quantity = quantityValue;
         }
     
         let loader = document.getElementById("loaderContainer");