{% set batch_actions = page.get_batch_actions(request) %}

<form class="w-full md:w-auto"
      :action="action"
      :hx-get="action"
      hx-method="get"
      hx-target="#modals"
      @submit="$nextTick(() => action = '')"
      x-show="objectIds.length"
      x-data="{action: '', objectIds: []}"
      method="get"
>
    {% if batch_actions %}
        <x-batch-selected-rows
            @change="objectIds.length=0; objectIds=objectIds.concat($event.detail)"></x-batch-selected-rows>
        <div class="btn-group">
            <select data-test="batch-action-selector"
                    name="_batch_action"
                    class="w-full md:w-64" x-model="action" :disabled="!objectIds.length">
                <option value="">{{ _('Select action', domain='ohmyadmin') }}</option>
                {% for action in batch_actions %}
                    <option value="{{ action.slug }}">{{ action.label }}</option>
                {% endfor %}
            </select>
            <button class="btn btn-accent" :disabled="action == '' || !objectIds.length">
                {{ tabler_icon('player-play') }}
            </button>
        </div>
    {% endif %}
</form>
