From b182e30c437352cb471bba4b1c49a191e69d9554 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Fri, 20 Jun 2025 10:02:40 -0500 Subject: [PATCH] Refactor combo box integration; streamline onAdd, onRemove, and onEdit parameters in render_combobox macro for improved functionality and readability --- static/js/widget.js | 2 - templates/fragments/_combobox_fragment.html | 6 +- templates/settings.html | 89 ++++++++++++++++----- 3 files changed, 71 insertions(+), 26 deletions(-) diff --git a/static/js/widget.js b/static/js/widget.js index 264272f..12d3527 100644 --- a/static/js/widget.js +++ b/static/js/widget.js @@ -1,6 +1,4 @@ const ComboBoxWidget = (() => { - let tempIdCounter = -1; - function initComboBox(ns, config = {}) { const input = document.querySelector(`#${ns}-input`); const list = document.querySelector(`#${ns}-list`); diff --git a/templates/fragments/_combobox_fragment.html b/templates/fragments/_combobox_fragment.html index 3ffc0d9..a65f943 100644 --- a/templates/fragments/_combobox_fragment.html +++ b/templates/fragments/_combobox_fragment.html @@ -24,9 +24,9 @@ diff --git a/templates/settings.html b/templates/settings.html index 66b7703..9e91bde 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -19,18 +19,18 @@
{{ combos.render_combobox( - id='brand', - options=brands, - label='Brands', - placeholder='Add a new brand' + id='brand', + options=brands, + label='Brands', + placeholder='Add a new brand' ) }}
{{ combos.render_combobox( - id='type', - options=types, - label='Inventory Types', - placeholder='Add a new type' + id='type', + options=types, + label='Inventory Types', + placeholder='Add a new type' ) }}
@@ -42,33 +42,80 @@
{{ combos.render_combobox( - id='section', - options=sections, - label='Sections', - placeholder='Add a new section' + id='section', + options=sections, + label='Sections', + placeholder='Add a new section' ) }}
{{ combos.render_combobox( - id='function', - options=functions, - label='Functions', - placeholder='Add a new function' + id='function', + options=functions, + label='Functions', + placeholder='Add a new function' ) }}
+ {% set room_editor %} + const roomEditor = new bootstrap.Modal(document.getElementById('roomEditor')); + roomEditor.show(); + {% endset %}
{{ combos.render_combobox( - id='room', - options=rooms, - label='Rooms', - placeholder='Add a new room' + id='room', + options=rooms, + label='Rooms', + placeholder='Add a new room', + onAdd=room_editor ) }}
+ -{% endblock %} +{% endblock %} \ No newline at end of file