Class: IronAdmin::Filters::BarComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/filters/bar_component.rb

Overview

Renders the filter bar containing search and filter controls.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form_url:, scope: nil, query: nil, active_count: 0) ⇒ BarComponent

Returns a new instance of BarComponent.

Parameters:

  • form_url (String)

    Form submission URL

  • scope (String, nil) (defaults to: nil)

    Current scope

  • query (String, nil) (defaults to: nil)

    Current query

  • active_count (Integer) (defaults to: 0)

    Active filter count



26
27
28
29
30
31
# File 'app/components/iron_admin/filters/bar_component.rb', line 26

def initialize(form_url:, scope: nil, query: nil, active_count: 0)
  @form_url = form_url
  @scope = scope
  @query = query
  @active_count = active_count
end

Instance Attribute Details

#active_countInteger (readonly)

Returns Number of active filters.

Returns:

  • (Integer)

    Number of active filters



20
21
22
# File 'app/components/iron_admin/filters/bar_component.rb', line 20

def active_count
  @active_count
end

#form_urlString (readonly)

Returns Form submission URL.

Returns:

  • (String)

    Form submission URL



11
12
13
# File 'app/components/iron_admin/filters/bar_component.rb', line 11

def form_url
  @form_url
end

#queryString? (readonly)

Returns Current search query.

Returns:

  • (String, nil)

    Current search query



17
18
19
# File 'app/components/iron_admin/filters/bar_component.rb', line 17

def query
  @query
end

#scopeString? (readonly)

Returns Current scope.

Returns:

  • (String, nil)

    Current scope



14
15
16
# File 'app/components/iron_admin/filters/bar_component.rb', line 14

def scope
  @scope
end

Instance Method Details

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CSS classes for filter dropdown panel.

Returns:

  • (String)

    CSS classes for filter dropdown panel



55
56
57
58
# File 'app/components/iron_admin/filters/bar_component.rb', line 55

def dropdown_classes
  "absolute right-0 top-full mt-2 w-72 border z-20 #{theme.border_radius} " \
    "#{theme.card_border} #{theme.card_bg} #{theme.card_shadow}-lg"
end

#has_active_filters?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Whether any filters are active.

Returns:

  • (Boolean)

    Whether any filters are active



41
42
43
# File 'app/components/iron_admin/filters/bar_component.rb', line 41

def has_active_filters?
  active_count.positive?
end

#themeIronAdmin::Configuration::Theme

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Theme configuration.

Returns:



35
36
37
# File 'app/components/iron_admin/filters/bar_component.rb', line 35

def theme
  IronAdmin.configuration.theme
end

#trigger_classesString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CSS classes for filter dropdown trigger button.

Returns:

  • (String)

    CSS classes for filter dropdown trigger button



47
48
49
50
51
# File 'app/components/iron_admin/filters/bar_component.rb', line 47

def trigger_classes
  "inline-flex items-center gap-2 px-4 cursor-pointer select-none text-sm font-medium " \
    "#{theme.border_radius} border shadow-sm transition duration-150 " \
    "#{theme.label_text} #{theme.card_border} #{theme.card_bg} py-2.5 hover:bg-gray-50"
end