From 76c3f33b55d372b4c670a471fa55dcb4648523e3 Mon Sep 17 00:00:00 2001 From: Jadowyne Ulve Date: Thu, 24 Oct 2024 19:30:50 -0500 Subject: [PATCH] 10-24-2024 --- __pycache__/api.cpython-312.pyc | Bin 34075 -> 34087 bytes __pycache__/config.cpython-312.pyc | Bin 2675 -> 2687 bytes __pycache__/main.cpython-312.pyc | Bin 23995 -> 24007 bytes templates/items/item.html | 69 ++++++++++++++++++++--------- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/__pycache__/api.cpython-312.pyc b/__pycache__/api.cpython-312.pyc index 5d8f3cf4d8957522ff8bb0d103c7116e29dc52e0..ad9adda5547c69e3b78ca7fb549ee19e81cd627d 100644 GIT binary patch delta 84 zcmbQ;#k9POiTgA!FBbz4*Ila-i~UmoL*=)yT$^igqWE|xH delta 70 zcmew_@>zuYG%qg~0}x2rOKjw3XVS5Ewu%WYPAw{q$x2MgFOTuhOLZyAEK7}X$xklL WP0cGQj>)Y|&QD1NQk%V)OgRAT*cS5u diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc index e3334f3cbd35a8544963241d1989c000a1fac03f..899b7b5a424ec737fbcd89dcf764e08a8c0c6bcf 100644 GIT binary patch delta 84 zcmdnJoALN=M()$Ryj%=GU>YT`k^3y8g{QMsOlWaxQE^OGVoH8_j7xrUX>Mv>NpVba geoAUgL4I*bdQoa|VU9vUWl2VU9!z923)A*!0KeNFod5s; delta 72 zcmX@Un{oGUM()$Ryj%=GAZ0JHk^3y8j;*s*OlWaxQE^OGVoH8_jDKFLOHpQ7YK%*M Za%paAUP*CGZe? +
+ +
@@ -150,7 +153,7 @@
-
+
@@ -209,7 +212,7 @@ let logistics_info = {}; let food_groups = []; let ingrediants = []; - + let tags = []; document.addEventListener('DOMContentLoaded', async function() { document.getElementById("title").innerHTML = String(item[2]) @@ -223,6 +226,8 @@ var elems = document.querySelectorAll('.modal'); var instances = M.Modal.init(elems, {}); + await propagateInfo() + var elem = document.getElementById('food_groups_container'); M.Chips.init(elem, { @@ -231,17 +236,26 @@ onChipDelete: deleteFoodGroup, onChipAdd: addFoodGroup, }); - var elem = document.getElementById('ingrediants_container'); M.Chips.init(elem, { placeholder: 'Add Ingrediant...', secondaryPlaceholder: 'Add Ingrediant...', onChipDelete: deleteIngrediant, + onChipAdd: addIngrediant, + }); + + var elem = document.getElementById('tags_container'); + M.Chips.init(elem, { + placeholder: 'Add Tag...', + secondaryPlaceholder: 'Add Tag...', + onChipDelete: deleteTag, + onChipAdd: addTag, }); await propagateInfo() - refreshFoodGroups() - refreshIngrediants() + //refreshFoodGroups() + refreshChips('food_groups_container', food_groups, item[33]) + refreshChips('ingrediants_container', ingrediants, item[34]) populateReferences(item[23], 'shopping_list') populateReferences(item[24], 'recipe') populateReferences(item[25], 'group') @@ -256,17 +270,20 @@ itemType.value = item[11]; await propagateLinks() - food_groups = item[33]; - ingrediants = item[34]; - } - - function refreshFoodGroups(){ - let instance = M.Chips.getInstance(document.getElementById('food_groups_container')); - for (let i=0; i < food_groups.length; i++){ - instance.addChip({tag: String(food_groups[i])}); - ;} + //food_groups = item[33]; + //ingrediants = item[34]; + tags = item[5]; }; + function refreshChips(elem_id, chips_array, initial_chips){ + let tags_array = []; + let instance = M.Chips.getInstance(document.getElementById(elem_id)); + for (let i=0; i < initial_chips.length; i++){ + instance.addChip({tag: String(initial_chips[i])}); + } + }; + + function addFoodGroup(e, chip){ chipText = chip.textContent.replace('close', '').trim() console.log(chipText) @@ -274,6 +291,20 @@ console.log(food_groups) } + function addIngrediant(e, chip){ + chipText = chip.textContent.replace('close', '').trim() + console.log(chipText) + ingrediants.push(chipText) + console.log(ingrediants) + } + + function addTag(e, chip){ + chipText = chip.textContent.replace('close', '').trim() + console.log(chipText) + tags.push(chipText) + console.log(tags) + } + function deleteFoodGroup(e, chip){ chipText = chip.textContent.replace('close', '').trim() food_groups = food_groups.filter(chip => chip !== chipText); @@ -284,12 +315,10 @@ ingrediants = ingrediants.filter(chip => chip !== chipText); } - function refreshIngrediants(){ - let instance = M.Chips.getInstance(document.getElementById('ingrediants_container')); - for (let i=0; i < ingrediants.length; i++){ - instance.addChip({tag: String(ingrediants[i])}); - ;} - }; + function deleteTag(e, chip){ + chipText = chip.textContent.replace('close', '').trim() + tags = tags.filter(chip => chip !== chipText); + } async function propagateLinks(){ var element = document.getElementById("weblinks");