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.
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/mxrb/dsl/builder.rb', line 160 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
171 172 173 |
# File 'lib/mxrb/dsl/builder.rb', line 171 def column(name, attribute: nil, caption: nil) @columns << { name: name.to_s, attribute: attribute&.to_s, caption: caption }.compact end |
#search_bar(&block) ⇒ Object
181 182 183 184 185 |
# File 'lib/mxrb/dsl/builder.rb', line 181 def (&block) sb = SearchBarBuilder.new sb.instance_eval(&block) if block @search_bar = sb.to_h end |
#tab_page(name, caption: nil, &block) ⇒ Object
175 176 177 178 179 |
# File 'lib/mxrb/dsl/builder.rb', line 175 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
201 202 203 204 205 206 207 208 |
# File 'lib/mxrb/dsl/builder.rb', line 201 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
187 188 189 190 191 |
# File 'lib/mxrb/dsl/builder.rb', line 187 def (&block) tb = ToolbarBuilder.new tb.instance_eval(&block) if block @toolbar = tb.to_h end |