From 462b86c5832e7e2e93371b4dc408767c1598f908 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Wed, 13 Aug 2025 11:58:23 -0500 Subject: [PATCH] Minor fixes to thingie. --- .../templates/fragments/_combobox_fragment.html | 6 ++++-- inventory/templates/fragments/_option_fragment.html | 13 +++++++------ inventory/templates/playground.html | 2 +- inventory/ui/blueprint.py | 5 +++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/inventory/templates/fragments/_combobox_fragment.html b/inventory/templates/fragments/_combobox_fragment.html index 5bf940c..5c2e7db 100644 --- a/inventory/templates/fragments/_combobox_fragment.html +++ b/inventory/templates/fragments/_combobox_fragment.html @@ -77,8 +77,10 @@ create_url = none, edit_url = none, delete_url = none, refresh_url = none {% if refresh_url %} -
+ {% set url = refresh_url ~ ('&' if '?' in refresh_url else '?') ~ 'view=option' %} +
+
{% endif %} {% endmacro %} \ No newline at end of file diff --git a/inventory/templates/fragments/_option_fragment.html b/inventory/templates/fragments/_option_fragment.html index 600edc5..bc25b57 100644 --- a/inventory/templates/fragments/_option_fragment.html +++ b/inventory/templates/fragments/_option_fragment.html @@ -1,6 +1,7 @@ -{% for option in options %} - -{% endfor %} \ No newline at end of file +{# templates/fragments/_option_fragment.html #} +{% for it in options %} + +{% endfor %} diff --git a/inventory/templates/playground.html b/inventory/templates/playground.html index af45727..d0b8764 100644 --- a/inventory/templates/playground.html +++ b/inventory/templates/playground.html @@ -4,6 +4,6 @@ {{ combos.dynamic_combobox( id='play', label='Breakfast!', - refresh_url=url_for('ui.list_items', model_name='brand', view='option') + refresh_url=url_for('ui.list_items', model_name='brand') ) }} {% endblock %} \ No newline at end of file diff --git a/inventory/ui/blueprint.py b/inventory/ui/blueprint.py index adea7e8..51781c0 100644 --- a/inventory/ui/blueprint.py +++ b/inventory/ui/blueprint.py @@ -53,6 +53,7 @@ def list_items(model_name): items = [call(Model, 'ui_serialize', r, view=view) or default_serialize(Model, r, view=view) for r in rows] - if view=="option": - return render_template('fragments/_option_fragment.html', options=items) + want_html = (request.args.get("view") == "option") or ("HX-Request" in request.headers) + if want_html: + return render_template("fragments/_option_fragment.html", options=items) return jsonify({"items": items})