Module: Mxrb::Dsl::WidgetDsl
- Included in:
- ContainerBuilder, PageBuilder, TabPageBuilder
- Defined in:
- lib/mxrb/dsl/builder.rb
Overview
Shared widget-building methods for PageBuilder and ContainerBuilder.
Includers must implement private _widget_list returning the target array.
Instance Method Summary collapse
-
#bson_binary(base64, subtype: :generic) ⇒ Object
Exported native widget payloads can contain BSON identifiers at any nesting level.
- #button(name, caption: nil, &block) ⇒ Object
- #check_box(name, attribute: nil, caption: nil, &block) ⇒ Object
- #container(name, class_name: nil, &block) ⇒ Object
- #data_grid(name, entity: nil, &block) ⇒ Object
- #date_picker(name, attribute: nil, caption: nil, &block) ⇒ Object
- #drop_down(name, attribute: nil, caption: nil) ⇒ Object
- #native_widget(name, type:, deep_structure:) ⇒ Object
- #number_input(name, attribute: nil, caption: nil, &block) ⇒ Object
- #pluggable_widget(name, widget_id:, widget_name: nil, properties: {}, class_name: nil) ⇒ Object
- #reference_selector(name, attribute: nil, caption: nil, display_attribute: nil, &block) ⇒ Object
- #snippet(name, from: nil) ⇒ Object
- #tab_control(name, &block) ⇒ Object
- #text(name, caption: nil, &block) ⇒ Object
- #text_area(name, attribute: nil, caption: nil, lines: 5, &block) ⇒ Object
- #text_box(name, attribute: nil, caption: nil, &block) ⇒ Object
Instance Method Details
#bson_binary(base64, subtype: :generic) ⇒ Object
Exported native widget payloads can contain BSON identifiers at any nesting level. Keep the reconstruction helper on the shared widget DSL so pages, containers, and tab pages all evaluate the same export.
102 103 104 |
# File 'lib/mxrb/dsl/builder.rb', line 102 def bson_binary(base64, subtype: :generic) BSON::Binary.new(Base64.strict_decode64(base64), subtype.to_sym) end |
#button(name, caption: nil, &block) ⇒ Object
53 54 55 |
# File 'lib/mxrb/dsl/builder.rb', line 53 def (name, caption: nil, &block) (:button, name, caption: caption || name.to_s, &block) end |
#check_box(name, attribute: nil, caption: nil, &block) ⇒ Object
26 27 28 |
# File 'lib/mxrb/dsl/builder.rb', line 26 def check_box(name, attribute: nil, caption: nil, &block) (:check_box, name, attribute: attribute, caption: caption, &block) end |
#container(name, class_name: nil, &block) ⇒ Object
73 74 75 76 77 |
# File 'lib/mxrb/dsl/builder.rb', line 73 def container(name, class_name: nil, &block) cb = ContainerBuilder.new(name, class_name: class_name) cb.instance_eval(&block) if block << cb.to_h end |
#data_grid(name, entity: nil, &block) ⇒ Object
45 46 47 |
# File 'lib/mxrb/dsl/builder.rb', line 45 def data_grid(name, entity: nil, &block) (:data_grid, name, entity: entity, &block) end |
#date_picker(name, attribute: nil, caption: nil, &block) ⇒ Object
30 31 32 |
# File 'lib/mxrb/dsl/builder.rb', line 30 def date_picker(name, attribute: nil, caption: nil, &block) (:date_picker, name, attribute: attribute, caption: caption, &block) end |
#drop_down(name, attribute: nil, caption: nil) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/mxrb/dsl/builder.rb', line 57 def drop_down(name, attribute: nil, caption: nil) << { type: :drop_down, name: name.to_s, options: { attribute: attribute&.to_s, caption: caption }.compact, events: [] } end |
#native_widget(name, type:, deep_structure:) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/mxrb/dsl/builder.rb', line 90 def (name, type:, deep_structure:) raise ArgumentError, "deep_structure requires a Hash" unless deep_structure.is_a?(Hash) << { type: :native_widget, name: name.to_s, options: { native_type: type.to_s, deep_structure: deep_structure }, events: [] } end |
#number_input(name, attribute: nil, caption: nil, &block) ⇒ Object
16 17 18 |
# File 'lib/mxrb/dsl/builder.rb', line 16 def number_input(name, attribute: nil, caption: nil, &block) (:number_input, name, attribute: attribute, caption: caption, &block) end |
#pluggable_widget(name, widget_id:, widget_name: nil, properties: {}, class_name: nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/mxrb/dsl/builder.rb', line 79 def (name, widget_id:, widget_name: nil, properties: {}, class_name: nil) << { type: :pluggable_widget, name: name.to_s, options: { widget_id: .to_s, widget_name: ( || name).to_s, properties: properties, class: class_name }.compact, events: [] } end |
#reference_selector(name, attribute: nil, caption: nil, display_attribute: nil, &block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/mxrb/dsl/builder.rb', line 34 def reference_selector(name, attribute: nil, caption: nil, display_attribute: nil, &block) ( :reference_selector, name, attribute: attribute, caption: caption, display_attribute: display_attribute, &block ) end |
#snippet(name, from: nil) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/mxrb/dsl/builder.rb', line 65 def snippet(name, from: nil) << { type: :snippet, name: name.to_s, options: { snippet: (from || name).to_s }, events: [] } end |
#tab_control(name, &block) ⇒ Object
49 50 51 |
# File 'lib/mxrb/dsl/builder.rb', line 49 def tab_control(name, &block) (:tab_control, name, &block) end |
#text(name, caption: nil, &block) ⇒ Object
41 42 43 |
# File 'lib/mxrb/dsl/builder.rb', line 41 def text(name, caption: nil, &block) (:text, name, caption: caption || name.to_s, &block) end |
#text_area(name, attribute: nil, caption: nil, lines: 5, &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/mxrb/dsl/builder.rb', line 20 def text_area(name, attribute: nil, caption: nil, lines: 5, &block) ( :text_area, name, attribute: attribute, caption: caption, lines: lines, &block ) end |
#text_box(name, attribute: nil, caption: nil, &block) ⇒ Object
12 13 14 |
# File 'lib/mxrb/dsl/builder.rb', line 12 def text_box(name, attribute: nil, caption: nil, &block) (:text_box, name, attribute: attribute, caption: caption, &block) end |