Sha256: a8aa24f7ef1c624aac0ffabe5d6a695ffb9e14d51afa75d0c587f49fc52bc70e

Contents?: true

Size: 1.85 KB

Versions: 442

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbAdvancedTable
    class TableBody < Playbook::KitBase
      prop :id, type: Playbook::Props::String,
                default: ""
      prop :table_data, type: Playbook::Props::Array,
                        default: []
      prop :column_definitions, type: Playbook::Props::Array,
                                default: []
      prop :enable_toggle_expansion, type: Playbook::Props::Enum,
                                     values: %w[all header none],
                                     default: "header"
      prop :subrow_headers, type: Playbook::Props::Array,
                            default: []

      def render_row_and_children(row, column_definitions, current_depth, first_parent_child)
        output = ActiveSupport::SafeBuffer.new
        is_first_child_of_subrow = current_depth.positive? && first_parent_child && subrow_headers[current_depth - 1].present?

        output << pb_rails("advanced_table/table_subrow_header", props: { row: row, column_definitions: column_definitions, depth: current_depth, subrow_header: subrow_headers[current_depth - 1] }) if is_first_child_of_subrow && enable_toggle_expansion == "all"

        output << pb_rails("advanced_table/table_row", props: { id: id, row: row, column_definitions: column_definitions, depth: current_depth })

        if row[:children].present?
          output << content_tag(:div, class: "toggle-content", data: { advanced_table_content: row.object_id.to_s + id }) do
            row[:children].map do |child_row|
              render_row_and_children(child_row, column_definitions, current_depth + 1, row.children.first == child_row)
            end.join.html_safe
          end
        end

        output
      end

      def classname
        generate_classname("pb_advanced_table_body", "pb_table_tbody", separator: " ")
      end
    end
  end
end

Version data entries

442 entries across 442 versions & 1 rubygems

Version Path
playbook_ui-14.9.0.pre.alpha.PLAY1731inputmasking4868 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0.pre.alpha.PLAY1731inputmasking4866 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0.pre.alpha.PBNTR738collapsiblewithintablekit4855 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.10 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.9 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.8 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.7 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.6 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.5 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.4 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0.pre.alpha.PLAY16264818 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0.pre.alpha.PBNTR702stickyleftcolrails4806 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.3 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.2 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0.pre.alpha.play1742globalheightfixes4766 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.1 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0.pre.alpha.PBNTR686advancedtablepaginationpoc4747 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0.pre.alpha.pbntr700newresettodefaultprop4736 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.10.0.pre.rc.0 app/pb_kits/playbook/pb_advanced_table/table_body.rb
playbook_ui-14.9.0 app/pb_kits/playbook/pb_advanced_table/table_body.rb