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>
|
||||
|
||||
{% if refresh_url %}
|
||||
<div id="{{ id }}-htmx-refresh" class="d-none" hx-get="{{ refresh_url }}"
|
||||
hx-trigger="load, combobox:refresh from:#{{ id }}-container" hx-target="#{{ id }}-list" hx-swap="innerHTML"></div>
|
||||
{% set url = refresh_url ~ ('&' if '?' in refresh_url else '?') ~ 'view=option' %}
|
||||
<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 %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
{% for option in options %}
|
||||
<option value="{{ option.id }}"
|
||||
{% for k,v in option.items() if k not in ('id','name') and v is not none %}
|
||||
data-{{ k }}="{{ v }}"
|
||||
{% endfor %}>{{ option.name }}</option>
|
||||
{% endfor %}
|
||||
{# templates/fragments/_option_fragment.html #}
|
||||
{% for it in options %}
|
||||
<option value="{{ it.id }}"
|
||||
{% for k, v in it.items() if k not in ('id','name') and v is not none %}
|
||||
data-{{ k|e }}="{{ v|e }}"
|
||||
{% endfor %}>{{ it.name }}</option>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -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 %}
|
||||
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue