Class: Avo::Index::ResourceTableComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ApplicationHelper
Defined in:
app/components/avo/index/resource_table_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ApplicationHelper

#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #mount_path, #render_license_warning, #render_license_warnings, #root_path_without_url, #svg, #white_panel_classes

Constructor Details

#initialize(resources: nil, resource: nil, reflection: nil, parent_model: nil, parent_resource: nil, pagy: nil, query: nil) ⇒ ResourceTableComponent

Returns a new instance of ResourceTableComponent.



7
8
9
10
11
12
13
14
15
# File 'app/components/avo/index/resource_table_component.rb', line 7

def initialize(resources: nil, resource: nil, reflection: nil, parent_model: nil, parent_resource: nil, pagy: nil, query: nil)
  @resources = resources
  @resource = resource
  @reflection = reflection
  @parent_model = parent_model
  @parent_resource = parent_resource
  @pagy = pagy
  @query = query
end

Instance Attribute Details

#pagyObject (readonly)

Returns the value of attribute pagy.



5
6
7
# File 'app/components/avo/index/resource_table_component.rb', line 5

def pagy
  @pagy
end

#queryObject (readonly)

Returns the value of attribute query.



5
6
7
# File 'app/components/avo/index/resource_table_component.rb', line 5

def query
  @query
end

Instance Method Details

#encrypted_queryObject



17
18
19
20
21
22
23
24
# File 'app/components/avo/index/resource_table_component.rb', line 17

def encrypted_query
  return :select_all_disabled if query.nil? || !query.respond_to?(:all) || !query.all.respond_to?(:to_sql)

  Avo::Services::EncryptionService.encrypt(
    message: query.all.to_sql,
    purpose: :select_all
  )
end