class Thinreports::SectionReport::Builder::StackViewBuilder
Attributes
item[R]
Public Class Methods
new(item)
click to toggle source
# File lib/thinreports/section_report/builder/stack_view_builder.rb, line 9 def initialize(item) @item = item end
Public Instance Methods
update(params)
click to toggle source
# File lib/thinreports/section_report/builder/stack_view_builder.rb, line 13 def update(params) rows_params = params[:rows] || {} rows_schema = item.internal.format.rows schema_row_ids = rows_schema.map {|row_schema| row_schema.id.to_sym}.to_set rows = [] rows_schema.each do |row_schema| row_params = rows_params[row_schema.id.to_sym] || {} next unless row_enabled?(row_schema, row_params) items = build_row_items( row_schema, row_params[:items] || {} ) rows << StackViewData::Row.new(row_schema, items, row_params[:min_height]) end item.internal.rows = rows end
Private Instance Methods
build_row_items(row_schema, items_params)
click to toggle source
# File lib/thinreports/section_report/builder/stack_view_builder.rb, line 38 def build_row_items(row_schema, items_params) row_schema.items.each_with_object([]) do |item_schema, items| item = ItemBuilder.new(item_schema, row_schema).build(items_params[item_schema.id&.to_sym]) items << item if item.visible? end end
row_enabled?(row_schema, row_params)
click to toggle source
# File lib/thinreports/section_report/builder/stack_view_builder.rb, line 45 def row_enabled?(row_schema, row_params) if row_params.key?(:display) row_params[:display] else row_schema.display? end end