cedar-embeddable-editor 0.9.0
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/.browserslistrc +18 -0
- package/.editorconfig +16 -0
- package/README.md +302 -0
- package/angular.json +153 -0
- package/cedar-embeddable-editor-0.9.0.tgz +0 -0
- package/e2e/protractor.conf.js +36 -0
- package/e2e/src/app.e2e-spec.ts +23 -0
- package/e2e/src/app.po.ts +11 -0
- package/e2e/tsconfig.json +14 -0
- package/karma.conf.js +32 -0
- package/license.txt +26 -0
- package/package.json +61 -0
- package/src/app/app.component.dev.ts +74 -0
- package/src/app/app.component.html +5 -0
- package/src/app/app.component.prod.ts +76 -0
- package/src/app/app.component.scss +1 -0
- package/src/app/app.module.dev.ts +58 -0
- package/src/app/app.module.prod.ts +56 -0
- 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 +24 -0
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.ts +39 -0
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.html +25 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.ts +91 -0
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.html +8 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.ts +104 -0
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.html +22 -0
- 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 +24 -0
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.ts +135 -0
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.html +44 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.ts +451 -0
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.html +16 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.ts +91 -0
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.html +16 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.ts +92 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.html +18 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.scss +5 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.ts +78 -0
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.html +15 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.ts +169 -0
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.html +15 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.ts +94 -0
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.html +19 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.ts +108 -0
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.html +25 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.ts +125 -0
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.html +8 -0
- 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 +24 -0
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.ts +40 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.html +20 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.scss +24 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.ts +36 -0
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.html +2 -0
- 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 +25 -0
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.ts +35 -0
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.html +8 -0
- 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 +24 -0
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.ts +39 -0
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.html +6 -0
- 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 +24 -0
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.ts +42 -0
- package/src/app/modules/input-types/input-types.module.ts +139 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.html +13 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.scss +12 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.ts +42 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.html +117 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.scss +5 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.ts +101 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.html +22 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.scss +23 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.spec.ts +24 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.ts +139 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.html +56 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.scss +13 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.ts +184 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.html +15 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.scss +2 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.ts +240 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.html +35 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.scss +41 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.ts +282 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.html +46 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.scss +7 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.spec.ts +25 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.ts +100 -0
- package/src/app/modules/shared/components/file-uploader/bytes/bytes.pipe.spec.ts +33 -0
- package/src/app/modules/shared/components/file-uploader/bytes/bytes.pipe.ts +16 -0
- package/src/app/modules/shared/components/file-uploader/file-upload-input-for/file-upload-input-for.directive.spec.ts +54 -0
- package/src/app/modules/shared/components/file-uploader/file-upload-input-for/file-upload-input-for.directive.ts +67 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.html +26 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.scss +55 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.spec.ts +25 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.ts +67 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.html +42 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.scss +31 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.spec.ts +177 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.ts +145 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.service.ts +21 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.html +1 -0
- 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 +59 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.ts +139 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.service.spec.ts +33 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.service.ts +17 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload.module.ts +35 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload.type.ts +24 -0
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.html +18 -0
- 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 +23 -0
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.ts +10 -0
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.html +16 -0
- 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 +25 -0
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.ts +89 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.html +19 -0
- 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 +25 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.ts +66 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.service.ts +175 -0
- package/src/app/modules/shared/components/source-panels/source-panels.component.html +98 -0
- 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 +25 -0
- package/src/app/modules/shared/components/source-panels/source-panels.component.ts +36 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.html +17 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.scss +110 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.spec.ts +25 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.ts +16 -0
- package/src/app/modules/shared/components/static-header/static-header.component.html +10 -0
- package/src/app/modules/shared/components/static-header/static-header.component.scss +13 -0
- package/src/app/modules/shared/components/static-header/static-header.component.spec.ts +25 -0
- package/src/app/modules/shared/components/static-header/static-header.component.ts +21 -0
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.html +16 -0
- 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 +25 -0
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.ts +251 -0
- package/src/app/modules/shared/factory/template-representation.factory.ts +323 -0
- package/src/app/modules/shared/handler/component-type.handler.ts +51 -0
- package/src/app/modules/shared/handler/data-object-builder.handler.ts +159 -0
- package/src/app/modules/shared/handler/data-object-data-value.handler.ts +270 -0
- package/src/app/modules/shared/handler/data-object-structure.handler.ts +145 -0
- package/src/app/modules/shared/handler/multi-instance-object.handler.ts +317 -0
- package/src/app/modules/shared/models/cedar-input-template.model.ts +3 -0
- package/src/app/modules/shared/models/cedar-model.model.ts +48 -0
- package/src/app/modules/shared/models/component/cedar-component.model.ts +16 -0
- package/src/app/modules/shared/models/component/component-representation.model.ts +30 -0
- package/src/app/modules/shared/models/component/element-component.model.ts +11 -0
- package/src/app/modules/shared/models/component/field-component.model.ts +23 -0
- package/src/app/modules/shared/models/component/multi-component.model.ts +10 -0
- package/src/app/modules/shared/models/component/null-component.model.ts +20 -0
- package/src/app/modules/shared/models/component/single-component.model.ts +6 -0
- package/src/app/modules/shared/models/element/abstract-element-component.model.ts +26 -0
- package/src/app/modules/shared/models/element/multi-element-component.model.ts +19 -0
- package/src/app/modules/shared/models/element/single-element-component.model.ts +16 -0
- package/src/app/modules/shared/models/enum/data-object-building-mode.model.ts +6 -0
- package/src/app/modules/shared/models/field/abstract-field-component.model.ts +28 -0
- package/src/app/modules/shared/models/field/multi-field-component.model.ts +21 -0
- package/src/app/modules/shared/models/field/single-field-component.model.ts +18 -0
- package/src/app/modules/shared/models/info/basic-info.model.ts +8 -0
- package/src/app/modules/shared/models/info/choice-info.model.ts +9 -0
- package/src/app/modules/shared/models/info/choice-option.model.ts +6 -0
- package/src/app/modules/shared/models/info/content-info.model.ts +5 -0
- package/src/app/modules/shared/models/info/controlled-info.model.ts +8 -0
- package/src/app/modules/shared/models/info/current-multi-info.model.ts +7 -0
- package/src/app/modules/shared/models/info/label-info.model.ts +7 -0
- package/src/app/modules/shared/models/info/multi-info.model.ts +10 -0
- package/src/app/modules/shared/models/info/multi-instance-info.model.ts +20 -0
- package/src/app/modules/shared/models/info/multi-instance-object-info.model.ts +30 -0
- package/src/app/modules/shared/models/info/number-info.model.ts +9 -0
- package/src/app/modules/shared/models/info/value-info.model.ts +9 -0
- package/src/app/modules/shared/models/input-type.model.ts +21 -0
- package/src/app/modules/shared/models/instance-extract-data.model.ts +3 -0
- package/src/app/modules/shared/models/instance-full-data.model.ts +5 -0
- package/src/app/modules/shared/models/javascript-types.model.ts +7 -0
- package/src/app/modules/shared/models/json-schema.model.ts +39 -0
- package/src/app/modules/shared/models/numbers.model.ts +10 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request-parameter-object.ts +8 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request-value-constraints.ts +8 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request.ts +9 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-response-item.ts +10 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-response.ts +13 -0
- package/src/app/modules/shared/models/static/static-field-component.model.ts +24 -0
- package/src/app/modules/shared/models/template/cedar-template.model.ts +24 -0
- package/src/app/modules/shared/models/template/empty-template.model.ts +5 -0
- package/src/app/modules/shared/models/template/null-template.model.ts +23 -0
- package/src/app/modules/shared/models/template/template-component.model.ts +12 -0
- package/src/app/modules/shared/models/temporal.model.ts +13 -0
- package/src/app/modules/shared/models/ui/cedar-ui-component.model.ts +17 -0
- package/src/app/modules/shared/models/xsd.model.ts +11 -0
- package/src/app/modules/shared/pipe/keep-html.pipe.ts +13 -0
- package/src/app/modules/shared/pipe/rdf.pipe.ts +10 -0
- package/src/app/modules/shared/service/active-component-registry.service.ts +134 -0
- package/src/app/modules/shared/service/component-data.service.ts +25 -0
- package/src/app/modules/shared/service/controlled-field-data.service.ts +37 -0
- package/src/app/modules/shared/service/date-time/custom-date-adapter.ts +19 -0
- package/src/app/modules/shared/service/date-time/date-time.service.ts +30 -0
- package/src/app/modules/shared/service/local-settings.service.ts +22 -0
- package/src/app/modules/shared/service/message-handler.service.ts +35 -0
- package/src/app/modules/shared/service/page-break-paginator.service.ts +78 -0
- package/src/app/modules/shared/shared.module.ts +97 -0
- package/src/app/modules/shared/util/data-context.ts +42 -0
- package/src/app/modules/shared/util/data-object-util.ts +102 -0
- package/src/app/modules/shared/util/handler-context.ts +81 -0
- package/src/app/modules/shared/util/template-object-util.ts +21 -0
- package/src/assets/.gitkeep +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.eot +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.ttf +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.woff +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.woff2 +0 -0
- package/src/assets/i18n-cee/en.json +86 -0
- package/src/assets/i18n-cee/hu.json +86 -0
- package/src/assets/images/bmir-logo.png +0 -0
- package/src/assets/images/cedar-logo-80x80.png +0 -0
- package/src/environments/environment.prod.ts +5 -0
- package/src/environments/environment.ts +18 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +16 -0
- package/src/main.ts +28 -0
- package/src/polyfills.ts +65 -0
- package/src/styles-own.scss +352 -0
- package/src/styles.scss +116 -0
- package/src/test.ts +25 -0
- package/tsconfig.app.json +16 -0
- package/tsconfig.base.json +20 -0
- package/tsconfig.json +20 -0
- package/tsconfig.spec.json +18 -0
- package/tslint.json +152 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
|
|
2
|
+
import {FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm, Validators} from '@angular/forms';
|
|
3
|
+
import {ErrorStateMatcher} from '@angular/material/core';
|
|
4
|
+
import {CedarUIComponent} from '../../../shared/models/ui/cedar-ui-component.model';
|
|
5
|
+
import {FieldComponent} from '../../../shared/models/component/field-component.model';
|
|
6
|
+
import {ActiveComponentRegistryService} from '../../../shared/service/active-component-registry.service';
|
|
7
|
+
import {HandlerContext} from '../../../shared/util/handler-context';
|
|
8
|
+
import {ComponentDataService} from '../../../shared/service/component-data.service';
|
|
9
|
+
|
|
10
|
+
export class TextFieldErrorStateMatcher implements ErrorStateMatcher {
|
|
11
|
+
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
|
12
|
+
return !!(control && control.invalid && (control.dirty || control.touched));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'app-cedar-input-link',
|
|
18
|
+
templateUrl: './cedar-input-link.component.html',
|
|
19
|
+
styleUrls: ['./cedar-input-link.component.scss'],
|
|
20
|
+
encapsulation: ViewEncapsulation.None
|
|
21
|
+
})
|
|
22
|
+
export class CedarInputLinkComponent extends CedarUIComponent implements OnInit {
|
|
23
|
+
|
|
24
|
+
component: FieldComponent;
|
|
25
|
+
options: FormGroup;
|
|
26
|
+
inputValueControl = new FormControl(null, null);
|
|
27
|
+
errorStateMatcher = new TextFieldErrorStateMatcher();
|
|
28
|
+
@Input() handlerContext: HandlerContext;
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
fb: FormBuilder,
|
|
32
|
+
public cds: ComponentDataService,
|
|
33
|
+
private activeComponentRegistry: ActiveComponentRegistryService
|
|
34
|
+
) {
|
|
35
|
+
super();
|
|
36
|
+
this.options = fb.group({
|
|
37
|
+
inputValue: this.inputValueControl,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ngOnInit(): void {
|
|
42
|
+
const validators: any[] = [];
|
|
43
|
+
|
|
44
|
+
const reg = '(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?';
|
|
45
|
+
validators.push(Validators.pattern(reg));
|
|
46
|
+
|
|
47
|
+
if (this.component.valueInfo.requiredValue) {
|
|
48
|
+
validators.push(Validators.required);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.inputValueControl = new FormControl(null, validators);
|
|
52
|
+
if (this.component.valueInfo.defaultValue != null) {
|
|
53
|
+
this.setValueUIAndModel(this.component.valueInfo.defaultValue);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Input() set componentToRender(componentToRender: FieldComponent) {
|
|
58
|
+
this.component = componentToRender;
|
|
59
|
+
this.activeComponentRegistry.registerComponent(this.component, this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
inputChanged($event: Event): void {
|
|
63
|
+
let val = ($event.target as HTMLTextAreaElement).value;
|
|
64
|
+
|
|
65
|
+
if (val.length === 0) {
|
|
66
|
+
val = null;
|
|
67
|
+
}
|
|
68
|
+
this.handlerContext.changeValue(this.component, val);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
setCurrentValue(currentValue: any): void {
|
|
72
|
+
this.inputValueControl.setValue(currentValue);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
clearValue(): void {
|
|
76
|
+
this.setValueUIAndModel(null);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private setValueUIAndModel(value: string): void {
|
|
80
|
+
this.inputValueControl.setValue(value);
|
|
81
|
+
this.handlerContext.changeValue(this.component, value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getCharCountHint(): string {
|
|
85
|
+
let len = 0;
|
|
86
|
+
if (this.inputValueControl.value != null) {
|
|
87
|
+
len = this.inputValueControl.value.length;
|
|
88
|
+
}
|
|
89
|
+
const s = '' + len;
|
|
90
|
+
return s;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<form class="form-container" [formGroup]="options">
|
|
2
|
+
<mat-form-field class="full-width">
|
|
3
|
+
<input matInput [formControl]="selectedChoiceInputControl" style="display:none">
|
|
4
|
+
<mat-radio-group [formControl]="selectedChoiceInputControl">
|
|
5
|
+
<div *ngFor="let choice of component.choiceInfo.choices" class="col-md-2">
|
|
6
|
+
<mat-radio-button
|
|
7
|
+
[checked]="choice.selectedByDefault"
|
|
8
|
+
[value]="choice.label"
|
|
9
|
+
(change)="inputChanged($event)"
|
|
10
|
+
>{{choice.label}}</mat-radio-button>
|
|
11
|
+
</div>
|
|
12
|
+
<button type="button" tabindex="0" mat-button *ngIf="selectedChoiceInputControl.value" matSuffix mat-icon-button attr.aria-label="{{'Generic.Clear' | translate}}" (click)="clearValue()">
|
|
13
|
+
<mat-icon>close</mat-icon>
|
|
14
|
+
</button>
|
|
15
|
+
</mat-radio-group>
|
|
16
|
+
<mat-error align="start" *ngIf="selectedChoiceInputControl.getError('required')" class="mat-error">{{'Validation.Required' | translate}}</mat-error>
|
|
17
|
+
</mat-form-field>
|
|
18
|
+
</form>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import {CedarInputMultipleChoiceComponent} from './cedar-input-multiple-choice.component';
|
|
4
|
+
|
|
5
|
+
describe('CedarInputMultipleChoiceComponent', () => {
|
|
6
|
+
let component: CedarInputMultipleChoiceComponent;
|
|
7
|
+
let fixture: ComponentFixture<CedarInputMultipleChoiceComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [CedarInputMultipleChoiceComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(CedarInputMultipleChoiceComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
|
|
2
|
+
import {FieldComponent} from '../../../shared/models/component/field-component.model';
|
|
3
|
+
import {FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm, Validators} from '@angular/forms';
|
|
4
|
+
import {CedarUIComponent} from '../../../shared/models/ui/cedar-ui-component.model';
|
|
5
|
+
import {ActiveComponentRegistryService} from '../../../shared/service/active-component-registry.service';
|
|
6
|
+
import {HandlerContext} from '../../../shared/util/handler-context';
|
|
7
|
+
import {ErrorStateMatcher} from '@angular/material/core';
|
|
8
|
+
import {TextFieldErrorStateMatcher} from '../cedar-input-text/cedar-input-text.component';
|
|
9
|
+
|
|
10
|
+
export class MultipleChoiceErrorStateMatcher implements ErrorStateMatcher {
|
|
11
|
+
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
|
12
|
+
return !!(control && control.invalid && (control.dirty || control.touched));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
@Component({
|
|
16
|
+
selector: 'app-cedar-input-multiple-choice',
|
|
17
|
+
templateUrl: './cedar-input-multiple-choice.component.html',
|
|
18
|
+
styleUrls: ['./cedar-input-multiple-choice.component.scss'],
|
|
19
|
+
encapsulation: ViewEncapsulation.None
|
|
20
|
+
})
|
|
21
|
+
export class CedarInputMultipleChoiceComponent extends CedarUIComponent implements OnInit {
|
|
22
|
+
component: FieldComponent;
|
|
23
|
+
options: FormGroup;
|
|
24
|
+
selectedChoiceInputControl = new FormControl(null, null);
|
|
25
|
+
errorStateMatcher = new MultipleChoiceErrorStateMatcher();
|
|
26
|
+
@Input() handlerContext: HandlerContext;
|
|
27
|
+
|
|
28
|
+
constructor(
|
|
29
|
+
fb: FormBuilder,
|
|
30
|
+
private activeComponentRegistry: ActiveComponentRegistryService
|
|
31
|
+
) {
|
|
32
|
+
super();
|
|
33
|
+
this.options = fb.group({
|
|
34
|
+
selectedChoiceValue: this.selectedChoiceInputControl
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ngOnInit(): void {
|
|
39
|
+
this.populateItemsOnLoad();
|
|
40
|
+
const validators: any[] = [];
|
|
41
|
+
if (this.component.valueInfo.requiredValue) {
|
|
42
|
+
validators.push(Validators.required);
|
|
43
|
+
}
|
|
44
|
+
this.selectedChoiceInputControl = new FormControl(null, validators);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Input() set componentToRender(componentToRender: FieldComponent) {
|
|
48
|
+
this.component = componentToRender;
|
|
49
|
+
this.activeComponentRegistry.registerComponent(this.component, this);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
inputChanged(event): void {
|
|
53
|
+
this.handlerContext.changeValue(this.component, event.value);
|
|
54
|
+
}
|
|
55
|
+
clearValue(): void {
|
|
56
|
+
this.setValueUIAndModel(null);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private setValueUIAndModel(value: string): void {
|
|
60
|
+
this.selectedChoiceInputControl.setValue(value);
|
|
61
|
+
this.handlerContext.changeValue(this.component, value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setCurrentValue(currentValue: any): void {
|
|
65
|
+
this.selectedChoiceInputControl.setValue(currentValue);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private populateItemsOnLoad(): void {
|
|
69
|
+
for (const choice of this.component.choiceInfo.choices) {
|
|
70
|
+
if (choice.selectedByDefault) {
|
|
71
|
+
this.handlerContext.changeValue(this.component, choice.label);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
this.handlerContext.changeValue(this.component, null);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<form class="form-container" [formGroup]="options">
|
|
2
|
+
<mat-form-field class="full-width">
|
|
3
|
+
<!-- <mat-label>{{cds.getRenderingLabelForComponent(component)}}</mat-label>-->
|
|
4
|
+
<input matInput type="number" placeholder="{{'Generic.NumberOnly' | translate}}"
|
|
5
|
+
[formControl]="inputValueControl"
|
|
6
|
+
(input)="inputChanged($event)"
|
|
7
|
+
attr.aria-label="{{cds.getRenderingLabelForComponent(component)}}">
|
|
8
|
+
<span matSuffix>{{unitOfMeasure}}</span>
|
|
9
|
+
<mat-error align="start" *ngIf="inputValueControl.getError('min')" class="mat-error">{{'Validation.Numeric.MinValue' | translate: {constraintMinValue} }}</mat-error>
|
|
10
|
+
<mat-error align="start" *ngIf="inputValueControl.getError('max')" class="mat-error">{{'Validation.Numeric.MaxValue' | translate: {constraintMaxValue} }}</mat-error>
|
|
11
|
+
<mat-error align="start" *ngIf="inputValueControl.getError('pattern')" class="mat-error">{{patternErrorMessage}}.</mat-error>
|
|
12
|
+
<mat-error align="start" *ngIf="inputValueControl.getError('required')" class="mat-error">{{'Validation.Required' | translate}}</mat-error>
|
|
13
|
+
<mat-hint align="end">{{getMinMaxValueHint()}}</mat-hint>
|
|
14
|
+
</mat-form-field>
|
|
15
|
+
</form>
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { CedarInputNumericComponent } from './cedar-input-numeric.component';
|
|
4
|
+
|
|
5
|
+
describe('CedarInputNumericComponent', () => {
|
|
6
|
+
let component: CedarInputNumericComponent;
|
|
7
|
+
let fixture: ComponentFixture<CedarInputNumericComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ CedarInputNumericComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(CedarInputNumericComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
|
|
2
|
+
import {FieldComponent} from '../../../shared/models/component/field-component.model';
|
|
3
|
+
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
|
|
4
|
+
import {ComponentDataService} from '../../../shared/service/component-data.service';
|
|
5
|
+
import {CedarUIComponent} from '../../../shared/models/ui/cedar-ui-component.model';
|
|
6
|
+
import {ActiveComponentRegistryService} from '../../../shared/service/active-component-registry.service';
|
|
7
|
+
import {HandlerContext} from '../../../shared/util/handler-context';
|
|
8
|
+
import {Numbers} from '../../../shared/models/numbers.model';
|
|
9
|
+
import {Xsd} from '../../../shared/models/xsd.model';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'app-cedar-input-numeric',
|
|
13
|
+
templateUrl: './cedar-input-numeric.component.html',
|
|
14
|
+
styleUrls: ['./cedar-input-numeric.component.scss'],
|
|
15
|
+
encapsulation: ViewEncapsulation.None
|
|
16
|
+
})
|
|
17
|
+
export class CedarInputNumericComponent extends CedarUIComponent implements OnInit {
|
|
18
|
+
|
|
19
|
+
component: FieldComponent;
|
|
20
|
+
options: FormGroup;
|
|
21
|
+
inputValueControl = new FormControl(null, Validators.min(10));
|
|
22
|
+
unitOfMeasure: string = null;
|
|
23
|
+
constraintMinValue = null;
|
|
24
|
+
constraintMaxValue = null;
|
|
25
|
+
patternErrorMessage = null;
|
|
26
|
+
@Input() handlerContext: HandlerContext;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
fb: FormBuilder,
|
|
31
|
+
public cds: ComponentDataService,
|
|
32
|
+
private activeComponentRegistry: ActiveComponentRegistryService
|
|
33
|
+
) {
|
|
34
|
+
super();
|
|
35
|
+
this.options = fb.group({
|
|
36
|
+
inputValue: this.inputValueControl,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ngOnInit(): void {
|
|
41
|
+
this.unitOfMeasure = this.component.numberInfo.unitOfMeasure;
|
|
42
|
+
|
|
43
|
+
const validators: any[] = [];
|
|
44
|
+
|
|
45
|
+
this.constraintMinValue = this.component.numberInfo.minValue;
|
|
46
|
+
this.constraintMaxValue = this.component.numberInfo.maxValue;
|
|
47
|
+
|
|
48
|
+
if (this.component.valueInfo.requiredValue) {
|
|
49
|
+
validators.push(Validators.required);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const numberType = this.component.numberInfo.numberType;
|
|
53
|
+
const decimalPlace = this.component.numberInfo.decimalPlace;
|
|
54
|
+
let maxDecimalError = '';
|
|
55
|
+
|
|
56
|
+
if (numberType === Xsd.int) {
|
|
57
|
+
validators.push(Validators.pattern(Numbers.PATTERN_XSD_INT_AND_LONG));
|
|
58
|
+
this.patternErrorMessage = ' The value should be an integer.';
|
|
59
|
+
|
|
60
|
+
if (this.constraintMinValue == null) {
|
|
61
|
+
this.constraintMinValue = Numbers.NUMBER_INT_MIN;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (this.constraintMaxValue == null) {
|
|
65
|
+
this.constraintMaxValue = Numbers.NUMBER_INT_MAX;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (numberType === Xsd.long) {
|
|
70
|
+
validators.push(Validators.pattern(Numbers.PATTERN_XSD_INT_AND_LONG));
|
|
71
|
+
this.patternErrorMessage = ' The value should be a long integer.';
|
|
72
|
+
|
|
73
|
+
if (this.constraintMinValue == null) {
|
|
74
|
+
this.constraintMinValue = Numbers.NUMBER_LONG_MIN;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (this.constraintMaxValue == null) {
|
|
78
|
+
this.constraintMaxValue = Numbers.NUMBER_LONG_MAX;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (numberType === Xsd.float || numberType === Xsd.double) {
|
|
83
|
+
let pattern: string = Numbers.PATTERN_XSD_FLOAT_AND_DOUBLE;
|
|
84
|
+
let maxDig = '';
|
|
85
|
+
|
|
86
|
+
if (decimalPlace != null) {
|
|
87
|
+
maxDig = '' + decimalPlace;
|
|
88
|
+
maxDecimalError = ' maximum ' + decimalPlace + ' decimals.';
|
|
89
|
+
}
|
|
90
|
+
pattern = pattern.replace(new RegExp('maxDig', 'g'), maxDig);
|
|
91
|
+
validators.push(Validators.pattern(pattern));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (numberType === Xsd.float) {
|
|
95
|
+
this.patternErrorMessage = ' The value should be a float,' + maxDecimalError;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (numberType === Xsd.double) {
|
|
99
|
+
this.patternErrorMessage = ' The value should be a double,' + maxDecimalError;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (this.constraintMinValue != null) {
|
|
103
|
+
validators.push(Validators.min(this.constraintMinValue));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (this.constraintMaxValue != null) {
|
|
107
|
+
validators.push(Validators.max(this.constraintMaxValue));
|
|
108
|
+
}
|
|
109
|
+
this.inputValueControl = new FormControl(null, validators);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Input() set componentToRender(componentToRender: FieldComponent) {
|
|
113
|
+
this.component = componentToRender;
|
|
114
|
+
this.activeComponentRegistry.registerComponent(this.component, this);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
inputChanged($event: Event): void {
|
|
118
|
+
let val = ($event.target as HTMLTextAreaElement).value;
|
|
119
|
+
|
|
120
|
+
if (val.length === 0) {
|
|
121
|
+
val = null;
|
|
122
|
+
}
|
|
123
|
+
this.handlerContext.changeValue(this.component, val);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setCurrentValue(currentValue: any): void {
|
|
127
|
+
this.inputValueControl.setValue(currentValue);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
clearValue(): void {
|
|
131
|
+
this.setValueUIAndModel(null);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private setValueUIAndModel(value: string): void {
|
|
135
|
+
this.inputValueControl.setValue(value);
|
|
136
|
+
this.handlerContext.changeValue(this.component, value);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getMinMaxValueHint(): string {
|
|
140
|
+
let s = '';
|
|
141
|
+
let min = null;
|
|
142
|
+
let max = null;
|
|
143
|
+
|
|
144
|
+
if (this.component.numberInfo.minValue != null) {
|
|
145
|
+
min = this.component.numberInfo.minValue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (this.component.numberInfo.maxValue != null) {
|
|
149
|
+
max = this.component.numberInfo.maxValue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (min != null || max != null) {
|
|
153
|
+
if (min != null) {
|
|
154
|
+
s += 'min: ' + min + '; ';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (max != null) {
|
|
158
|
+
s += 'max: ' + max + ';';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const decimalPlace = this.component.numberInfo.decimalPlace;
|
|
162
|
+
|
|
163
|
+
if (decimalPlace != null) {
|
|
164
|
+
s += ' max ' + decimalPlace + ' decimals;';
|
|
165
|
+
}
|
|
166
|
+
return s;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<form class="form-container" [formGroup]="options">
|
|
2
|
+
<mat-form-field class="full-width">
|
|
3
|
+
<!-- <mat-label>{{cds.getRenderingLabelForComponent(component)}}</mat-label>-->
|
|
4
|
+
<input matInput type="text"
|
|
5
|
+
[formControl]="inputValueControl"
|
|
6
|
+
[errorStateMatcher]="errorStateMatcher"
|
|
7
|
+
(input)="inputChanged($event)"
|
|
8
|
+
attr.aria-label="{{cds.getRenderingLabelForComponent(component)}}">
|
|
9
|
+
<button type="button" mat-button *ngIf="inputValueControl.value" matSuffix mat-icon-button attr.aria-label="{{'Generic.Clear' | translate}}" (click)="clearValue()">
|
|
10
|
+
<mat-icon>close</mat-icon>
|
|
11
|
+
</button>
|
|
12
|
+
<mat-error align="start" *ngIf="inputValueControl.getError('required')" class="mat-error">{{'Validation.Required' | translate}}</mat-error>
|
|
13
|
+
</mat-form-field>
|
|
14
|
+
</form>
|
|
15
|
+
|
package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.scss
ADDED
|
File without changes
|
package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.spec.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import {CedarInputPhoneComponent} from './cedar-input-phone.component';
|
|
4
|
+
|
|
5
|
+
describe('CedarInputPhoneComponent', () => {
|
|
6
|
+
let component: CedarInputPhoneComponent;
|
|
7
|
+
let fixture: ComponentFixture<CedarInputPhoneComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [CedarInputPhoneComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(CedarInputPhoneComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
|
|
2
|
+
import {FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm, Validators} from '@angular/forms';
|
|
3
|
+
import {ErrorStateMatcher} from '@angular/material/core';
|
|
4
|
+
import {CedarUIComponent} from '../../../shared/models/ui/cedar-ui-component.model';
|
|
5
|
+
import {FieldComponent} from '../../../shared/models/component/field-component.model';
|
|
6
|
+
import {ActiveComponentRegistryService} from '../../../shared/service/active-component-registry.service';
|
|
7
|
+
import {HandlerContext} from '../../../shared/util/handler-context';
|
|
8
|
+
import {ComponentDataService} from '../../../shared/service/component-data.service';
|
|
9
|
+
|
|
10
|
+
export class TextFieldErrorStateMatcher implements ErrorStateMatcher {
|
|
11
|
+
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
|
12
|
+
return !!(control && control.invalid && (control.dirty || control.touched));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'app-cedar-input-phone',
|
|
18
|
+
templateUrl: './cedar-input-phone.component.html',
|
|
19
|
+
styleUrls: ['./cedar-input-phone.component.scss'],
|
|
20
|
+
encapsulation: ViewEncapsulation.None
|
|
21
|
+
})
|
|
22
|
+
export class CedarInputPhoneComponent extends CedarUIComponent implements OnInit {
|
|
23
|
+
|
|
24
|
+
component: FieldComponent;
|
|
25
|
+
options: FormGroup;
|
|
26
|
+
inputValueControl = new FormControl(null, null);
|
|
27
|
+
errorStateMatcher = new TextFieldErrorStateMatcher();
|
|
28
|
+
@Input() handlerContext: HandlerContext;
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
fb: FormBuilder,
|
|
32
|
+
public cds: ComponentDataService,
|
|
33
|
+
private activeComponentRegistry: ActiveComponentRegistryService
|
|
34
|
+
) {
|
|
35
|
+
super();
|
|
36
|
+
this.options = fb.group({
|
|
37
|
+
inputValue: this.inputValueControl,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ngOnInit(): void {
|
|
42
|
+
const validators: any[] = [];
|
|
43
|
+
|
|
44
|
+
const reg = /^[\+0-9\s\-\(\)]+$/im;
|
|
45
|
+
validators.push(Validators.pattern(reg));
|
|
46
|
+
|
|
47
|
+
if (this.component.valueInfo.requiredValue) {
|
|
48
|
+
validators.push(Validators.required);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.inputValueControl = new FormControl(null, validators);
|
|
52
|
+
|
|
53
|
+
if (this.component.valueInfo.defaultValue != null) {
|
|
54
|
+
this.setValueUIAndModel(this.component.valueInfo.defaultValue);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Input() set componentToRender(componentToRender: FieldComponent) {
|
|
59
|
+
this.component = componentToRender;
|
|
60
|
+
this.activeComponentRegistry.registerComponent(this.component, this);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
inputChanged($event: Event): void {
|
|
64
|
+
let val = ($event.target as HTMLTextAreaElement).value;
|
|
65
|
+
|
|
66
|
+
if (val.length === 0) {
|
|
67
|
+
val = null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.handlerContext.changeValue(this.component, val);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setCurrentValue(currentValue: any): void {
|
|
74
|
+
this.inputValueControl.setValue(currentValue);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
clearValue(): void {
|
|
78
|
+
this.setValueUIAndModel(null);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private setValueUIAndModel(value: string): void {
|
|
82
|
+
this.inputValueControl.setValue(value);
|
|
83
|
+
this.handlerContext.changeValue(this.component, value);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getCharCountHint(): string {
|
|
87
|
+
let len = 0;
|
|
88
|
+
if (this.inputValueControl.value != null) {
|
|
89
|
+
len = this.inputValueControl.value.length;
|
|
90
|
+
}
|
|
91
|
+
const s = '' + len;
|
|
92
|
+
return s;
|
|
93
|
+
}
|
|
94
|
+
}
|
package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.html
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<form class="form-container" [formGroup]="options">
|
|
2
|
+
<mat-form-field class="full-width">
|
|
3
|
+
<!-- <mat-label>{{cds.getRenderingLabelForComponent(component)}}</mat-label>-->
|
|
4
|
+
<mat-select #inputSelect
|
|
5
|
+
[formControl]="inputValueControl"
|
|
6
|
+
[errorStateMatcher]="errorStateMatcher"
|
|
7
|
+
multiple="{{component.choiceInfo.multipleChoice}}"
|
|
8
|
+
(selectionChange)="inputChanged()"
|
|
9
|
+
[aria-label]=cds.getRenderingLabelForComponent(component)>
|
|
10
|
+
<mat-option *ngFor="let option of dropdownList" [value]="option.id"
|
|
11
|
+
>{{option.label}}</mat-option>
|
|
12
|
+
</mat-select>
|
|
13
|
+
<button type="button" tabindex="0" mat-button *ngIf="inputValueControl.value" matSuffix mat-icon-button attr.aria-label="{{'Generic.Clear' | translate}}" (click)="clearValue($event)">
|
|
14
|
+
<mat-icon>close</mat-icon>
|
|
15
|
+
</button>
|
|
16
|
+
<mat-error tabindex="0" align="start" *ngIf="inputValueControl.hasError('required')" class="mat-error">{{'Validation.Required' | translate}}</mat-error>
|
|
17
|
+
<mat-hint *ngIf=maxSelections!==undefined>{{'Validation.Select.MaxSelection' | translate: {maxSelections} }}</mat-hint>
|
|
18
|
+
</mat-form-field>
|
|
19
|
+
</form>
|
package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.scss
ADDED
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import {CedarInputSelectComponent} from './cedar-input-select.component';
|
|
4
|
+
|
|
5
|
+
describe('CedarInputSelectComponent', () => {
|
|
6
|
+
let component: CedarInputSelectComponent;
|
|
7
|
+
let fixture: ComponentFixture<CedarInputSelectComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [CedarInputSelectComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(CedarInputSelectComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|