Sha256: e8914183c5e8be3f8ba6d69ec999f5d0914ee81e8133a0a98a960fb23b349bfd
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require_relative "body_cell" module Katalyst module Tables module Frontend module Builder class HeaderCell < BodyCell # :nodoc: def initialize(table, method, **options) super(table, nil, method, **options) @value = options[:label] @header = true end def build(&_block) # NOTE: block ignored intentionally but subclasses may consume it if @table.sort&.supports?(@table.collection, method) content = sort_link(value) # writes to html_options table_tag :th, content # consumes options else table_tag :th, value end end def value if !@value.nil? @value elsif @table.object_name.present? translation else default_value end end def translation(key = "activerecord.attributes.#{@table.object_name}.#{method}") translate(key, default: default_value) end def default_value method.to_s.humanize.titleize end private def sort_link(content) (@html_options["data"] ||= {})["sort"] = sort.status(method) link_to(content, @table.sort.url_for(method)) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katalyst-tables-1.0.0 | lib/katalyst/tables/frontend/builder/header_cell.rb |