From 2186330ae8d9e31f5b91749372651951498ed3c9 Mon Sep 17 00:00:00 2001 From: Jadowyne Ulve Date: Sat, 9 Aug 2025 17:26:24 -0500 Subject: [PATCH] Implemented dark mode in recipes module --- .../__pycache__/recipes_api.cpython-313.pyc | Bin 13769 -> 13806 bytes application/recipes/recipes_api.py | 1 + application/recipes/sql/getRecipeByID.sql | 2 +- .../recipes/static/js/recipeEditHandler.js | 20 ------------------ .../recipes/static/js/recipeViewHandler.js | 19 ----------------- .../recipes/static/js/recipesListHandler.js | 19 ----------------- .../recipes/templates/recipe_edit.html | 11 +++++++--- .../recipes/templates/recipe_view.html | 11 +++++++--- .../recipes/templates/recipes_index.html | 8 ++++++- logs/database.log | 5 ++++- static/css/dark-mode.css | 10 +++++++++ 11 files changed, 39 insertions(+), 67 deletions(-) diff --git a/application/recipes/__pycache__/recipes_api.cpython-313.pyc b/application/recipes/__pycache__/recipes_api.cpython-313.pyc index 152fcf9ecba8dc0d482aa252da24be9110b66871..932a1a2e96e299ad8a487c0505db8215701bde71 100644 GIT binary patch delta 278 zcmX?^{VtpLGcPX}0}z;>oSxylkvEi`@yO&nR@KP|WH}~JV3!byW(CQDKr|bKW?+~+ zk6oOf6UGZ>4h70hKEkeyB*qRF`^G+r4Wz4xb#fnvu}Tt<*}(9Hje%G8I*;ll9@Wb{ z>J6@USU5Y>T6}?2k9v#W=6f8;%#6yLop{)o84Wjk@+Yt`+H77WJc)(TZ?mn03^QZw z<|t`?R>sWDSqiUM*z16177H*=PLMX(+^rhQ%s6fHLygOfj0-kz)!M_vwgM!*Z*sh} qq5dZ)H diff --git a/application/recipes/recipes_api.py b/application/recipes/recipes_api.py index 9fa48ab..6846454 100644 --- a/application/recipes/recipes_api.py +++ b/application/recipes/recipes_api.py @@ -26,6 +26,7 @@ def recipes(): def recipe(id, mode='view'): units = database_recipes.getUnits() print("woot") + print(session) if mode == "edit": return render_template("recipe_edit.html", recipe_id=id, current_site=session['selected_site'], units=units) if mode == "view": diff --git a/application/recipes/sql/getRecipeByID.sql b/application/recipes/sql/getRecipeByID.sql index 88982b8..c7b5669 100644 --- a/application/recipes/sql/getRecipeByID.sql +++ b/application/recipes/sql/getRecipeByID.sql @@ -1,7 +1,7 @@ WITH passed_id AS (SELECT %s AS passed_id), cte_recipe_items AS ( SELECT items.*, - COALESCE(%%site_name%%_items.barcode, items.uuid) AS uuid, + /*COALESCE(%%site_name%%_items.barcode, items.uuid) AS uuid,*/ (SELECT COALESCE(row_to_json(units.*), '{}') FROM units WHERE units.id=%%site_name%%_item_info.uom) AS item_uom, COALESCE(%%site_name%%_items.item_name, items.item_name) AS item_name, COALESCE(%%site_name%%_items.links, items.links) AS links, diff --git a/application/recipes/static/js/recipeEditHandler.js b/application/recipes/static/js/recipeEditHandler.js index 86f5072..32fc161 100644 --- a/application/recipes/static/js/recipeEditHandler.js +++ b/application/recipes/static/js/recipeEditHandler.js @@ -1,23 +1,3 @@ -var mode = false -async function toggleDarkMode() { - let darkMode = document.getElementById("dark-mode"); - darkMode.disabled = !darkMode.disabled; - mode = !mode; - if(mode){ - document.getElementById('modeToggle').innerHTML = "light_mode" - document.getElementById('main_html').classList.add('uk-light') - - } else { - document.getElementById('modeToggle').innerHTML = "dark_mode" - document.getElementById('main_html').classList.remove('uk-light') - } -} - - -if(session.user.flags.darkmode){ - toggleDarkMode() -} - // Beginning of site specific code! var recipe = []; document.addEventListener('DOMContentLoaded', async function() { diff --git a/application/recipes/static/js/recipeViewHandler.js b/application/recipes/static/js/recipeViewHandler.js index 1ac534f..e4165ce 100644 --- a/application/recipes/static/js/recipeViewHandler.js +++ b/application/recipes/static/js/recipeViewHandler.js @@ -1,22 +1,3 @@ -var mode = false -async function toggleDarkMode() { - let darkMode = document.getElementById("dark-mode"); - darkMode.disabled = !darkMode.disabled; - mode = !mode; - if(mode){ - document.getElementById('modeToggle').innerHTML = "light_mode" - document.getElementById('main_html').classList.add('uk-light') - - } else { - document.getElementById('modeToggle').innerHTML = "dark_mode" - document.getElementById('main_html').classList.remove('uk-light') - } -} - -if(session.user.flags.darkmode){ - toggleDarkMode() -} - // Beginning of site specific code! var recipe = []; document.addEventListener('DOMContentLoaded', async function() { diff --git a/application/recipes/static/js/recipesListHandler.js b/application/recipes/static/js/recipesListHandler.js index d5372c7..4bc06a2 100644 --- a/application/recipes/static/js/recipesListHandler.js +++ b/application/recipes/static/js/recipesListHandler.js @@ -1,22 +1,3 @@ -var mode = false -async function toggleDarkMode() { - let darkMode = document.getElementById("dark-mode"); - darkMode.disabled = !darkMode.disabled; - mode = !mode; - if(mode){ - document.getElementById('modeToggle').innerHTML = "light_mode" - document.getElementById('main_html').classList.add('uk-light') - } else { - document.getElementById('modeToggle').innerHTML = "dark_mode" - document.getElementById('main_html').classList.remove('uk-light') - } -} - - -if(session.user.flags.darkmode){ - toggleDarkMode() -} - async function changeSite(site){ console.log(site) const response = await fetch(`/changeSite`, { diff --git a/application/recipes/templates/recipe_edit.html b/application/recipes/templates/recipe_edit.html index c1b1d93..27d19a7 100644 --- a/application/recipes/templates/recipe_edit.html +++ b/application/recipes/templates/recipe_edit.html @@ -16,13 +16,18 @@ - - + {% if session['user']['flags']['darkmode'] %} + + {% endif %} - + {% if session['user']['flags']['darkmode'] %} + + {% else %} + + {% endif %}