Sha256: fd8465db30c63549b551f7d86aea1b12411a0c005a257a46c95bbb23ffc66ad7

Contents?: true

Size: 1.35 KB

Versions: 34

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbAdvancedTable
    class TableRow < Playbook::KitBase
      prop :id, type: Playbook::Props::String,
                default: ""
      prop :column_definitions, type: Playbook::Props::Array,
                                default: []
      prop :row
      prop :depth
      prop :collapsible_trail, type: Playbook::Props::Boolean,
                               default: true

      def classname
        generate_classname("pb_table_tr", "bg-white", subrow_depth_classname, separator: " ")
      end

      def td_classname
        generate_classname("id-cell", "chrome-styles", separator: " ")
      end

      def depth_accessors
        column_definitions.flat_map do |column|
          column[:cellAccessors] if column.key?(:cellAccessors)
        end.compact
      end

    private

      def custom_renderer_value(column, index)
        if index.zero?
          if depth.zero?
            row[column[:accessor].to_sym]
          else
            depth_accessors.each_with_index do |item, accessor_index|
              key = item.to_sym
              return row[key] if depth - 1 == accessor_index
            end
          end
        else
          row[column[:accessor].to_sym]
        end
      end

      def subrow_depth_classname
        depth.positive? ? "depth-sub-row-#{depth}" : ""
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5214 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5213 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5210 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5208 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5207 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play16825206 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5204 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5201 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.9 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5200 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.8 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.7 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.6 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.5 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5193 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.4 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.3 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.10.0.pre.alpha.PBNTR662stickyrightcolumnreact5160 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.2 app/pb_kits/playbook/pb_advanced_table/table_row.rb
playbook_ui-14.11.0.pre.rc.1 app/pb_kits/playbook/pb_advanced_table/table_row.rb