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.
145 146 147 |
# File 'lib/mxrb/dsl/builder.rb', line 145 def bson_binary(base64, subtype: :generic) BSON::Binary.new(Base64.strict_decode64(base64), subtype.to_sym) end |
#button(name, caption: nil, &block) ⇒ Object
96 97 98 |
# File 'lib/mxrb/dsl/builder.rb', line 96 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
116 117 118 119 120 |
# File 'lib/mxrb/dsl/builder.rb', line 116 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
88 89 90 |
# File 'lib/mxrb/dsl/builder.rb', line 88 def data_grid(name, entity: nil, &block) (:data_grid, name, entity: entity, &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
100 101 102 103 104 105 106 |
# File 'lib/mxrb/dsl/builder.rb', line 100 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
133 134 135 136 137 138 139 140 |
# File 'lib/mxrb/dsl/builder.rb', line 133 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
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/mxrb/dsl/builder.rb', line 122 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
108 109 110 111 112 113 114 |
# File 'lib/mxrb/dsl/builder.rb', line 108 def snippet(name, from: nil) << { type: :snippet, name: name.to_s, options: { snippet: (from || name).to_s }, events: [] } end |
#tab_control(name, &block) ⇒ Object
92 93 94 |
# File 'lib/mxrb/dsl/builder.rb', line 92 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 |