瀏覽代碼

Add ability for clover users to update recipe ingredients

Lee Morgan 6 年之前
父節點
當前提交
e35b825b68
共有 2 個文件被更改,包括 20 次插入16 次删除
  1. 13 9
      views/dashboardPage/components/components.js
  2. 7 7
      views/dashboardPage/components/recipeDetails.ejs

+ 13 - 9
views/dashboardPage/components/components.js

@@ -39,11 +39,18 @@ let recipeDetailsComp = {
     edit: function(){
         let ingredientDivs = document.querySelector("#recipeIngredientList");
 
-        let name = document.querySelector("#recipeName");
-        let nameIn = document.querySelector("#recipeNameIn");
-        name.style.display = "none";
-        nameIn.style.display = "block";
-        nameIn.placeholder = name.innerText;
+        if(merchant.pos === "none"){
+            let name = document.querySelector("#recipeName");
+            let nameIn = document.querySelector("#recipeNameIn");
+            name.style.display = "none";
+            nameIn.style.display = "block";
+            nameIn.placeholder = name.innerText;
+
+            let price = document.querySelector("#recipePrice");
+            price.children[1].style.display = "none";
+            price.children[2].style.display = "block";
+            price.children[2].placeholder = price.children[1].innerText;
+        }
 
         for(let i = 0; i < ingredientDivs.children.length; i++){
             let div = ingredientDivs.children[i];
@@ -57,10 +64,7 @@ let recipeDetailsComp = {
 
         document.querySelector("#addRecIng").style.display = "flex";
 
-        let price = document.querySelector("#recipePrice");
-        price.children[1].style.display = "none";
-        price.children[2].style.display = "block";
-        price.children[2].placeholder = price.children[1].innerText;
+        
 
         document.querySelector("#recipeUpdate").style.display = "flex";
     },

+ 7 - 7
views/dashboardPage/components/recipeDetails.ejs

@@ -7,14 +7,14 @@
             </svg>
         </button>
 
-        <% if(merchant.pos === "none"){ %>
-            <button class="iconButton" onclick="recipeDetailsComp.edit()">
-                <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                    <path d="M12 20h9"></path>
-                    <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
-                </svg>
-            </button>
+        <button class="iconButton" onclick="recipeDetailsComp.edit()">
+            <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+                <path d="M12 20h9"></path>
+                <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
+            </svg>
+        </button>
 
+        <% if(merchant.pos === "none"){ %>
             <button class="iconButton" onclick="recipeDetailsComp.remove()">
                 <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                     <polyline points="3 6 5 6 21 6"></polyline>