Просмотр исходного кода

Bug fix so that merchant is created on page load

Lee Morgan 5 лет назад
Родитель
Сommit
727f0010d3

+ 58 - 25
views/dashboardPage/bundle.js

@@ -1,15 +1,15 @@
 (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){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             banner.createError("NAME CONTAINS ILLEGAL CHARCTERS");
             return false;
         }
-        if(!controller.sanitaryString(category)){
+        if(!this.isSanitaryString(category)){
             banner.createError("CATEGORY CONTAINS ILLEGAL CHARACTERS");
             return false;
         }
-        
+
         this._id = id;
         this._name = name;
         this._category = category;
@@ -31,7 +31,7 @@ class Ingredient{
     }
 
     set name(name){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             return false;
         }
 
@@ -43,7 +43,7 @@ class Ingredient{
     }
 
     set category(category){
-        if(!controller.sanitaryString(category)){
+        if(!this.isSanitaryString(category)){
             return false;
         }
 
@@ -81,6 +81,18 @@ class Ingredient{
 
         this._unitSize = unitSize;
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Ingredient;
@@ -91,7 +103,7 @@ class MerchantIngredient{
             banner.createError("QUANTITY CANNOT BE A NEGATIVE NUMBER");
             return false;
         }
-        
+
         this._ingredient = ingredient;
         this._quantity = this.convertToBase(quantity);
     }
@@ -239,7 +251,7 @@ class Merchant{
     }
 
     set name(name){
-        if(sanitaryString(name)){
+        if(this.isSanitaryString(name)){
             this._name = name;
         }
         return false;
@@ -675,6 +687,18 @@ class Merchant{
 
         return {from: from, to: to};
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Merchant;
@@ -744,7 +768,7 @@ class OrderIngredient{
 
 class Order{
     constructor(id, name, date, taxes, fees, ingredients, parent){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             banner.createError("NAME CONTAINS ILLEGAL CHARACTERS");
             return false;
         }
@@ -804,6 +828,18 @@ class Order{
     get ingredients(){
         return this._ingredients;
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Order;
@@ -886,7 +922,7 @@ class Recipe{
             banner.createError("PRICE CANNOT BE A NEGATIVE NUMBER");
             return false;
         }
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             banner.createError("NAME CONTAINS ILLEGAL CHARACTERS");
             return false;
         }
@@ -907,7 +943,6 @@ class Recipe{
 
         this._parent.modules.recipeBook.isPopulated = false;
         this._parent.modules.analytics.isPopulated = false;
-        this._parent.modules.recipeBook.display();
     }
 
     get id(){
@@ -919,7 +954,7 @@ class Recipe{
     }
 
     set name(name){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             return false;
         }
 
@@ -975,6 +1010,18 @@ class Recipe{
 
         this._ingredients[index].quantity = quantity;
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Recipe;
@@ -1396,18 +1443,6 @@ merchant = new Merchant(data.merchant, data.transactions, {
 });
 
 controller = {
-    sanitaryString: function(str){
-        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
-
-        for(let i = 0; i < disallowed.length; j++){
-            if(str.includes(disallowed[i])){
-                return false;
-            }
-        }
-
-        return true;
-    },
-
     openStrand: function(strand){
         this.closeSidebar();
 
@@ -2186,7 +2221,6 @@ let ingredientDetails = {
                 }
             })
             .catch((err)=>{
-                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             .finally(()=>{
@@ -2467,7 +2501,6 @@ let newIngredient = {
                 }
             })
             .catch((err)=>{
-                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             .finally(()=>{

+ 17 - 5
views/dashboardPage/js/Ingredient.js

@@ -1,14 +1,14 @@
 class Ingredient{
     constructor(id, name, category, unitType, unit, parent, specialUnit = undefined, unitSize = undefined){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             banner.createError("NAME CONTAINS ILLEGAL CHARCTERS");
             return false;
         }
-        if(!controller.sanitaryString(category)){
+        if(!this.isSanitaryString(category)){
             banner.createError("CATEGORY CONTAINS ILLEGAL CHARACTERS");
             return false;
         }
-        
+
         this._id = id;
         this._name = name;
         this._category = category;
@@ -30,7 +30,7 @@ class Ingredient{
     }
 
     set name(name){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             return false;
         }
 
@@ -42,7 +42,7 @@ class Ingredient{
     }
 
     set category(category){
-        if(!controller.sanitaryString(category)){
+        if(!this.isSanitaryString(category)){
             return false;
         }
 
@@ -80,6 +80,18 @@ class Ingredient{
 
         this._unitSize = unitSize;
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Ingredient;

+ 14 - 2
views/dashboardPage/js/Merchant.js

@@ -4,7 +4,7 @@ class MerchantIngredient{
             banner.createError("QUANTITY CANNOT BE A NEGATIVE NUMBER");
             return false;
         }
-        
+
         this._ingredient = ingredient;
         this._quantity = this.convertToBase(quantity);
     }
@@ -152,7 +152,7 @@ class Merchant{
     }
 
     set name(name){
-        if(sanitaryString(name)){
+        if(this.isSanitaryString(name)){
             this._name = name;
         }
         return false;
@@ -588,6 +588,18 @@ class Merchant{
 
         return {from: from, to: to};
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Merchant;

+ 13 - 1
views/dashboardPage/js/Order.js

@@ -63,7 +63,7 @@ class OrderIngredient{
 
 class Order{
     constructor(id, name, date, taxes, fees, ingredients, parent){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             banner.createError("NAME CONTAINS ILLEGAL CHARACTERS");
             return false;
         }
@@ -123,6 +123,18 @@ class Order{
     get ingredients(){
         return this._ingredients;
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Order;

+ 14 - 3
views/dashboardPage/js/Recipe.js

@@ -76,7 +76,7 @@ class Recipe{
             banner.createError("PRICE CANNOT BE A NEGATIVE NUMBER");
             return false;
         }
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             banner.createError("NAME CONTAINS ILLEGAL CHARACTERS");
             return false;
         }
@@ -97,7 +97,6 @@ class Recipe{
 
         this._parent.modules.recipeBook.isPopulated = false;
         this._parent.modules.analytics.isPopulated = false;
-        this._parent.modules.recipeBook.display();
     }
 
     get id(){
@@ -109,7 +108,7 @@ class Recipe{
     }
 
     set name(name){
-        if(!controller.sanitaryString(name)){
+        if(!this.isSanitaryString(name)){
             return false;
         }
 
@@ -165,6 +164,18 @@ class Recipe{
 
         this._ingredients[index].quantity = quantity;
     }
+
+    isSanitaryString(str){
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
+
+        for(let i = 0; i < disallowed.length; i++){
+            if(str.includes(disallowed[i])){
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
 
 module.exports = Recipe;

+ 0 - 12
views/dashboardPage/js/dashboard.js

@@ -33,18 +33,6 @@ merchant = new Merchant(data.merchant, data.transactions, {
 });
 
 controller = {
-    sanitaryString: function(str){
-        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
-
-        for(let i = 0; i < disallowed.length; j++){
-            if(str.includes(disallowed[i])){
-                return false;
-            }
-        }
-
-        return true;
-    },
-
     openStrand: function(strand){
         this.closeSidebar();
 

+ 0 - 1
views/dashboardPage/js/ingredientDetails.js

@@ -255,7 +255,6 @@ let ingredientDetails = {
                 }
             })
             .catch((err)=>{
-                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             .finally(()=>{

+ 0 - 1
views/dashboardPage/js/newIngredient.js

@@ -87,7 +87,6 @@ let newIngredient = {
                 }
             })
             .catch((err)=>{
-                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             .finally(()=>{