<% filter = user_filtering.filter %>

<%= tag.div class: "flex-inline flex-wrap position-relative quick-filter",
      data: {
        controller: "dialog filter multi-selection-combobox",
        action: "keydown.esc->dialog#close click@document->dialog#closeOnClickOutside turbo:morph@window->multi-selection-combobox#refresh dialog:close@document->filter#clearInput",
        filter_show: user_filtering.show_boards?,
        multi_selection_combobox_no_selection_label_value: user_filtering.selected_boards_label } do %>
  <button type="button" class="btn borderless btn--plain events__filter-select" data-action="click->dialog#toggle:stop">
    <span data-multi-selection-combobox-target="label">
    </span>
  </button>

  <template data-multi-selection-combobox-target="hiddenFieldTemplate">
    <%= hidden_field_tag "board_ids[]", nil, data: { filter_settings_target: "field" } %>
  </template>

  <%= filter_dialog "Board…" do %>
    <%= filter_title "Board…" %>
    <%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small font-weight-normal", autofocus: true,
          type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>

    <ul class="popup__list" data-filter-target="list" role="listbox">
      <% user_filtering.boards.each do |board| %>
        <%= tag.li class: "popup__item", data: {
              filter_target: "item", navigable_list_target: "item", multi_selection_combobox_target: "item", multi_selection_combobox_value: board.id, multi_selection_combobox_label: board.name },
              role: "checkbox", aria: { checked: filter.boards.include?(board) } do %>
          <button type="button" class="btn popup__btn" data-action="dialog#close multi-selection-combobox#change filter-settings#change form#submit">
            <span class="overflow-ellipsis flex-item-grow"><%= board.name %></span>
            <%= icon_tag "check", class: "checked flex-item-justify-end" %>
          </button>
        <% end %>
      <% end %>
    </ul>
  <% end %>
<% end %>
