Class: Mxrb::Compiler::DataGridBundleCompiler

Inherits:
Object
  • Object
show all
Includes:
ModelValues
Defined in:
lib/mxrb/compiler/data_grid_bundle_compiler.rb

Overview

Compiles the Data Grid 2 XPath/attribute-column subset into pluggable-widget properties. rubocop:disable Metrics

Constant Summary collapse

WIDGET_ID =
'com.mendix.widget.web.datagrid.Datagrid'

Instance Method Summary collapse

Constructor Details

#initialize(source, page_name, widget = nil, render_widgets: nil, **widget_keywords) ⇒ DataGridBundleCompiler

Returns a new instance of DataGridBundleCompiler.



14
15
16
17
18
19
20
# File 'lib/mxrb/compiler/data_grid_bundle_compiler.rb', line 14

def initialize(source, page_name, widget = nil, render_widgets: nil, **widget_keywords)
  @source = source
  @page_name = page_name
  @widget = widget || widget_keywords
  @render_widgets = render_widgets
  @index = document_index
end

Instance Method Details

#renderObject



27
28
29
# File 'lib/mxrb/compiler/data_grid_bundle_compiler.rb', line 27

def render
  "React.createElement($Datagrid, #{js_object(properties)})"
end

#supported?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/mxrb/compiler/data_grid_bundle_compiler.rb', line 22

def supported?
  widget_type&.fetch('WidgetId', nil) == WIDGET_ID && xpath_source &&
    columns.all? { supported_column?(_1) }
end