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

Remove old files for editing recipes.

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

+ 0 - 28
views/dashboardPage/css/sidebars/editRecipe2.css

@@ -1,28 +0,0 @@
-#editRecipe{
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-    width: 100%;
-}
-
-    #editRecipeIngList{
-        width: 100%;
-        max-height: 75%;
-        overflow-y: auto;
-    }
-
-        .editRecipeIng{
-            background: rgb(0, 27, 45);
-            color: white;
-            width: 90%;
-            border-radius: 5px;
-            text-align: center;
-            padding: 5px;
-            margin: 5px auto;
-            position: relative;
-        }
-
-            .editRecipeIng button{
-                position: absolute;
-                right: 5px;
-            }

+ 0 - 63
views/dashboardPage/ejs/sidebars/editRecipe2.ejs

@@ -1,63 +0,0 @@
-<div id="editRecipe">
-    <div class="sidebarIconButtons">
-        <button class="iconButton tooltipContainer" onclick="controller.closeSidebar()">
-            <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                <line x1="5" y1="12" x2="19" y2="12"></line>
-                <polyline points="12 5 19 12 12 19"></polyline>
-            </svg>
-            <span class="tooltip">CLOSE</span>
-        </button>
-    </div>
-
-    <label>NAME:
-        <input id="editRecipeName" type="text">
-    </label>
-
-    <h1 id="editRecipeNoName"></h1>
-    
-    <label style="display:none">CATEGORY:
-        <input id="editRecipeCategory" type="text">
-    </label>
-
-    <h3>INGREDIENTS</h3>
-
-    <div id="editRecipeIngList"></div>
-
-    <button id="addRecIng" class="iconButton">
-        <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-            <circle cx="12" cy="12" r="10"></circle>
-            <line x1="12" y1="8" x2="12" y2="16"></line>
-            <line x1="8" y1="12" x2="16" y2="12"></line>
-        </svg>
-    </button>
-
-    <div class="lineBorder"></div>
-
-    <h3>PRICE</h3>
-
-    <input id="editRecipePrice" type="number" min="0" step="0.01">
-
-    <div class="lineBorder"></div>
-
-    <div class="buttonBox">
-        <button id="editRecipeSubmit" class="sidebarButton">UPDATE</button>
-        <button id="editRecipeCancel" class="sidebarButton">CANCEL</button>
-    </div>
-
-    <template id="editRecipeIng">
-        <div class="editRecipeIng">
-            <button class="iconButton">
-                <svg width="20" height="20" 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>
-                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
-                </svg>
-            </button>
-
-            <p></p>
-
-            <select></select>
-
-            <input type="number" min="0" step="0.01">
-        </div>
-    </template>
-</div>

+ 0 - 136
views/dashboardPage/js/sidebars/editRecipe2.js

@@ -1,136 +0,0 @@
-let editRecipe = {
-    display: function(recipe){
-        document.getElementById("sidebarDiv").classList.add("sidebarWide");
-        let nameInput = document.getElementById("editRecipeName");
-        if(merchant.pos === "none"){
-            nameInput.value = recipe.name;
-            let categoryInput = document.getElementById("editRecipeCategory");
-            categoryInput.value = recipe.category;
-            categoryInput.parentElement.style.display = "block";
-        }else{
-            document.getElementById("editRecipeNoName").innerText = recipe.name;
-            nameInput.parentNode.style.display = "none";
-        }
-
-        //Populate ingredients
-        let ingredientList = document.getElementById("editRecipeIngList");
-
-        while(ingredientList.children.length > 0){
-            ingredientList.removeChild(ingredientList.firstChild);
-        }
-
-        let template = document.getElementById("editRecipeIng").content.children[0];
-        for(let i = 0; i < recipe.ingredients.length; i++){
-            let ingredientDiv = template.cloneNode(true);
-            ingredientDiv.children[0].onclick = ()=>{ingredientDiv.parentNode.removeChild(ingredientDiv)};
-            ingredientDiv.children[1].innerText = recipe.ingredients[i].ingredient.getNameAndUnit();
-            ingredientDiv.children[2].style.display = "none";
-            ingredientDiv.children[3].value = recipe.ingredients[i].quantity;
-            ingredientDiv.ingredient = recipe.ingredients[i];
-            
-            ingredientList.appendChild(ingredientDiv);
-        }
-
-        document.getElementById("addRecIng").onclick = ()=>{this.newIngredient()};
-        document.getElementById("editRecipePrice").value = recipe.price;
-        document.getElementById("editRecipeSubmit").onclick = ()=>{this.submit(recipe)};
-        document.getElementById("editRecipeCancel").onclick = ()=>{controller.openSidebar("recipeDetails", recipe)};
-    },
-
-    newIngredient: function(){
-        let ingredientList = document.getElementById("editRecipeIngList");
-
-        let ingredientDiv = document.getElementById("editRecipeIng").content.children[0].cloneNode(true);
-        ingredientDiv.children[0].onclick = ()=>{ingredientDiv.parentNode.removeChild(ingredientDiv)};
-        ingredientDiv.children[1].style.display = "none";
-        ingredientDiv.children[3].value = "0.00";
-
-        //Populate selector
-        let categories = merchant.categorizeIngredients();
-        for(let i = 0; i < categories.length; i++){
-            let group = document.createElement("optgroup");
-            group.label = categories[i].name;
-
-            for(let j = 0; j < categories[i].ingredients.length; j++){
-                let option = document.createElement("option");
-                option.innerText = categories[i].ingredients[j].ingredient.getNameAndUnit();
-                option.ingredient = categories[i].ingredients[j];
-                group.appendChild(option);
-            }
-            
-            ingredientDiv.children[2].appendChild(group);
-        }
-
-        ingredientList.appendChild(ingredientDiv);
-    },
-
-    submit: function(recipe){
-        let data = {
-            id: recipe.id,
-            name: recipe.name,
-            price: document.getElementById("editRecipePrice").value * 100,
-            category: document.getElementById("editRecipeCategory").value,
-            ingredients: []
-        }
-
-        if(merchant.pos === "none"){
-            data.name = document.getElementById("editRecipeName").value;
-        }
-
-        let ingredients = document.getElementById("editRecipeIngList").children;
-        for(let i = 0; i < ingredients.length; i++){
-            const quantity = parseFloat(ingredients[i].children[3].value);
-            let newIngredient = {};
-            let ingredient = {};
-
-            if(ingredients[i].children[1].style.display === "none"){
-                let selector = ingredients[i].children[2];
-                ingredient = selector.options[selector.selectedIndex].ingredient;
-
-                newIngredient = {
-                    ingredient: ingredient.ingredient.id,
-                    quantity: controller.baseUnit(quantity, ingredient.ingredient.unit)
-                };
-            }else{
-                ingredient = ingredients[i].ingredient;
-
-                newIngredient = {
-                    ingredient: ingredient.ingredient.id,
-                    quantity: controller.baseUnit(quantity, ingredient.ingredient.unit)
-                };
-            }
-
-            data.ingredients.push(newIngredient);
-        }
-
-        let loader = document.getElementById("loaderContainer");
-        loader.style.display = "flex";
-
-        fetch("/recipe/update", {
-            method: "put",
-            headers: {
-                "Content-Type": "application/json;charset=utf-8"
-            },
-            body: JSON.stringify(data)
-        })
-            .then(response => response.json())
-            .then((response)=>{
-                if(typeof(response) === "string"){
-                    controller.createBanner(response, "error");
-                }else{
-                    merchant.updateRecipe(recipe, response);
-                    state.updateRecipes();
-                    controller.openStrand("recipeBook");
-                    controller.createBanner("RECIPE UPDATED", "success");
-                }
-            })
-            .catch((err)=>{
-                controller.createBanner("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE", "error");
-            })
-            .finally(()=>{
-                loader.style.display = "none";
-            });
-    }
-}
-
-module.exports = editRecipe;