{# Query builder filter. Rules in a group are ANDed; groups are ORed. Buttons re-render the table with a `_qb` action. #} {% from "tungsten/tables/constraint-value.html" import constraint_value with context %} {% macro qb(action) -%} hx-get="{{ ctx.url('_tw', 'table') }}" hx-include="closest form" hx-vals='{{ {"_qb": action} | tojson }}' hx-target="#{{ table.id }}" hx-swap="outerHTML" {%- endmacro %} {% macro picker(label, where, icon_name='plus') %}
{% for c in constraints %} {% endfor %}
{% endmacro %}

{{ builder.get_label() }}

{% for g in groups %} {% if not loop.first %}
{{ __('or') }}
{% endif %}
{% for r in g.rules %} {% if not loop.first %}

{{ __('and') }}

{% endif %}
{{ icon(r.constraint.get_icon(), 'h-4 w-4 shrink-0 text-gray-400') }}{{ r.constraint.get_label() }} {% if not r.complete %}{% endif %}
{{ constraint_value(r) }}
{% endfor %} {{ picker(__('Add rule'), g.index) }}
{% endfor %} {% if groups %}{{ picker(__('Add “or” group'), 'new', 'git-branch-plus') }}{% else %}{{ picker(__('Add rule'), 'new') }}{% endif %}