Class: Mxrb::Compiler::LegacyPageBuilder

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

Overview

rubocop:disable Metrics/AbcSize, Metrics/ClassLength, Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity Writes deterministic Dojo page XML for the built-in Data Grid 1 contract.

Constant Summary collapse

VISUAL_WIDGET_TYPES =

Model elements that own visible client widgets. Supporting a page means rendering these elements, not merely serializing their nested settings.

%w[
  Forms$ActionButton Forms$CheckBox Forms$DataGrid Forms$DataView Forms$DatePicker
  Forms$DivContainer Forms$DropDown Forms$DynamicText Forms$ImageViewer Forms$Label
  Forms$LayoutGrid Forms$ListView Forms$RadioButtonGroup Forms$ReferenceSelector
  Forms$SnippetCallWidget Forms$StaticImageViewer Forms$TabControl Forms$TextArea
  Forms$TextBox Forms$InputReferenceSetSelector CustomWidgets$CustomWidget
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(source, web_root, profiles: [:dojo]) ⇒ LegacyPageBuilder

Returns a new instance of LegacyPageBuilder.



26
27
28
29
30
31
# File 'lib/mxrb/compiler/legacy_page_builder.rb', line 26

def initialize(source, web_root, profiles: [:dojo])
  @source = source
  @web_root = web_root
  @profiles = profiles
  @unsupported = Hash.new { |hash, key| hash[key] = [] }
end

Instance Method Details

#auditObject

Performs the same widget audit as #build without writing deployment files.



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/mxrb/compiler/legacy_page_builder.rb', line 49

def audit
  @unsupported.clear
  (@source.units_of('Forms$Layout') + @source.units_of('Forms$Page')).each do |unit|
    name = "#{unit.module_name}.#{unit.document['Name']}"
    audit_unsupported_widgets(unit.document, name)
    descendants(unit.document).select { _1['$Type'] == 'Forms$DataGrid' }.each_with_index do |grid, index|
      compiler = LegacyDataGridCompiler.new(@source, name, grid, language: 'en_US', sequence: index + 1)
      compiler.html
      @unsupported[name].concat(compiler.unsupported)
    end
  end
  frozen_unsupported
end

#buildObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mxrb/compiler/legacy_page_builder.rb', line 33

def build
  pages = @source.units_of('Forms$Page')
  layouts = @source.units_of('Forms$Layout')
  languages.each do |language|
    layouts.each { write_layout(_1, language) }
    pages.each { write_page(_1, language) }
  end
  write_manifest
  files = Dir.glob(File.join(@web_root, 'pages', '**', '*.xml')).select { File.file?(_1) }
  LegacyPageBuild.new(
    directory: File.join(@web_root, 'pages'), files: files.length,
    bytes: files.sum { File.size(_1) }, unsupported_widgets: frozen_unsupported
  )
end