Sha256: b560f3ec565c63e5775ab9d9df338fbc173f228b3b474de35dc0ed4b8401ad45
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Katalyst module Turbo # Renders a table that uses turbo stream replacement when sorting or # paginating. class TableComponent < ::Katalyst::TableComponent include Tables::TurboReplaceable attr_reader :id def initialize(collection:, id:, header: true, **options) header = if header.is_a?(Hash) default_header_options.merge(header) elsif header default_header_options end @id = id super(collection: collection, header: header, id: id, **options) end private def default_html_attributes { data: { controller: "tables--turbo-collection", tables__turbo_collection_url_value: current_path, tables__turbo_collection_sort_value: collection.sort, }, } end def current_path params = collection.to_params query_string = params.empty? ? "" : "?#{Rack::Utils.build_nested_query(params)}" "#{request.path}#{query_string}" end def default_header_options { link: { data: { turbo_stream: "" } } } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems