Sha256: 64ffd6e49eee32833f44567f135baabc6eec82a6c6edbca9362c9ed86e51566c

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module Query
      class ModalComponent < ViewComponent::Base
        include Katalyst::HtmlAttributes
        include Katalyst::Tables::Frontend

        renders_one :footer
        renders_many :suggestions, SuggestionComponent

        attr_reader :collection, :url

        def initialize(collection:, **)
          super(**)

          @collection = collection
        end

        def before_render
          collection.suggestions.each_with_index do |suggestion, index|
            with_suggestion(suggestion:, index:)
          end
        end

        private

        def default_html_attributes
          {
            id:    "suggestion-dialog",
            class: "query-modal",
            role:  "dialog",
            aria:  {
              label: t(".suggestions_title"),
            },
            data:  {
              tables__query_target: "modal",
              action:               ["turbo:before-morph-attribute->tables--query#beforeMorphAttribute"],
            },
          }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katalyst-tables-3.7.0 app/components/katalyst/tables/query/modal_component.rb
katalyst-tables-3.6.2 app/components/katalyst/tables/query/modal_component.rb
katalyst-tables-3.6.1 app/components/katalyst/tables/query/modal_component.rb
katalyst-tables-3.6.0 app/components/katalyst/tables/query/modal_component.rb