Sha256: 990943bae0bf724dcf8a29a19628ef4769d54258702f14198d81349d895aa1ee

Contents?: true

Size: 1 KB

Versions: 14

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

class Avo::Index::ResourceTableComponent < ViewComponent::Base
  include Avo::ApplicationHelper
  attr_reader :pagy, :query

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

  def encrypted_query
    # TODO: move this to the resource where we can apply the adapter pattern
    serialized_query = if query.instance_of?(Ransack::Search)
      query.context.object.to_sql
    else
      return :select_all_disabled if query.nil? || !query.respond_to?(:all) || !query.all.respond_to?(:to_sql)

      query.all.to_sql
    end

    return if serialized_query.nil?

    Avo::Services::EncryptionService.encrypt(
      message: serialized_query,
      purpose: :select_all
    )
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
avo-3.0.0.pre14 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre13 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre12 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre10 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre11 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre8 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre9 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre7 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre5 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre6 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre4 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre3 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre2 app/components/avo/index/resource_table_component.rb
avo-3.0.0.pre1 app/components/avo/index/resource_table_component.rb