From d3a9b6dbd5e190dc3fa8d76e8836119a7a89df32 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Fri, 20 Jun 2025 09:10:14 -0500 Subject: [PATCH] Refactor icon rendering; update render_icon macro to accept extra_class parameter and adjust button icons in combobox for better state management --- models/__pycache__/inventory.cpython-313.pyc | Bin 5053 -> 4849 bytes models/inventory.py | 4 +--- static/js/widget.js | 17 +++++++++-------- templates/fragments/_combobox_fragment.html | 2 +- templates/fragments/_icon_fragment.html | 4 ++-- templates/settings.html | 7 ------- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/models/__pycache__/inventory.cpython-313.pyc b/models/__pycache__/inventory.cpython-313.pyc index 8d133d82009ef2a1ac5d49512b211703b51f7375..421da6d44c06d827342a85f4a2cc810e6108d400 100644 GIT binary patch delta 846 zcmdn1{!x|pGcPX}0|Ns?QC4V%-9%nV#w!!mH5er(1{l{f1haeddhr$UdGQzVdkGW? zcnKB>dI=Q?c?lN@dx;c@c!?H?Dlh~y1ao+cd5IT^dr1^Ycu5vXg2gz!rHZ72nS!~z zrM+Z|WE2=A7?c=-xuqC_d17ROtUz|6VpC=azep~fQS7AF^F z7L;V>=M`yzL|F67^HPg$ai*2#_>_5CJk= zld;Hwfq|izk%56hp~z|S8(vjLyU9X)nT)QJYxsQY`9a3=#mAQwo?ujCege0*YFUVcd;$Xy`iLLfy7AbF0I#FEsK%-qx>L6Ddd zNQ}9-q^L**#N`DMsvrXFP*w&8hWa9~OEo}(U>|aTeHfpaQltYC(*+S=AMt=#!XUx` zWGYKietu4o7>I8SB5Xl~DTn|CU6BQd#R4LnL8>_lit-Cmi%KesJV0F0`1oRw^ONHz zALr+l^a81K1rbglLJ~&sZGOw|#l#Jk0SRi#Pj(VA)8;78FUpS3$xkl=rPN!jMfv%; z#YNm8gSm0M7aWw3Fb2Cn7^IV-NE}45`sSyk z<`jW!D?)YFEe@O9{FKt1RJ)=i1_lODd=}eJP862pRlLh0{hT58Iz#MbhSud|GcPX}0|NttlX^hL@rk^WjDIGoYcR@93@{d83TF4__2MhyQ(y>Y2H^mge-9_L3=*@scf)1@pPQ<-FvJM%6ucCR z6v1NL-bzJE!A!wC-pXDoMJfsm5)4WV!Msuo!F(|)L0%IdNVBS?b8GTXVsv3;2`x@7 zn(W9ZqQHHN-6=mmCp9temWW$^QEFy-o_A`cbADcNNl{{EUdiNmMs+WdfTGOY#G*9^QJ^D>k3Q&MknxFnXOhGgcZ-eM_9ttioCy2a_@7~&e@>Fa8Ai`CcP z&oy%MJjN%?i~^gRS<4t1c_#m2(~>L#h0rb5q@u*Ulp;5R0sd*{4Sc*~$ii)g3Lfk2-#mPmP1tppJc|`^w5!U?jywsvwoN1*w zIq`Xkxv52#lecgcGwN*C;MQhR0vS|f0y0t;M1Ty}WGr%JU|=X_WME)WC~}`%%B#xg zFnKm_CZpG6Rz6=XL6EV0@$n^zNja(UiACwf@$p5{Al*VBLI6a7%qfzZT*D_-F9zbP zf%I^sB$lL>Wag$8iGsv5Kw`|rB}GMAATB?M&;}7;H?e|PU^nT3SYW?!fc+AmnNnl~ z5;F!7V7K#vSmGeU3}h%vQht6;kqn4$nFu1CK!g>D0EJSKEr`VeB0NCKISPvM3sQ?p zDvNwUT+#UW;*!LY%;fmQl9Hm#q|%a9kPrPq>b*dOJBW~n5dxdb_`R68!7?C0P4&sA z1kt(>eQq+DMl z0x}mIKHz`@dFqxVLXlodW@1iia!IjXZgFv8PLTvixg^LWJ|so?MY%;%AQ^D9fCC}| zq=unL7DTc7=BK3Q6oFh@gzBw;TO2mI`6;D2sdhz~3=9mQG*BGEz`*cXtz>F+EIj6qD_84%=0F#A4(+2jjCvMivm0RTJt1Uvu$ diff --git a/models/inventory.py b/models/inventory.py index 38a64e4..febd8e6 100644 --- a/models/inventory.py +++ b/models/inventory.py @@ -2,12 +2,10 @@ from typing import Any, List, Optional, TYPE_CHECKING if TYPE_CHECKING: from .brands import Brand from .items import Item - from .users import User from .work_log import WorkLog from .rooms import Room -from sqlalchemy import Boolean, ForeignKeyConstraint, ForeignKey, Identity, Index, Integer, PrimaryKeyConstraint, String, Unicode, DateTime, text -from sqlalchemy.dialects.mssql import DATETIME2, MONEY +from sqlalchemy import Boolean, ForeignKey, Identity, Index, Integer, Unicode, DateTime, text from sqlalchemy.orm import Mapped, mapped_column, relationship import datetime diff --git a/static/js/widget.js b/static/js/widget.js index f6e89b4..264272f 100644 --- a/static/js/widget.js +++ b/static/js/widget.js @@ -15,7 +15,15 @@ const ComboBoxWidget = (() => { } function updateAddButtonIcon() { - addBtn.innerHTML = currentlyEditing ? icons.edit : icons.add; + const iconEl = addBtn.querySelector('.icon-state'); + + const iconClass = currentlyEditing ? 'bi-pencil' : 'bi-plus-lg'; + iconEl.classList.forEach(cls => { + if (cls.startsWith('bi-') && cls !== 'icon-state') { + iconEl.classList.remove(cls); + } + }); + iconEl.classList.add(iconClass); } input.addEventListener('input', () => { @@ -96,13 +104,6 @@ const ComboBoxWidget = (() => { } } - function sortOptions(selectElement) { - const sorted = Array.from(selectElement.options) - .sort((a, b) => a.text.localeCompare(b.text)); - selectElement.innerHTML = ''; - sorted.forEach(option => selectElement.appendChild(option)); - } - return { initComboBox }; diff --git a/templates/fragments/_combobox_fragment.html b/templates/fragments/_combobox_fragment.html index 75684c2..3ffc0d9 100644 --- a/templates/fragments/_combobox_fragment.html +++ b/templates/fragments/_combobox_fragment.html @@ -8,7 +8,7 @@
{% endblock %} - -{% block script %} - const icons = { - add: `{{ icons.render_icon('plus', 16)|safe }}`, - edit: `{{ icons.render_icon('pencil', 16)|safe }}`, - }; -{% endblock %} \ No newline at end of file