Sha256: c18de295b5e238d86cfaa2e1a0b43692c23748fee23322d9c54a42283d34a8ad

Contents?: true

Size: 1.3 KB

Versions: 31

Compression:

Stored size: 1.3 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
    if Module.const_defined?("Ransack::Search") && query.instance_of?(Ransack::Search)
      @query = @query.result
    end

    Avo::Services::EncryptionService.encrypt(message: @query, purpose: :select_all, serializer: Marshal)
  end

  def selected_page_label
    if @resource.pagination_type.countless?
      t "avo.x_records_selected_from_page_html", selected: pagy.in
    else
      t "avo.x_records_selected_from_a_total_of_x_html", selected: pagy.in, count: pagy.count
    end
  end

  def selected_all_label
    if @resource.pagination_type.countless?
      t "avo.records_selected_from_all_pages_html"
    else
      t "avo.x_records_selected_from_all_pages_html", count: pagy.count
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
avo-3.4.4 app/components/avo/index/resource_table_component.rb
avo-3.4.3 app/components/avo/index/resource_table_component.rb
avo-3.4.2 app/components/avo/index/resource_table_component.rb
avo-3.4.1 app/components/avo/index/resource_table_component.rb
avo-3.4.0 app/components/avo/index/resource_table_component.rb
avo-3.3.6 app/components/avo/index/resource_table_component.rb
avo-3.3.5 app/components/avo/index/resource_table_component.rb
avo-3.3.4 app/components/avo/index/resource_table_component.rb
avo-3.3.3 app/components/avo/index/resource_table_component.rb
avo-3.3.2 app/components/avo/index/resource_table_component.rb
avo-3.3.1 app/components/avo/index/resource_table_component.rb
avo-3.3.0 app/components/avo/index/resource_table_component.rb
avo-3.2.3 app/components/avo/index/resource_table_component.rb
avo-3.2.2 app/components/avo/index/resource_table_component.rb
avo-3.2.1 app/components/avo/index/resource_table_component.rb
avo-3.2.0 app/components/avo/index/resource_table_component.rb
avo-3.1.7 app/components/avo/index/resource_table_component.rb
avo-3.1.6 app/components/avo/index/resource_table_component.rb
avo-3.1.5 app/components/avo/index/resource_table_component.rb
avo-3.1.4 app/components/avo/index/resource_table_component.rb