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

Update bug when creating new orders with a unit of count

Lee Morgan 6 лет назад
Родитель
Сommit
bc3cef9ed3

+ 1 - 0
controllers/ingredientData.js

@@ -65,6 +65,7 @@ module.exports = {
                 return res.json(newIngredient);
             })
             .catch((err)=>{
+                console.log(err);
                 return res.json("ERROR: UNABLE TO CREATE NEW INGREDIENT");
             });
     }

+ 1 - 1
views/dashboardPage/sidebars/ingredientDetails.ejs

@@ -47,7 +47,7 @@
 
     <div class="lineBorder"></div>
 
-    <label>DISPLAY UNIT:</label>
+    <label id="displayUnitLabel">DISPLAY UNIT:</label>
 
     <div id="ingredientButtons" class="ingredientButtons"></div>
 

+ 1 - 1
views/dashboardPage/sidebars/newIngredient.ejs

@@ -52,7 +52,7 @@
             </optgroup>
 
             <optgroup label="OTHER">
-                <option value="count">count</option>
+                <option type="other" value="each">count</option>
             </optgroup>
         </select>
     </label>

+ 10 - 3
views/dashboardPage/sidebars/newOrder.ejs

@@ -10,11 +10,18 @@
 
     <h1>NEW ORDER</h1>
 
-    <label>ID OR NAME(OPTIONAL):
-        <input id="orderName" type="text"> 
+    <label>ID/NAME:
+        <input id="orderName" type="text">
     </label>
 
-    <input id="orderDate" type="date">
+    <label>Date:
+        <input id="orderDate" type="date">
+    </label>
+
+    <label>Time:
+        <input id="orderTime" type="time">
+    </label>
+    
 
     <div id=newOrderCategories></div>
 

+ 14 - 1
views/dashboardPage/sidebars/sidebars.js

@@ -324,6 +324,7 @@ let newIngredientComp = {
 
         let unit = unitSelector.value;
 
+        console.log(options[unitSelector.selectedIndex].getAttribute("type"));
         let newIngredient = {
             ingredient: {
                 name: document.getElementById("newIngName").value,
@@ -347,6 +348,7 @@ let newIngredientComp = {
             .then((response) => response.json())
             .then((response)=>{
                 if(typeof(response) === "string"){
+                    console.log(response);
                     banner.createError(response);
                 }else{
                     merchant.editIngredients([{
@@ -720,7 +722,18 @@ let ingredientDetailsComp = {
         }
 
         let ingredientButtons = document.getElementById("ingredientButtons");
-        let units = merchant.units[this.ingredient.ingredient.unitType];
+        let units = [];
+        let unitLabel = document.getElementById("displayUnitLabel");
+        let defaultButton = document.getElementById("defaultUnit");
+        if(this.ingredient.ingredient.unitType !== "other"){
+            units = merchant.units[this.ingredient.ingredient.unitType];
+            unitLabel.style.display = "block";
+            defaultButton.style.display = "block";
+        }else{
+            unitLabel.style.display = "none";
+            defaultButton.style.display = "none";
+        }
+        
         while(ingredientButtons.children.length > 0){
             ingredientButtons.removeChild(ingredientButtons.firstChild);
         }