Module: Mxrb::Dsl::WidgetDsl
- Included in:
- ContainerBuilder, PageBuilder, TabPageBuilder, WidgetBuilder
- 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, selection: nil, &block) ⇒ Object
- #date_picker(name, attribute: nil, caption: nil, &block) ⇒ Object
- #drop_down(name, attribute: nil, caption: nil) ⇒ Object
-
#gallery(name, entity: nil, &block) ⇒ Object
Gallery projections remain present beside an authoritative page deep_structure in exported projects.
- #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.
153 154 155 |
# File 'lib/mxrb/dsl/builder.rb', line 153 def bson_binary(base64, subtype: :generic) BSON::Binary.new(Base64.strict_decode64(base64), subtype.to_sym) end |
#button(name, caption: nil, &block) ⇒ Object
104 105 106 |
# File 'lib/mxrb/dsl/builder.rb', line 104 def (name, caption: nil, &block) (:button, name, caption: caption || name.to_s, &block) end |
#check_box(name, attribute: nil, caption: nil, &block) ⇒ Object
69 70 71 |
# File 'lib/mxrb/dsl/builder.rb', line 69 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
124 125 126 127 128 |
# File 'lib/mxrb/dsl/builder.rb', line 124 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, selection: nil, &block) ⇒ Object
88 89 90 |
# File 'lib/mxrb/dsl/builder.rb', line 88 def data_grid(name, entity: nil, selection: nil, &block) (:data_grid, name, entity: entity, selection: selection, &block) end |
#date_picker(name, attribute: nil, caption: nil, &block) ⇒ Object
73 74 75 |
# File 'lib/mxrb/dsl/builder.rb', line 73 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
108 109 110 111 112 113 114 |
# File 'lib/mxrb/dsl/builder.rb', line 108 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 |
#gallery(name, entity: nil, &block) ⇒ Object
Gallery projections remain present beside an authoritative page deep_structure in exported projects. Accept the concise projection at every widget nesting level so arbitrary native pages can be evaluated and reconstructed from their lossless payload.
96 97 98 |
# File 'lib/mxrb/dsl/builder.rb', line 96 def gallery(name, entity: nil, &block) (:gallery, name, entity: entity, &block) end |
#native_widget(name, type:, deep_structure:) ⇒ Object
141 142 143 144 145 146 147 148 |
# File 'lib/mxrb/dsl/builder.rb', line 141 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
59 60 61 |
# File 'lib/mxrb/dsl/builder.rb', line 59 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
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/mxrb/dsl/builder.rb', line 130 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
77 78 79 80 81 82 |
# File 'lib/mxrb/dsl/builder.rb', line 77 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
116 117 118 119 120 121 122 |
# File 'lib/mxrb/dsl/builder.rb', line 116 def snippet(name, from: nil) << { type: :snippet, name: name.to_s, options: { snippet: (from || name).to_s }, events: [] } end |
#tab_control(name, &block) ⇒ Object
100 101 102 |
# File 'lib/mxrb/dsl/builder.rb', line 100 def tab_control(name, &block) (:tab_control, name, &block) end |
#text(name, caption: nil, &block) ⇒ Object
84 85 86 |
# File 'lib/mxrb/dsl/builder.rb', line 84 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
63 64 65 66 67 |
# File 'lib/mxrb/dsl/builder.rb', line 63 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
55 56 57 |
# File 'lib/mxrb/dsl/builder.rb', line 55 def text_box(name, attribute: nil, caption: nil, &block) (:text_box, name, attribute: attribute, caption: caption, &block) end |