From 4b9483f333a852bb389cfbdcdc3276f7726254d8 Mon Sep 17 00:00:00 2001 From: ydb5755 Date: Mon, 7 Oct 2024 15:25:59 +0300 Subject: [PATCH] separating html into base and unique url files --- app/static/budget_categories.js | 14 ++++++++++++++ app/static/{index.js => homepage.js} | 11 ----------- app/templates/base.html | 1 - app/templates/budget_categories.html | 1 + app/templates/{index.html => homepage.html} | 3 ++- 5 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 app/static/budget_categories.js rename app/static/{index.js => homepage.js} (76%) rename app/templates/{index.html => homepage.html} (96%) diff --git a/app/static/budget_categories.js b/app/static/budget_categories.js new file mode 100644 index 0000000..7ce2bbd --- /dev/null +++ b/app/static/budget_categories.js @@ -0,0 +1,14 @@ +const delButtons = document.getElementsByClassName('del-button'); + +async function deleteCategory(id){ + var result = await fetch(`/delete_budget_category/${id}`, {method:'POST'}); + var data = await result.json(); + document.getElementById(`${id}-row`).remove(); +} +document.addEventListener("DOMContentLoaded", (event) => { + for(let i = 0; i < delButtons.length; i++){ + delButtons[i].addEventListener('click', e => { + deleteCategory(parseInt(e.target.id)) + }) + } + }); \ No newline at end of file diff --git a/app/static/index.js b/app/static/homepage.js similarity index 76% rename from app/static/index.js rename to app/static/homepage.js index e259939..ce3e8b0 100644 --- a/app/static/index.js +++ b/app/static/homepage.js @@ -1,11 +1,5 @@ -const delButtons = document.getElementsByClassName('del-button'); const reassignButtons = document.getElementsByClassName('reassign-button'); -async function deleteCategory(id){ - var result = await fetch(`/delete_budget_category/${id}`, {method:'POST'}); - var data = await result.json(); - document.getElementById(`${id}-row`).remove(); -} function startEditMode(id){ for(let i = 0; i < reassignButtons.length; i++){ reassignButtons[i].disabled = true; @@ -40,11 +34,6 @@ function startEditMode(id){ } document.addEventListener("DOMContentLoaded", (event) => { - for(let i = 0; i < delButtons.length; i++){ - delButtons[i].addEventListener('click', e => { - deleteCategory(parseInt(e.target.id)) - }) - } for(let i = 0; i < reassignButtons.length; i++){ reassignButtons[i].addEventListener('click', e => { startEditMode(parseInt(e.target.id)) diff --git a/app/templates/base.html b/app/templates/base.html index cbc3fe4..bada81c 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -45,6 +45,5 @@ - \ No newline at end of file diff --git a/app/templates/budget_categories.html b/app/templates/budget_categories.html index 39f4abb..7496da7 100644 --- a/app/templates/budget_categories.html +++ b/app/templates/budget_categories.html @@ -41,4 +41,5 @@ + {% endblock content %} \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/homepage.html similarity index 96% rename from app/templates/index.html rename to app/templates/homepage.html index 192d61e..73a797b 100644 --- a/app/templates/index.html +++ b/app/templates/homepage.html @@ -57,7 +57,7 @@ - {% for li in all_line_items %} + {% for li in last_month_lines %} {{li[0].id}} {{li[0].parent_line_item_id}} @@ -78,4 +78,5 @@ + {% endblock content %}