Class: Mxrb::Dsl::WidgetBuilder
- Inherits:
-
Object
- Object
- Mxrb::Dsl::WidgetBuilder
show all
- Includes:
- WidgetDsl
- 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
Methods included from WidgetDsl
#bson_binary, #button, #check_box, #container, #data_grid, #date_picker, #drop_down, #gallery, #native_widget, #number_input, #pluggable_widget, #reference_selector, #snippet, #tab_control, #text, #text_area, #text_box
Constructor Details
#initialize(type, name, **options) ⇒ WidgetBuilder
Returns a new instance of WidgetBuilder.
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/mxrb/dsl/builder.rb', line 170
def initialize(type, name, **options)
@type = type
@name = name.to_s
@options = options
@events = []
@columns = []
@tabs = []
@search_bar = nil
@toolbar = nil
@children = []
@filters = []
end
|
Instance Method Details
#column(name, attribute: nil, caption: nil, filter: nil) ⇒ Object
183
184
185
186
187
|
# File 'lib/mxrb/dsl/builder.rb', line 183
def column(name, attribute: nil, caption: nil, filter: nil)
@columns << {
name: name.to_s, attribute: attribute&.to_s, caption:, filter:
}.compact
end
|
#filter(widget) ⇒ Object
189
|
# File 'lib/mxrb/dsl/builder.rb', line 189
def filter(widget) = @filters << widget
|
#search_bar(&block) ⇒ Object
197
198
199
200
201
|
# File 'lib/mxrb/dsl/builder.rb', line 197
def search_bar(&block)
sb = SearchBarBuilder.new
sb.instance_eval(&block) if block
@search_bar = sb.to_h
end
|
#tab_page(name, caption: nil, &block) ⇒ Object
191
192
193
194
195
|
# File 'lib/mxrb/dsl/builder.rb', line 191
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
217
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/mxrb/dsl/builder.rb', line 217
def to_h
options = @options.dup
options[:columns] = @columns unless @columns.empty?
options[:tabs] = @tabs unless @tabs.empty?
options[:search_bar] = @search_bar if @search_bar
options[:toolbar] = @toolbar if @toolbar
options[:filters] = @filters unless @filters.empty?
value = { type: @type, name: @name, options: options, events: @events }
value[:children] = @children unless @children.empty?
value
end
|
203
204
205
206
207
|
# File 'lib/mxrb/dsl/builder.rb', line 203
def toolbar(&block)
tb = ToolbarBuilder.new
tb.instance_eval(&block) if block
@toolbar = tb.to_h
end
|