Class: SolidusAdmin::UI::Table::Component::Search

Inherits:
Struct
  • Object
show all
Defined in:
app/components/solidus_admin/ui/table/component.rb

Overview

rubocop:disable Style/StructInheritance

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Search

Returns a new instance of Search.



31
32
33
34
35
36
# File 'app/components/solidus_admin/ui/table/component.rb', line 31

def initialize(**args)
  super

  self.filters = filters.to_a.map { |filter| Filter.new(**filter) }
  self.scopes = scopes.to_a.map { |scope| Scope.new(**scope) }
end

Instance Attribute Details

#filtersObject

Returns the value of attribute filters

Returns:

  • (Object)

    the current value of filters



30
31
32
# File 'app/components/solidus_admin/ui/table/component.rb', line 30

def filters
  @filters
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



30
31
32
# File 'app/components/solidus_admin/ui/table/component.rb', line 30

def name
  @name
end

#scopesObject

Returns the value of attribute scopes

Returns:

  • (Object)

    the current value of scopes



30
31
32
# File 'app/components/solidus_admin/ui/table/component.rb', line 30

def scopes
  @scopes
end

#searchbar_keyObject

Returns the value of attribute searchbar_key

Returns:

  • (Object)

    the current value of searchbar_key



30
31
32
# File 'app/components/solidus_admin/ui/table/component.rb', line 30

def searchbar_key
  @searchbar_key
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



30
31
32
# File 'app/components/solidus_admin/ui/table/component.rb', line 30

def url
  @url
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



30
31
32
# File 'app/components/solidus_admin/ui/table/component.rb', line 30

def value
  @value
end

Instance Method Details

#current_scopeObject



38
39
40
# File 'app/components/solidus_admin/ui/table/component.rb', line 38

def current_scope
  scopes.find { |scope| scope.name.to_s == value[:scope].presence } || default_scope
end

#default_scopeObject



42
43
44
# File 'app/components/solidus_admin/ui/table/component.rb', line 42

def default_scope
  scopes.find(&:default)
end

#on_default_scope?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/components/solidus_admin/ui/table/component.rb', line 46

def on_default_scope?
  current_scope == default_scope
end

#scope_param_nameObject



50
51
52
# File 'app/components/solidus_admin/ui/table/component.rb', line 50

def scope_param_name
  "#{name}[scope]"
end

#searchbar_param_nameObject



54
55
56
# File 'app/components/solidus_admin/ui/table/component.rb', line 54

def searchbar_param_name
  "#{name}[#{searchbar_key}]"
end