Class: Mxrb::Compiler::ComboBoxBundleCompiler
- Inherits:
-
Object
- Object
- Mxrb::Compiler::ComboBoxBundleCompiler
- Includes:
- ModelValues
- Defined in:
- lib/mxrb/compiler/combo_box_bundle_compiler.rb
Overview
Compiles association- and database-backed instances of the official React Combo box widget. rubocop:disable Metrics
Constant Summary collapse
- WIDGET_ID =
'com.mendix.widget.web.combobox.Combobox'
Instance Method Summary collapse
-
#initialize(source, page_name, widget, scope:, entity:) ⇒ ComboBoxBundleCompiler
constructor
A new instance of ComboBoxBundleCompiler.
-
#render ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
- #supported? ⇒ Boolean
Constructor Details
#initialize(source, page_name, widget, scope:, entity:) ⇒ ComboBoxBundleCompiler
Returns a new instance of ComboBoxBundleCompiler.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mxrb/compiler/combo_box_bundle_compiler.rb', line 15 def initialize(source, page_name, , scope:, entity:) @source = source @page_name = page_name @widget = @scope = scope @entity = entity @index = document_index @values = property_values(['Object']) @data_source = WebListDataSource.new(source, ) end |
Instance Method Details
#render ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mxrb/compiler/combo_box_bundle_compiler.rb', line 30 def render # rubocop:disable Metrics/AbcSize, Metrics/MethodLength properties = primitive_properties.merge( key: , '$widgetId': , class: css_class, id: , optionsSourceStaticDataSource: [], ariaRequired: raw(expression(false)) ) properties.merge!(source_properties) control = "React.createElement($Combobox, #{javascript(properties)})" caption = translated_text(@widget['LabelTemplate']) group = { key: "#{}$formGroup", '$widgetId': "#{}$formGroup", class: "#{css_class} mx-combobox", control: raw("[#{control}]"), width: 3, orientation: 'horizontal', labelFor: , caption: raw(expression(caption)), hasError: raw(expression(false)) } "React.createElement($FormGroup, #{javascript(group)})" end |
#supported? ⇒ Boolean
26 27 28 |
# File 'lib/mxrb/compiler/combo_box_bundle_compiler.rb', line 26 def supported? &.fetch('WidgetId', nil) == WIDGET_ID && supported_source? && resolved_scope end |