{# Query builder filter. Rules in a group are ANDed; groups are ORed. Buttons re-render the table with a `_qb` action. #} {% 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 %}
{% set itype = r.constraint.input_type() %} {% if r.needs in ('text', 'number', 'date') %} {% elif r.needs == 'count' %} {% elif r.needs == 'between' %}
{% elif r.needs == 'select' %} {% elif r.needs == 'multi' %}
{% for value, label in r.options %} {% else %}

{{ __('No options') }}

{% endfor %}
{% endif %}
{% endfor %} {{ picker(__('Add rule'), g.index) }}
{% endfor %} {% if groups %}{{ picker(__('Add “or” group'), 'new', 'git-branch-plus') }}{% else %}{{ picker(__('Add rule'), 'new') }}{% endif %}