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.



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

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



26
27
28
# File 'app/components/solidus_admin/ui/table/component.rb', line 26

def filters
  @filters
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



26
27
28
# File 'app/components/solidus_admin/ui/table/component.rb', line 26

def name
  @name
end

#scopesObject

Returns the value of attribute scopes

Returns:

  • (Object)

    the current value of scopes



26
27
28
# File 'app/components/solidus_admin/ui/table/component.rb', line 26

def scopes
  @scopes
end

#searchbar_keyObject

Returns the value of attribute searchbar_key

Returns:

  • (Object)

    the current value of searchbar_key



26
27
28
# File 'app/components/solidus_admin/ui/table/component.rb', line 26

def searchbar_key
  @searchbar_key
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



26
27
28
# File 'app/components/solidus_admin/ui/table/component.rb', line 26

def url
  @url
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



26
27
28
# File 'app/components/solidus_admin/ui/table/component.rb', line 26

def value
  @value
end

Instance Method Details

#current_scopeObject



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

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

#default_scopeObject



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

def default_scope
  scopes.find(&:default)
end

#on_default_scope?Boolean

Returns:

  • (Boolean)


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

def on_default_scope?
  current_scope == default_scope
end

#scope_param_nameObject



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

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

#searchbar_param_nameObject



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

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