Class: Glib::JsonUi::ViewBuilder::Panels::Table2

Inherits:
View show all
Defined in:
app/helpers/glib/json_ui/view_builder/panels.rb

Instance Attribute Summary collapse

Attributes inherited from JsonUiElement

#json, #page

Instance Method Summary collapse

Methods inherited from View

component_name

Methods inherited from JsonUiElement

action, any, array, badgeable, bool, color, component_name, date, date_time, enum, float, hash, icon, int, length, menu, panels_builder, #props, required, singleton_array, string, text, url, views

Constructor Details

#initialize(json, page) ⇒ Table2

Returns a new instance of Table2.



452
453
454
455
# File 'app/helpers/glib/json_ui/view_builder/panels.rb', line 452

def initialize(json, page)
  super
  @template = Glib::JsonUi::TableBuilders::Template.new(json, self)
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



446
447
448
# File 'app/helpers/glib/json_ui/view_builder/panels.rb', line 446

def template
  @template
end

Instance Method Details

#header(options = {}) ⇒ Object



457
458
459
460
461
462
463
464
465
466
467
468
# File 'app/helpers/glib/json_ui/view_builder/panels.rb', line 457

def header(options = {})
  json.header do
    json.backgroundColor options.delete(:backgroundColor)
    json.cellViews do
      options.delete(:cellViews)&.call page.view_builder
    end

    json.colSpans options.delete(:colSpans)
  end

  raise "Invalid properties: #{options.keys}" if options.size > 0
end

#rows(options = {}) ⇒ Object



470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'app/helpers/glib/json_ui/view_builder/panels.rb', line 470

def rows(options = {})
  block = options.delete(:builder)
  json.rows do
    if (objects = options.delete(:objects))
      objects.each_with_index do |object, index|
        block&.call template, object, index
      end
    else
      block&.call template
    end
  end

  raise "Invalid properties: #{options.keys}" if options.size > 0
end