Minor fixes to thingie.
This commit is contained in:
parent
dfc37bf8b8
commit
462b86c583
4 changed files with 15 additions and 11 deletions
|
|
@ -77,8 +77,10 @@ create_url = none, edit_url = none, delete_url = none, refresh_url = none
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
{% if refresh_url %}
|
{% if refresh_url %}
|
||||||
<div id="{{ id }}-htmx-refresh" class="d-none" hx-get="{{ refresh_url }}"
|
{% set url = refresh_url ~ ('&' if '?' in refresh_url else '?') ~ 'view=option' %}
|
||||||
hx-trigger="load, combobox:refresh from:#{{ id }}-container" hx-target="#{{ id }}-list" hx-swap="innerHTML"></div>
|
<div id="{{ id }}-htmx-refresh" class="d-none" hx-get="{{ url }}"
|
||||||
|
hx-trigger="revealed, combobox:refresh from:#{{ id }}-container" hx-target="#{{ id }}-list" hx-swap="innerHTML">
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{% for option in options %}
|
{# templates/fragments/_option_fragment.html #}
|
||||||
<option value="{{ option.id }}"
|
{% for it in options %}
|
||||||
{% for k,v in option.items() if k not in ('id','name') and v is not none %}
|
<option value="{{ it.id }}"
|
||||||
data-{{ k }}="{{ v }}"
|
{% for k, v in it.items() if k not in ('id','name') and v is not none %}
|
||||||
{% endfor %}>{{ option.name }}</option>
|
data-{{ k|e }}="{{ v|e }}"
|
||||||
{% endfor %}
|
{% endfor %}>{{ it.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,6 @@
|
||||||
{{ combos.dynamic_combobox(
|
{{ combos.dynamic_combobox(
|
||||||
id='play',
|
id='play',
|
||||||
label='Breakfast!',
|
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 %}
|
{% endblock %}
|
||||||
|
|
@ -53,6 +53,7 @@ def list_items(model_name):
|
||||||
items = [call(Model, 'ui_serialize', r, view=view) or default_serialize(Model, r, view=view)
|
items = [call(Model, 'ui_serialize', r, view=view) or default_serialize(Model, r, view=view)
|
||||||
for r in rows]
|
for r in rows]
|
||||||
|
|
||||||
if view=="option":
|
want_html = (request.args.get("view") == "option") or ("HX-Request" in request.headers)
|
||||||
return render_template('fragments/_option_fragment.html', options=items)
|
if want_html:
|
||||||
|
return render_template("fragments/_option_fragment.html", options=items)
|
||||||
return jsonify({"items": items})
|
return jsonify({"items": items})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue