cedar-embeddable-editor 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/fonts/MaterialIcons-Regular.eot +0 -0
- package/assets/fonts/MaterialIcons-Regular.ttf +0 -0
- package/assets/fonts/MaterialIcons-Regular.woff +0 -0
- package/assets/fonts/MaterialIcons-Regular.woff2 +0 -0
- package/{src/index.html → index.html} +3 -3
- package/main.js +9417 -0
- package/main.js.map +1 -0
- package/package.json +1 -1
- package/polyfills.js +4345 -0
- package/polyfills.js.map +1 -0
- package/runtime.js +205 -0
- package/runtime.js.map +1 -0
- package/scripts.js +48 -0
- package/scripts.js.map +1 -0
- package/styles.css +5019 -0
- package/styles.css.map +1 -0
- package/vendor.js +189695 -0
- package/vendor.js.map +1 -0
- package/.browserslistrc +0 -18
- package/.editorconfig +0 -16
- package/README.md +0 -302
- package/angular.json +0 -153
- package/cedar-embeddable-editor-0.9.0.tgz +0 -0
- package/e2e/protractor.conf.js +0 -36
- package/e2e/src/app.e2e-spec.ts +0 -23
- package/e2e/src/app.po.ts +0 -11
- package/e2e/tsconfig.json +0 -14
- package/karma.conf.js +0 -32
- package/license.txt +0 -26
- package/src/app/app.component.dev.ts +0 -74
- package/src/app/app.component.html +0 -5
- package/src/app/app.component.prod.ts +0 -76
- package/src/app/app.component.scss +0 -1
- package/src/app/app.module.dev.ts +0 -58
- package/src/app/app.module.prod.ts +0 -56
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.html +0 -0
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.spec.ts +0 -24
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.ts +0 -39
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.html +0 -25
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.ts +0 -91
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.html +0 -8
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.ts +0 -104
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.html +0 -22
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.spec.ts +0 -24
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.ts +0 -135
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.html +0 -44
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.ts +0 -451
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.html +0 -16
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.ts +0 -91
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.html +0 -16
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.ts +0 -92
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.html +0 -18
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.scss +0 -5
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.ts +0 -78
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.html +0 -15
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.ts +0 -169
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.html +0 -15
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.ts +0 -94
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.html +0 -19
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.ts +0 -108
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.html +0 -25
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.ts +0 -125
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.html +0 -8
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.spec.ts +0 -24
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.ts +0 -40
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.html +0 -20
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.scss +0 -24
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.ts +0 -36
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.html +0 -2
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.spec.ts +0 -25
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.ts +0 -35
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.html +0 -8
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.spec.ts +0 -24
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.ts +0 -39
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.html +0 -6
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.spec.ts +0 -24
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.ts +0 -42
- package/src/app/modules/input-types/input-types.module.ts +0 -139
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.html +0 -13
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.scss +0 -12
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.spec.ts +0 -25
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.ts +0 -42
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.html +0 -117
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.scss +0 -5
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.spec.ts +0 -25
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.ts +0 -101
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.html +0 -22
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.scss +0 -23
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.spec.ts +0 -24
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.ts +0 -139
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.html +0 -56
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.scss +0 -13
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.spec.ts +0 -25
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.ts +0 -184
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.html +0 -15
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.scss +0 -2
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.spec.ts +0 -25
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.ts +0 -240
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.html +0 -35
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.scss +0 -41
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.spec.ts +0 -25
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.ts +0 -282
- package/src/app/modules/shared/components/date-picker/date-picker.component.html +0 -46
- package/src/app/modules/shared/components/date-picker/date-picker.component.scss +0 -7
- package/src/app/modules/shared/components/date-picker/date-picker.component.spec.ts +0 -25
- package/src/app/modules/shared/components/date-picker/date-picker.component.ts +0 -100
- package/src/app/modules/shared/components/file-uploader/bytes/bytes.pipe.spec.ts +0 -33
- package/src/app/modules/shared/components/file-uploader/bytes/bytes.pipe.ts +0 -16
- package/src/app/modules/shared/components/file-uploader/file-upload-input-for/file-upload-input-for.directive.spec.ts +0 -54
- package/src/app/modules/shared/components/file-uploader/file-upload-input-for/file-upload-input-for.directive.ts +0 -67
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.html +0 -26
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.scss +0 -55
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.spec.ts +0 -25
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.ts +0 -67
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.html +0 -42
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.scss +0 -31
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.spec.ts +0 -177
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.ts +0 -145
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.service.ts +0 -21
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.html +0 -1
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.scss +0 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.spec.ts +0 -59
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.ts +0 -139
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.service.spec.ts +0 -33
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.service.ts +0 -17
- package/src/app/modules/shared/components/file-uploader/mat-file-upload.module.ts +0 -35
- package/src/app/modules/shared/components/file-uploader/mat-file-upload.type.ts +0 -24
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.html +0 -18
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.scss +0 -0
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.spec.ts +0 -23
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.ts +0 -10
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.html +0 -16
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.scss +0 -0
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.spec.ts +0 -25
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.ts +0 -89
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.html +0 -19
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.scss +0 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.spec.ts +0 -25
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.ts +0 -66
- package/src/app/modules/shared/components/sample-templates/sample-templates.service.ts +0 -175
- package/src/app/modules/shared/components/source-panels/source-panels.component.html +0 -98
- package/src/app/modules/shared/components/source-panels/source-panels.component.scss +0 -0
- package/src/app/modules/shared/components/source-panels/source-panels.component.spec.ts +0 -25
- package/src/app/modules/shared/components/source-panels/source-panels.component.ts +0 -36
- package/src/app/modules/shared/components/static-footer/static-footer.component.html +0 -17
- package/src/app/modules/shared/components/static-footer/static-footer.component.scss +0 -110
- package/src/app/modules/shared/components/static-footer/static-footer.component.spec.ts +0 -25
- package/src/app/modules/shared/components/static-footer/static-footer.component.ts +0 -16
- package/src/app/modules/shared/components/static-header/static-header.component.html +0 -10
- package/src/app/modules/shared/components/static-header/static-header.component.scss +0 -13
- package/src/app/modules/shared/components/static-header/static-header.component.spec.ts +0 -25
- package/src/app/modules/shared/components/static-header/static-header.component.ts +0 -21
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.html +0 -16
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.scss +0 -0
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.spec.ts +0 -25
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.ts +0 -251
- package/src/app/modules/shared/factory/template-representation.factory.ts +0 -323
- package/src/app/modules/shared/handler/component-type.handler.ts +0 -51
- package/src/app/modules/shared/handler/data-object-builder.handler.ts +0 -159
- package/src/app/modules/shared/handler/data-object-data-value.handler.ts +0 -270
- package/src/app/modules/shared/handler/data-object-structure.handler.ts +0 -145
- package/src/app/modules/shared/handler/multi-instance-object.handler.ts +0 -317
- package/src/app/modules/shared/models/cedar-input-template.model.ts +0 -3
- package/src/app/modules/shared/models/cedar-model.model.ts +0 -48
- package/src/app/modules/shared/models/component/cedar-component.model.ts +0 -16
- package/src/app/modules/shared/models/component/component-representation.model.ts +0 -30
- package/src/app/modules/shared/models/component/element-component.model.ts +0 -11
- package/src/app/modules/shared/models/component/field-component.model.ts +0 -23
- package/src/app/modules/shared/models/component/multi-component.model.ts +0 -10
- package/src/app/modules/shared/models/component/null-component.model.ts +0 -20
- package/src/app/modules/shared/models/component/single-component.model.ts +0 -6
- package/src/app/modules/shared/models/element/abstract-element-component.model.ts +0 -26
- package/src/app/modules/shared/models/element/multi-element-component.model.ts +0 -19
- package/src/app/modules/shared/models/element/single-element-component.model.ts +0 -16
- package/src/app/modules/shared/models/enum/data-object-building-mode.model.ts +0 -6
- package/src/app/modules/shared/models/field/abstract-field-component.model.ts +0 -28
- package/src/app/modules/shared/models/field/multi-field-component.model.ts +0 -21
- package/src/app/modules/shared/models/field/single-field-component.model.ts +0 -18
- package/src/app/modules/shared/models/info/basic-info.model.ts +0 -8
- package/src/app/modules/shared/models/info/choice-info.model.ts +0 -9
- package/src/app/modules/shared/models/info/choice-option.model.ts +0 -6
- package/src/app/modules/shared/models/info/content-info.model.ts +0 -5
- package/src/app/modules/shared/models/info/controlled-info.model.ts +0 -8
- package/src/app/modules/shared/models/info/current-multi-info.model.ts +0 -7
- package/src/app/modules/shared/models/info/label-info.model.ts +0 -7
- package/src/app/modules/shared/models/info/multi-info.model.ts +0 -10
- package/src/app/modules/shared/models/info/multi-instance-info.model.ts +0 -20
- package/src/app/modules/shared/models/info/multi-instance-object-info.model.ts +0 -30
- package/src/app/modules/shared/models/info/number-info.model.ts +0 -9
- package/src/app/modules/shared/models/info/value-info.model.ts +0 -9
- package/src/app/modules/shared/models/input-type.model.ts +0 -21
- package/src/app/modules/shared/models/instance-extract-data.model.ts +0 -3
- package/src/app/modules/shared/models/instance-full-data.model.ts +0 -5
- package/src/app/modules/shared/models/javascript-types.model.ts +0 -7
- package/src/app/modules/shared/models/json-schema.model.ts +0 -39
- package/src/app/modules/shared/models/numbers.model.ts +0 -10
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request-parameter-object.ts +0 -8
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request-value-constraints.ts +0 -8
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request.ts +0 -9
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-response-item.ts +0 -10
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-response.ts +0 -13
- package/src/app/modules/shared/models/static/static-field-component.model.ts +0 -24
- package/src/app/modules/shared/models/template/cedar-template.model.ts +0 -24
- package/src/app/modules/shared/models/template/empty-template.model.ts +0 -5
- package/src/app/modules/shared/models/template/null-template.model.ts +0 -23
- package/src/app/modules/shared/models/template/template-component.model.ts +0 -12
- package/src/app/modules/shared/models/temporal.model.ts +0 -13
- package/src/app/modules/shared/models/ui/cedar-ui-component.model.ts +0 -17
- package/src/app/modules/shared/models/xsd.model.ts +0 -11
- package/src/app/modules/shared/pipe/keep-html.pipe.ts +0 -13
- package/src/app/modules/shared/pipe/rdf.pipe.ts +0 -10
- package/src/app/modules/shared/service/active-component-registry.service.ts +0 -134
- package/src/app/modules/shared/service/component-data.service.ts +0 -25
- package/src/app/modules/shared/service/controlled-field-data.service.ts +0 -37
- package/src/app/modules/shared/service/date-time/custom-date-adapter.ts +0 -19
- package/src/app/modules/shared/service/date-time/date-time.service.ts +0 -30
- package/src/app/modules/shared/service/local-settings.service.ts +0 -22
- package/src/app/modules/shared/service/message-handler.service.ts +0 -35
- package/src/app/modules/shared/service/page-break-paginator.service.ts +0 -78
- package/src/app/modules/shared/shared.module.ts +0 -97
- package/src/app/modules/shared/util/data-context.ts +0 -42
- package/src/app/modules/shared/util/data-object-util.ts +0 -102
- package/src/app/modules/shared/util/handler-context.ts +0 -81
- package/src/app/modules/shared/util/template-object-util.ts +0 -21
- package/src/assets/.gitkeep +0 -0
- package/src/environments/environment.prod.ts +0 -5
- package/src/environments/environment.ts +0 -18
- package/src/main.ts +0 -28
- package/src/polyfills.ts +0 -65
- package/src/styles-own.scss +0 -352
- package/src/styles.scss +0 -116
- package/src/test.ts +0 -25
- package/tsconfig.app.json +0 -16
- package/tsconfig.base.json +0 -20
- package/tsconfig.json +0 -20
- package/tsconfig.spec.json +0 -18
- package/tslint.json +0 -152
- /package/{src/assets/fonts/MaterialIcons-Regular.eot → MaterialIcons-Regular.eot} +0 -0
- /package/{src/assets/fonts/MaterialIcons-Regular.ttf → MaterialIcons-Regular.ttf} +0 -0
- /package/{src/assets/fonts/MaterialIcons-Regular.woff → MaterialIcons-Regular.woff} +0 -0
- /package/{src/assets/fonts/MaterialIcons-Regular.woff2 → MaterialIcons-Regular.woff2} +0 -0
- /package/{src/assets → assets}/i18n-cee/en.json +0 -0
- /package/{src/assets → assets}/i18n-cee/hu.json +0 -0
- /package/{src/assets → assets}/images/bmir-logo.png +0 -0
- /package/{src/assets → assets}/images/cedar-logo-80x80.png +0 -0
- /package/{src/favicon.ico → favicon.ico} +0 -0
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import {JsonSchema} from '../models/json-schema.model';
|
|
2
|
-
import {CedarModel} from '../models/cedar-model.model';
|
|
3
|
-
import {JavascriptTypes} from '../models/javascript-types.model';
|
|
4
|
-
import {CedarComponent} from '../models/component/cedar-component.model';
|
|
5
|
-
import {MultiElementComponent} from '../models/element/multi-element-component.model';
|
|
6
|
-
import {CedarTemplate} from '../models/template/cedar-template.model';
|
|
7
|
-
import {NullTemplate} from '../models/template/null-template.model';
|
|
8
|
-
import {EmptyTemplate} from '../models/template/empty-template.model';
|
|
9
|
-
import {TemplateComponent} from '../models/template/template-component.model';
|
|
10
|
-
import {MultiFieldComponent} from '../models/field/multi-field-component.model';
|
|
11
|
-
import {SingleFieldComponent} from '../models/field/single-field-component.model';
|
|
12
|
-
import {SingleElementComponent} from '../models/element/single-element-component.model';
|
|
13
|
-
import {MultiComponent} from '../models/component/multi-component.model';
|
|
14
|
-
import {ElementComponent} from '../models/component/element-component.model';
|
|
15
|
-
import {FieldComponent} from '../models/component/field-component.model';
|
|
16
|
-
import {ChoiceOption} from '../models/info/choice-option.model';
|
|
17
|
-
import {CedarInputTemplate} from '../models/cedar-input-template.model';
|
|
18
|
-
import {StaticFieldComponent} from '../models/static/static-field-component.model';
|
|
19
|
-
import {ComponentTypeHandler} from '../handler/component-type.handler';
|
|
20
|
-
import {InputType} from '../models/input-type.model';
|
|
21
|
-
import {TemplateObjectUtil} from '../util/template-object-util';
|
|
22
|
-
|
|
23
|
-
export class TemplateRepresentationFactory {
|
|
24
|
-
|
|
25
|
-
static create(inputTemplate: CedarInputTemplate, collapseStaticComponents: boolean): TemplateComponent {
|
|
26
|
-
if (inputTemplate === null) {
|
|
27
|
-
return new NullTemplate();
|
|
28
|
-
} else {
|
|
29
|
-
const template = new CedarTemplate();
|
|
30
|
-
TemplateRepresentationFactory.wrap(inputTemplate, inputTemplate, template, [], collapseStaticComponents);
|
|
31
|
-
TemplateRepresentationFactory.extractTemplateLabels(inputTemplate, template);
|
|
32
|
-
TemplateRepresentationFactory.extractPageBreakPages(template);
|
|
33
|
-
return template;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static extractPageBreakPages(template: CedarTemplate): void {
|
|
38
|
-
const pages = [];
|
|
39
|
-
let page = [];
|
|
40
|
-
let numPBInRow = 0;
|
|
41
|
-
|
|
42
|
-
template.children.forEach((child, index) => {
|
|
43
|
-
// encountered page-break component
|
|
44
|
-
if (child instanceof StaticFieldComponent && (child as StaticFieldComponent).basicInfo.inputType === InputType.pageBreak) {
|
|
45
|
-
if (page.length) {
|
|
46
|
-
pages.push(page);
|
|
47
|
-
}
|
|
48
|
-
// if page-break is the last component, always add an empty page
|
|
49
|
-
if (index === template.children.length - 1) {
|
|
50
|
-
pages.push([new EmptyTemplate()]);
|
|
51
|
-
} else {
|
|
52
|
-
numPBInRow++;
|
|
53
|
-
}
|
|
54
|
-
page = [];
|
|
55
|
-
} else {
|
|
56
|
-
page.push(child);
|
|
57
|
-
|
|
58
|
-
if (index === template.children.length - 1) {
|
|
59
|
-
pages.push(page);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// add empty pages corresponding to: (number of page breaks in a row - 1)
|
|
63
|
-
for (let i = 0; i < numPBInRow - 1; i++) {
|
|
64
|
-
pages.push([new EmptyTemplate()]);
|
|
65
|
-
}
|
|
66
|
-
numPBInRow = 0;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
template.pageBreakChildren = pages;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private static isFragmentMulti(templateFragment: object): boolean {
|
|
73
|
-
const fragmentType = templateFragment[CedarModel.type];
|
|
74
|
-
|
|
75
|
-
if (fragmentType === JavascriptTypes.object) {
|
|
76
|
-
return false;
|
|
77
|
-
} else if (fragmentType === JavascriptTypes.array) {
|
|
78
|
-
return true;
|
|
79
|
-
} else {
|
|
80
|
-
throw new Error(
|
|
81
|
-
'Invalid node value of ' + CedarModel.type + '. Value found:"' + fragmentType + '". ' +
|
|
82
|
-
'Expected "' + JavascriptTypes.object + '" or "' + JavascriptTypes.array + '"!'
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private static wrap(templateJsonObj: object, parentJsonObj: object, component: CedarComponent, parentPath: string[], collapseStaticComponents: boolean): void {
|
|
88
|
-
// const propertyNames: string[] = TemplateRepresentationFactory.getFilteredSchemaPropertyNames(templateJsonObj);
|
|
89
|
-
// console.log(propertyNames);
|
|
90
|
-
const propertyNames: string[] = TemplateRepresentationFactory.getOrderedPropertyNames(templateJsonObj);
|
|
91
|
-
for (const name of propertyNames) {
|
|
92
|
-
const templateFragment = templateJsonObj[JsonSchema.properties][name];
|
|
93
|
-
|
|
94
|
-
const isMulti: boolean = TemplateRepresentationFactory.isFragmentMulti(templateFragment);
|
|
95
|
-
|
|
96
|
-
const parentDataNode: object = TemplateRepresentationFactory.getDataNode(parentJsonObj);
|
|
97
|
-
const dataNode: object = TemplateRepresentationFactory.getDataNode(templateFragment);
|
|
98
|
-
const fragmentAtType = dataNode[JsonSchema.atType];
|
|
99
|
-
let r: CedarComponent = null;
|
|
100
|
-
|
|
101
|
-
const myPath: string[] = parentPath.slice();
|
|
102
|
-
myPath.push(name);
|
|
103
|
-
|
|
104
|
-
if (fragmentAtType === CedarModel.templateFieldType) {
|
|
105
|
-
if (isMulti) {
|
|
106
|
-
r = new MultiFieldComponent();
|
|
107
|
-
} else {
|
|
108
|
-
r = new SingleFieldComponent();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
TemplateRepresentationFactory.extractValueConstraints(dataNode, r as FieldComponent);
|
|
112
|
-
TemplateRepresentationFactory.extractLabels(dataNode, parentDataNode, name, r as FieldComponent);
|
|
113
|
-
} else if (fragmentAtType === CedarModel.templateElementType) {
|
|
114
|
-
if (isMulti) {
|
|
115
|
-
r = new MultiElementComponent();
|
|
116
|
-
} else {
|
|
117
|
-
r = new SingleElementComponent();
|
|
118
|
-
}
|
|
119
|
-
TemplateRepresentationFactory.extractLabels(dataNode, parentDataNode, name, r as FieldComponent);
|
|
120
|
-
TemplateRepresentationFactory.wrap(dataNode, templateJsonObj, r, myPath, collapseStaticComponents);
|
|
121
|
-
} else if (fragmentAtType === CedarModel.templateStaticFieldType) {
|
|
122
|
-
r = new StaticFieldComponent();
|
|
123
|
-
TemplateRepresentationFactory.extractStaticData(dataNode, parentDataNode, name, r as StaticFieldComponent);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (r !== null) {
|
|
127
|
-
const wrapperElement: ElementComponent = component as ElementComponent;
|
|
128
|
-
wrapperElement.children.push(r);
|
|
129
|
-
r.name = name;
|
|
130
|
-
r.path = myPath;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (isMulti) {
|
|
134
|
-
const mr = r as MultiComponent;
|
|
135
|
-
TemplateRepresentationFactory.extractMultiInfo(templateFragment, mr);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (collapseStaticComponents) {
|
|
140
|
-
this.collapseStaticFieldsIntoNextFieldOrElement(component);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// private static getFilteredSchemaPropertyNames(jsonObj: object): string[] {
|
|
145
|
-
// const names: string[] = [];
|
|
146
|
-
// if (jsonObj.hasOwnProperty(JsonSchema.properties)) {
|
|
147
|
-
// const prMap = jsonObj[JsonSchema.properties];
|
|
148
|
-
// if (prMap instanceof Object) {
|
|
149
|
-
// for (const name of Object.keys(prMap)) {
|
|
150
|
-
// if (!JsonSchema.builtInProperties.has(name)) {
|
|
151
|
-
// names.push(name);
|
|
152
|
-
// }
|
|
153
|
-
// }
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
// return names;
|
|
157
|
-
// }
|
|
158
|
-
|
|
159
|
-
private static getOrderedPropertyNames(jsonObj: object): string[] {
|
|
160
|
-
const order: string[] = [];
|
|
161
|
-
if (jsonObj.hasOwnProperty(CedarModel.ui)) {
|
|
162
|
-
const uiMap = jsonObj[CedarModel.ui];
|
|
163
|
-
if (uiMap.hasOwnProperty(CedarModel.order)) {
|
|
164
|
-
return uiMap[CedarModel.order];
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return order;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private static getDataNode(templateFragment: object): object {
|
|
171
|
-
if (templateFragment == null) {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
const isMulti: boolean = TemplateRepresentationFactory.isFragmentMulti(templateFragment);
|
|
175
|
-
if (isMulti) {
|
|
176
|
-
return templateFragment[CedarModel.items];
|
|
177
|
-
} else {
|
|
178
|
-
return templateFragment;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
private static extractValueConstraints(dataNode: object, fc: FieldComponent): void {
|
|
183
|
-
fc.basicInfo.inputType = dataNode[CedarModel.ui][CedarModel.inputType];
|
|
184
|
-
|
|
185
|
-
if (dataNode[CedarModel.ui][CedarModel.inputType] === InputType.temporal) {
|
|
186
|
-
if (dataNode[CedarModel.ui].hasOwnProperty(CedarModel.timezoneEnabled)) {
|
|
187
|
-
fc.basicInfo.timezoneEnabled = dataNode[CedarModel.ui][CedarModel.timezoneEnabled];
|
|
188
|
-
}
|
|
189
|
-
if (dataNode[CedarModel.ui].hasOwnProperty(CedarModel.inputTimeFormat)) {
|
|
190
|
-
fc.basicInfo.inputTimeFormat = dataNode[CedarModel.ui][CedarModel.inputTimeFormat];
|
|
191
|
-
}
|
|
192
|
-
if (dataNode[CedarModel.ui].hasOwnProperty(CedarModel.temporalGranularity)) {
|
|
193
|
-
fc.basicInfo.temporalGranularity = dataNode[CedarModel.ui][CedarModel.temporalGranularity];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (dataNode[CedarModel.ui].hasOwnProperty(CedarModel.temporalGranularity)) {
|
|
198
|
-
fc.basicInfo.temporalGranularity = dataNode[CedarModel.ui][CedarModel.temporalGranularity];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (TemplateObjectUtil.hasValueConstraints(dataNode)) {
|
|
202
|
-
const vc: object = dataNode[CedarModel.valueConstraints];
|
|
203
|
-
fc.valueInfo.requiredValue = vc[CedarModel.requiredValue];
|
|
204
|
-
fc.valueInfo.defaultValue = vc[CedarModel.defaultValue];
|
|
205
|
-
fc.valueInfo.minLength = vc[CedarModel.minLength];
|
|
206
|
-
fc.valueInfo.maxLength = vc[CedarModel.maxLength];
|
|
207
|
-
|
|
208
|
-
if (vc.hasOwnProperty(CedarModel.temporalType)) {
|
|
209
|
-
fc.valueInfo.temporalType = vc[CedarModel.temporalType];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
fc.numberInfo.numberType = vc[CedarModel.numberType];
|
|
213
|
-
fc.numberInfo.unitOfMeasure = vc[CedarModel.unitOfMeasure];
|
|
214
|
-
fc.numberInfo.minValue = vc[CedarModel.minValue];
|
|
215
|
-
fc.numberInfo.maxValue = vc[CedarModel.maxValue];
|
|
216
|
-
fc.numberInfo.decimalPlace = vc[CedarModel.decimalPlace];
|
|
217
|
-
fc.choiceInfo.multipleChoice = vc[CedarModel.multipleChoice];
|
|
218
|
-
|
|
219
|
-
if (vc[CedarModel.literals] !== undefined) {
|
|
220
|
-
for (const pair of vc[CedarModel.literals]) {
|
|
221
|
-
const option = new ChoiceOption();
|
|
222
|
-
option.label = pair[CedarModel.label];
|
|
223
|
-
option.selectedByDefault = pair[CedarModel.selectedByDefault];
|
|
224
|
-
fc.choiceInfo.choices.push(option);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (TemplateObjectUtil.hasControlledInfo(dataNode)) {
|
|
229
|
-
fc.basicInfo.inputType = InputType.controlled;
|
|
230
|
-
fc.controlledInfo.ontologies = vc[CedarModel.ontologies];
|
|
231
|
-
fc.controlledInfo.valueSets = vc[CedarModel.valueSets];
|
|
232
|
-
fc.controlledInfo.classes = vc[CedarModel.classes];
|
|
233
|
-
fc.controlledInfo.branches = vc[CedarModel.branches];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private static extractLabels(dataNode: object, parentDataNode: object, name: string, fc: FieldComponent): void {
|
|
239
|
-
fc.labelInfo.preferredLabel = dataNode[CedarModel.skosPrefLabel];
|
|
240
|
-
fc.labelInfo.description = dataNode[JsonSchema.schemaDescription];
|
|
241
|
-
fc.labelInfo.label = dataNode[JsonSchema.schemaName];
|
|
242
|
-
if (parentDataNode != null) {
|
|
243
|
-
if (fc.labelInfo.description == null || fc.labelInfo.description === 'Help Text') {
|
|
244
|
-
if (parentDataNode[CedarModel.ui][CedarModel.propertyDescriptions] !== undefined) {
|
|
245
|
-
fc.labelInfo.description = parentDataNode[CedarModel.ui][CedarModel.propertyDescriptions][name];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
if (fc.labelInfo.label == null || fc.labelInfo.label === name) {
|
|
249
|
-
if (parentDataNode[CedarModel.ui][CedarModel.propertyLabels] !== undefined) {
|
|
250
|
-
fc.labelInfo.label = parentDataNode[CedarModel.ui][CedarModel.propertyLabels][name];
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
private static extractMultiInfo(templateFragment: object, mr: MultiComponent): void {
|
|
257
|
-
mr.multiInfo.minItems = templateFragment[CedarModel.minItems];
|
|
258
|
-
mr.multiInfo.maxItems = templateFragment[CedarModel.maxItems];
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
private static extractTemplateLabels(templateJsonObj: object, template: CedarTemplate): void {
|
|
262
|
-
template.labelInfo.label = templateJsonObj[JsonSchema.schemaName];
|
|
263
|
-
template.labelInfo.description = templateJsonObj[JsonSchema.schemaDescription];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
private static extractStaticData(dataNode: object, parentDataNode: object, name: string, sfc: StaticFieldComponent): void {
|
|
267
|
-
sfc.basicInfo.inputType = dataNode[CedarModel.ui][CedarModel.inputType];
|
|
268
|
-
sfc.labelInfo.preferredLabel = dataNode[CedarModel.skosPrefLabel];
|
|
269
|
-
sfc.contentInfo.content = dataNode[CedarModel.ui][CedarModel.content];
|
|
270
|
-
sfc.labelInfo.description = dataNode[JsonSchema.schemaDescription];
|
|
271
|
-
sfc.labelInfo.label = dataNode[JsonSchema.schemaName];
|
|
272
|
-
if (parentDataNode != null) {
|
|
273
|
-
if (sfc.labelInfo.description == null || sfc.labelInfo.description === 'Help Text') {
|
|
274
|
-
if (parentDataNode[CedarModel.ui][CedarModel.propertyDescriptions] !== undefined) {
|
|
275
|
-
sfc.labelInfo.description = parentDataNode[CedarModel.ui][CedarModel.propertyDescriptions][name];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (sfc.labelInfo.label == null || sfc.labelInfo.label === name) {
|
|
279
|
-
if (parentDataNode[CedarModel.ui][CedarModel.propertyLabels] !== undefined) {
|
|
280
|
-
sfc.labelInfo.label = parentDataNode[CedarModel.ui][CedarModel.propertyLabels][name];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Group RTF/image/video fields into consecutive pairs. Any pair gets combined
|
|
287
|
-
// and displayed inline wherever it's located.
|
|
288
|
-
// If the RTF/image/video field is odd (not paired with another RTF/image/video),
|
|
289
|
-
// wrap this field into the next dynamic field/element
|
|
290
|
-
private static collapseStaticFieldsIntoNextFieldOrElement(component: CedarComponent): void {
|
|
291
|
-
// re-iterate, inject static components (images) into the next dynamic components
|
|
292
|
-
// but only if they aren't paired with other like fields
|
|
293
|
-
if (ComponentTypeHandler.isContainerComponent(component)) {
|
|
294
|
-
const elementComponent = component as ElementComponent;
|
|
295
|
-
let prevChild: CedarComponent = null;
|
|
296
|
-
const newChildren: CedarComponent[] = [];
|
|
297
|
-
let isStaticPair = false;
|
|
298
|
-
|
|
299
|
-
for (let i = 0; i < elementComponent.children.length; i++) {
|
|
300
|
-
const currentChild: CedarComponent = elementComponent.children[i];
|
|
301
|
-
|
|
302
|
-
if (ComponentTypeHandler.isFieldOrElement(currentChild) &&
|
|
303
|
-
ComponentTypeHandler.isStaticContentComponent(prevChild) && !isStaticPair) {
|
|
304
|
-
currentChild.linkedStaticFieldComponent = prevChild as StaticFieldComponent;
|
|
305
|
-
newChildren.pop();
|
|
306
|
-
newChildren.push(currentChild);
|
|
307
|
-
} else {
|
|
308
|
-
newChildren.push(currentChild);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (!isStaticPair && ComponentTypeHandler.isStaticContentComponent(currentChild) &&
|
|
312
|
-
ComponentTypeHandler.isStaticContentComponent(prevChild)) {
|
|
313
|
-
isStaticPair = true;
|
|
314
|
-
} else if (isStaticPair) {
|
|
315
|
-
isStaticPair = false;
|
|
316
|
-
}
|
|
317
|
-
prevChild = currentChild;
|
|
318
|
-
}
|
|
319
|
-
elementComponent.children = newChildren;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {CedarComponent} from '../models/component/cedar-component.model';
|
|
2
|
-
import {SingleFieldComponent} from '../models/field/single-field-component.model';
|
|
3
|
-
import {MultiFieldComponent} from '../models/field/multi-field-component.model';
|
|
4
|
-
import {StaticFieldComponent} from '../models/static/static-field-component.model';
|
|
5
|
-
import {InputType} from '../models/input-type.model';
|
|
6
|
-
import {CedarTemplate} from '../models/template/cedar-template.model';
|
|
7
|
-
import {SingleElementComponent} from '../models/element/single-element-component.model';
|
|
8
|
-
import {MultiElementComponent} from '../models/element/multi-element-component.model';
|
|
9
|
-
|
|
10
|
-
export class ComponentTypeHandler {
|
|
11
|
-
|
|
12
|
-
public static isImage(component: CedarComponent): boolean {
|
|
13
|
-
return component instanceof StaticFieldComponent && component.basicInfo.inputType === InputType.image;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static isYoutube(component: CedarComponent): boolean {
|
|
17
|
-
return component instanceof StaticFieldComponent && component.basicInfo.inputType === InputType.youtube;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public static isRichText(component: CedarComponent): boolean {
|
|
21
|
-
return component instanceof StaticFieldComponent && component.basicInfo.inputType === InputType.richText;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public static isStaticContentComponent(component: CedarComponent): boolean {
|
|
25
|
-
return this.isImage(component) || this.isYoutube(component) || this.isRichText(component);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public static isField(component: CedarComponent): boolean {
|
|
29
|
-
return component instanceof SingleFieldComponent || component instanceof MultiFieldComponent;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public static isElement(component: CedarComponent): boolean {
|
|
33
|
-
return component instanceof SingleElementComponent || component instanceof MultiElementComponent;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static isContainerComponent(component: CedarComponent): boolean {
|
|
37
|
-
return component instanceof CedarTemplate || component instanceof SingleElementComponent || component instanceof MultiElementComponent;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static isTemplate(component: CedarComponent): boolean {
|
|
41
|
-
return component instanceof CedarTemplate;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static isFieldOrElement(component: CedarComponent): boolean {
|
|
45
|
-
return this.isField(component) || this.isElement(component);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static isMulti(component: CedarComponent): boolean {
|
|
49
|
-
return component instanceof MultiFieldComponent || component instanceof MultiElementComponent;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import {TemplateComponent} from '../models/template/template-component.model';
|
|
2
|
-
import {CedarComponent} from '../models/component/cedar-component.model';
|
|
3
|
-
import {SingleElementComponent} from '../models/element/single-element-component.model';
|
|
4
|
-
import {MultiElementComponent} from '../models/element/multi-element-component.model';
|
|
5
|
-
import {CedarTemplate} from '../models/template/cedar-template.model';
|
|
6
|
-
import {ElementComponent} from '../models/component/element-component.model';
|
|
7
|
-
import {SingleFieldComponent} from '../models/field/single-field-component.model';
|
|
8
|
-
import {MultiFieldComponent} from '../models/field/multi-field-component.model';
|
|
9
|
-
import {FieldComponent} from '../models/component/field-component.model';
|
|
10
|
-
import {JsonSchema} from '../models/json-schema.model';
|
|
11
|
-
import * as _ from 'lodash-es';
|
|
12
|
-
import {InstanceExtractData} from '../models/instance-extract-data.model';
|
|
13
|
-
import {InstanceFullData} from '../models/instance-full-data.model';
|
|
14
|
-
import {DataObjectUtil} from '../util/data-object-util';
|
|
15
|
-
import {MultiInstanceObjectHandler} from './multi-instance-object.handler';
|
|
16
|
-
import {CedarInputTemplate} from '../models/cedar-input-template.model';
|
|
17
|
-
import {DataObjectBuildingMode} from '../models/enum/data-object-building-mode.model';
|
|
18
|
-
|
|
19
|
-
export class DataObjectBuilderHandler {
|
|
20
|
-
|
|
21
|
-
private dataObject: object;
|
|
22
|
-
private dataObjectFull: object;
|
|
23
|
-
private templateJsonObj: object;
|
|
24
|
-
private templateRepresentation: TemplateComponent;
|
|
25
|
-
private multiInstanceObjectService: MultiInstanceObjectHandler;
|
|
26
|
-
|
|
27
|
-
static getSubTemplate(template: CedarInputTemplate, path: string[]): CedarInputTemplate {
|
|
28
|
-
if (path.length === 0) {
|
|
29
|
-
return template;
|
|
30
|
-
}
|
|
31
|
-
const firstPath = path[0];
|
|
32
|
-
const remainingPath = path.slice(1);
|
|
33
|
-
const subTemplate = DataObjectUtil.getSafeSubTemplate(template, firstPath);
|
|
34
|
-
return this.getSubTemplate(subTemplate, remainingPath);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public static buildRecursively(component: CedarComponent, dataObject: InstanceExtractData, templateJsonObj: CedarInputTemplate, buildingMode: DataObjectBuildingMode): void {
|
|
38
|
-
let ret = null;
|
|
39
|
-
if (templateJsonObj != null) {
|
|
40
|
-
DataObjectBuilderHandler.addContext(component, dataObject, templateJsonObj, buildingMode);
|
|
41
|
-
}
|
|
42
|
-
if (component instanceof SingleElementComponent || component instanceof MultiElementComponent || component instanceof CedarTemplate) {
|
|
43
|
-
const iterableComponent: ElementComponent = component as ElementComponent;
|
|
44
|
-
const targetName = iterableComponent.name;
|
|
45
|
-
if (component instanceof MultiElementComponent) {
|
|
46
|
-
const multiElement: MultiElementComponent = component as MultiElementComponent;
|
|
47
|
-
dataObject[targetName] = DataObjectUtil.getEmptyList();
|
|
48
|
-
if (multiElement.multiInfo.minItems > 0) {
|
|
49
|
-
const dummyTargetObject: object = DataObjectUtil.getEmptyObject();
|
|
50
|
-
const subTemplate = DataObjectUtil.getSafeSubTemplate(templateJsonObj, targetName);
|
|
51
|
-
for (const childComponent of iterableComponent.children) {
|
|
52
|
-
DataObjectBuilderHandler.buildRecursively(childComponent, dummyTargetObject, subTemplate, buildingMode);
|
|
53
|
-
}
|
|
54
|
-
for (let idx = 0; idx < multiElement.multiInfo.minItems; idx++) {
|
|
55
|
-
const clone = _.cloneDeep(dummyTargetObject as any);
|
|
56
|
-
dataObject[targetName].push(clone);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
dataObject[targetName] = DataObjectUtil.getEmptyObject();
|
|
61
|
-
const subTemplate = DataObjectUtil.getSafeSubTemplate(templateJsonObj, targetName);
|
|
62
|
-
for (const childComponent of iterableComponent.children) {
|
|
63
|
-
DataObjectBuilderHandler.buildRecursively(childComponent, dataObject[targetName], subTemplate, buildingMode);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
ret = dataObject[targetName];
|
|
67
|
-
}
|
|
68
|
-
if (component instanceof SingleFieldComponent || component instanceof MultiFieldComponent) {
|
|
69
|
-
const nonIterableComponent = component as FieldComponent;
|
|
70
|
-
const targetName = nonIterableComponent.name;
|
|
71
|
-
if (component instanceof MultiFieldComponent) {
|
|
72
|
-
const multiField: MultiFieldComponent = component as MultiFieldComponent;
|
|
73
|
-
dataObject[targetName] = DataObjectUtil.getEmptyList();
|
|
74
|
-
if (multiField.multiInfo.minItems > 0) {
|
|
75
|
-
const subTemplate = DataObjectUtil.getSafeSubTemplate(templateJsonObj, targetName);
|
|
76
|
-
for (let idx = 0; idx < multiField.multiInfo.minItems; idx++) {
|
|
77
|
-
dataObject[targetName].push(DataObjectUtil.getEmptyValueWrapper(subTemplate, buildingMode));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
const subTemplate = DataObjectUtil.getSafeSubTemplate(templateJsonObj, targetName);
|
|
82
|
-
dataObject[targetName] = DataObjectUtil.getEmptyValueWrapper(subTemplate, buildingMode);
|
|
83
|
-
}
|
|
84
|
-
ret = dataObject[targetName];
|
|
85
|
-
}
|
|
86
|
-
return ret;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public static setCurrentCountToMinRecursively(component: CedarComponent, path: string[]): void {
|
|
90
|
-
if (path.length === 0) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const firstPath = path[0];
|
|
94
|
-
const remainingPath = path.slice(1);
|
|
95
|
-
if (component instanceof SingleElementComponent) {
|
|
96
|
-
const singleElement: SingleElementComponent = component as SingleElementComponent;
|
|
97
|
-
for (const childComponent of singleElement.children) {
|
|
98
|
-
DataObjectBuilderHandler.setCurrentCountToMinRecursively(childComponent, remainingPath);
|
|
99
|
-
}
|
|
100
|
-
} else if (component instanceof MultiElementComponent) {
|
|
101
|
-
const multiElement: MultiElementComponent = component as MultiElementComponent;
|
|
102
|
-
const min = multiElement.multiInfo.getSafeMinItems();
|
|
103
|
-
if (min === 0) {
|
|
104
|
-
multiElement.multiInfo.minItems = 1;
|
|
105
|
-
}
|
|
106
|
-
for (const childComponent of multiElement.children) {
|
|
107
|
-
DataObjectBuilderHandler.setCurrentCountToMinRecursively(childComponent, remainingPath);
|
|
108
|
-
}
|
|
109
|
-
} else if (component instanceof MultiFieldComponent) {
|
|
110
|
-
const multiField: MultiFieldComponent = component as MultiFieldComponent;
|
|
111
|
-
const min = multiField.multiInfo.getSafeMinItems();
|
|
112
|
-
if (min === 0) {
|
|
113
|
-
multiField.multiInfo.minItems = 1;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private static addContext(component: CedarComponent, dataObject: InstanceExtractData, templateJsonObj: CedarInputTemplate, buildingMode: DataObjectBuildingMode): void {
|
|
119
|
-
if (buildingMode === DataObjectBuildingMode.INCLUDE_CONTEXT) {
|
|
120
|
-
const props = templateJsonObj[JsonSchema.properties];
|
|
121
|
-
const propsContext = props[JsonSchema.atContext];
|
|
122
|
-
const propsContextProps = propsContext[JsonSchema.properties];
|
|
123
|
-
const p: object = {};
|
|
124
|
-
for (const key of Object.keys(propsContextProps)) {
|
|
125
|
-
p[key] = DataObjectUtil.convertTemplateContextNode(propsContextProps[key]);
|
|
126
|
-
}
|
|
127
|
-
dataObject[JsonSchema.atContext] = p;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
injectMultiInstanceService(multiInstanceObjectService: MultiInstanceObjectHandler): void {
|
|
132
|
-
this.multiInstanceObjectService = multiInstanceObjectService;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
buildNewExtractDataObject(templateRepresentation: TemplateComponent, templateJsonObj: CedarInputTemplate): InstanceExtractData {
|
|
136
|
-
this.templateJsonObj = templateJsonObj;
|
|
137
|
-
this.templateRepresentation = templateRepresentation;
|
|
138
|
-
this.dataObject = new InstanceExtractData();
|
|
139
|
-
this.buildNewByIterating(this.dataObject, templateJsonObj, DataObjectBuildingMode.EXCLUDE_CONTEXT);
|
|
140
|
-
return this.dataObject;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
buildNewFullDataObject(templateRepresentation: TemplateComponent, templateJsonObj: CedarInputTemplate): InstanceFullData {
|
|
144
|
-
this.templateJsonObj = templateJsonObj;
|
|
145
|
-
this.templateRepresentation = templateRepresentation;
|
|
146
|
-
this.dataObjectFull = new InstanceFullData();
|
|
147
|
-
this.buildNewByIterating(this.dataObjectFull, templateJsonObj, DataObjectBuildingMode.INCLUDE_CONTEXT);
|
|
148
|
-
return this.dataObjectFull;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
private buildNewByIterating(dataObject: InstanceExtractData, templateJsonObj: CedarInputTemplate, buildingMode: DataObjectBuildingMode): void {
|
|
152
|
-
if (this.templateRepresentation != null && this.templateRepresentation.children != null) {
|
|
153
|
-
for (const childComponent of this.templateRepresentation.children) {
|
|
154
|
-
DataObjectBuilderHandler.buildRecursively(childComponent, dataObject, templateJsonObj, buildingMode);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
}
|