Class: Maquina::Application::Filters

Inherits:
Phlex::HTML
  • Object
show all
Includes:
Maquina::ApplicationView, Phlex::Rails::Helpers::LinkTo, Phlex::Rails::Helpers::TokenList
Defined in:
app/views/maquina/application/filters.rb

Instance Method Summary collapse

Methods included from Maquina::ApplicationView

#attribute_human_name, #button_to, #image_tag, #link_to, #model_human_name, #svg_icon

Instance Method Details

#view_templateObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/views/maquina/application/filters.rb', line 10

def view_template
  div(class: "flex flex-1 items-center space-x-2") do
    filters.each_pair do |field, options|
      selected_option = calculate_selected(field, options)
      display_filter(field, selected_option, options)
    end

    active_filters = filters.keys.select { |field| params[field].present? }
    link_to(collection_path(**clear_filters), class: token_list("text-skin-dimmed text-xs border border-gray-200 inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-white hover:text-skin-base py-2 h-9 px-2 lg:px-3", hidden: active_filters.empty?)) do
      span { t("filters.clear") }
      svg(width: "15", height: "15", viewbox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "ml-2 h-4 w-4") do |s|
        s.path(d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
          fill: "currentColor",
          fill_rule: "evenodd",
          clip_rule: "evenodd")
      end
    end
  end
end