Class: Mxrb::Dsl::WidgetBuilder
- Inherits:
-
Object
- Object
- Mxrb::Dsl::WidgetBuilder
- Defined in:
- lib/mxrb/dsl/builder.rb
Overview
Builds sub-widgets inside a data_grid column sub-items or inside a container.
Instance Method Summary collapse
- #column(name, attribute: nil, caption: nil) ⇒ Object
-
#initialize(type, name, **options) ⇒ WidgetBuilder
constructor
A new instance of WidgetBuilder.
- #search_bar(&block) ⇒ Object
- #tab_page(name, caption: nil, &block) ⇒ Object
- #to_h ⇒ Object
- #toolbar(&block) ⇒ Object
Constructor Details
#initialize(type, name, **options) ⇒ WidgetBuilder
Returns a new instance of WidgetBuilder.
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/mxrb/dsl/builder.rb', line 117 def initialize(type, name, **) @type = type @name = name.to_s @options = @events = [] @columns = [] @tabs = [] @search_bar = nil @toolbar = nil end |
Instance Method Details
#column(name, attribute: nil, caption: nil) ⇒ Object
128 129 130 |
# File 'lib/mxrb/dsl/builder.rb', line 128 def column(name, attribute: nil, caption: nil) @columns << { name: name.to_s, attribute: attribute&.to_s, caption: caption }.compact end |
#search_bar(&block) ⇒ Object
138 139 140 141 142 |
# File 'lib/mxrb/dsl/builder.rb', line 138 def (&block) sb = SearchBarBuilder.new sb.instance_eval(&block) if block @search_bar = sb.to_h end |
#tab_page(name, caption: nil, &block) ⇒ Object
132 133 134 135 136 |
# File 'lib/mxrb/dsl/builder.rb', line 132 def tab_page(name, caption: nil, &block) tab = TabPageBuilder.new(name, caption: caption) tab.instance_eval(&block) if block @tabs << tab.to_h end |
#to_h ⇒ Object
158 159 160 161 162 163 164 165 |
# File 'lib/mxrb/dsl/builder.rb', line 158 def to_h = @options.dup [:columns] = @columns unless @columns.empty? [:tabs] = @tabs unless @tabs.empty? [:search_bar] = @search_bar if @search_bar [:toolbar] = @toolbar if @toolbar { type: @type, name: @name, options: , events: @events } end |
#toolbar(&block) ⇒ Object
144 145 146 147 148 |
# File 'lib/mxrb/dsl/builder.rb', line 144 def (&block) tb = ToolbarBuilder.new tb.instance_eval(&block) if block @toolbar = tb.to_h end |