Class: Mensa::FilterPill::Component

Inherits:
ApplicationComponent show all
Defined in:
app/components/mensa/filter_pill/component.rb

Instance Attribute Summary collapse

Attributes inherited from ApplicationComponent

#original_view_context

Instance Method Summary collapse

Methods included from ApplicationHelper

#table

Constructor Details

#initialize(filter:) ⇒ Component

Returns a new instance of Component.



10
11
12
# File 'app/components/mensa/filter_pill/component.rb', line 10

def initialize(filter:)
  @filter = filter
end

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



8
9
10
# File 'app/components/mensa/filter_pill/component.rb', line 8

def filter
  @filter
end

Instance Method Details

#view_filter?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
# File 'app/components/mensa/filter_pill/component.rb', line 14

def view_filter?
  view = filter.table.table_view
  return false unless view

  view_filters = view.config&.dig(:filters) || view.config&.dig("filters") || {}
  col = filter.column.name.to_s
  view_filters.key?(col) || view_filters.key?(col.to_sym)
end