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,451 @@
|
|
|
1
|
+
import {AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
|
|
2
|
+
import {FieldComponent} from '../../../shared/models/component/field-component.model';
|
|
3
|
+
import {FormBuilder, FormControl} 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 {DatePickerComponent} from '../../../shared/components/date-picker/date-picker.component';
|
|
8
|
+
import {Xsd} from '../../../shared/models/xsd.model';
|
|
9
|
+
import {Temporal} from '../../../shared/models/temporal.model';
|
|
10
|
+
import moment, {Moment} from 'moment';
|
|
11
|
+
import {TimezonePickerComponent, TZone} from '../../../shared/components/timezone-picker/timezone-picker.component';
|
|
12
|
+
// import {Moment} from 'moment';
|
|
13
|
+
// import * as moment from 'moment-timezone';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'app-cedar-input-datetime',
|
|
18
|
+
templateUrl: './cedar-input-datetime.component.html',
|
|
19
|
+
styleUrls: ['./cedar-input-datetime.component.scss'],
|
|
20
|
+
encapsulation: ViewEncapsulation.None
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export class CedarInputDatetimeComponent extends CedarUIComponent implements OnInit, AfterViewInit {
|
|
24
|
+
|
|
25
|
+
component: FieldComponent;
|
|
26
|
+
|
|
27
|
+
timePickerTime: Date;
|
|
28
|
+
decimalSeconds: number;
|
|
29
|
+
timezone: TZone;
|
|
30
|
+
setDefaultZone = false;
|
|
31
|
+
datetimeParsed: DatetimeRepresentation;
|
|
32
|
+
dateMonthYearControl: FormControl;
|
|
33
|
+
required: boolean;
|
|
34
|
+
|
|
35
|
+
@Input() handlerContext: HandlerContext;
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
fb: FormBuilder,
|
|
39
|
+
private activeComponentRegistry: ActiveComponentRegistryService,
|
|
40
|
+
private cdr: ChangeDetectorRef
|
|
41
|
+
) {
|
|
42
|
+
super();
|
|
43
|
+
this.datetimeParsed = new DatetimeRepresentation();
|
|
44
|
+
this.timePickerTime = this.getDefaultTime();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ngOnInit(): void {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngAfterViewInit(): void {
|
|
51
|
+
this.cdr.detectChanges();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Input() set componentToRender(componentToRender: FieldComponent) {
|
|
55
|
+
this.component = componentToRender;
|
|
56
|
+
this.required = this.component.valueInfo.requiredValue;
|
|
57
|
+
this.activeComponentRegistry.registerComponent(this.component, this);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
dateInputChanged(event): void {
|
|
61
|
+
this.datetimeParsed.setDate(event);
|
|
62
|
+
this.handlerContext.changeValue(this.component, this.datetimeParsed.toStorageRepresentation());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
timeInputChanged(event): void {
|
|
66
|
+
this.datetimeParsed.setHours(this.timePickerTime.getHours());
|
|
67
|
+
this.datetimeParsed.setAMPM(this.enableMeridian());
|
|
68
|
+
|
|
69
|
+
if (!this.disableMinute()) {
|
|
70
|
+
this.datetimeParsed.setMinutes(this.timePickerTime.getMinutes());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (this.showSeconds()) {
|
|
74
|
+
this.datetimeParsed.setSeconds(this.timePickerTime.getSeconds());
|
|
75
|
+
}
|
|
76
|
+
this.handlerContext.changeValue(this.component, this.datetimeParsed.toStorageRepresentation());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
decimalSecondsChanged(event): void {
|
|
80
|
+
this.datetimeParsed.setDecimalSeconds(this.decimalSeconds);
|
|
81
|
+
this.handlerContext.changeValue(this.component, this.datetimeParsed.toStorageRepresentation());
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
timezoneInputChanged(event): void {
|
|
85
|
+
if (event != null) {
|
|
86
|
+
this.datetimeParsed.setTimezone(event);
|
|
87
|
+
this.handlerContext.changeValue(this.component, this.datetimeParsed.toStorageRepresentation());
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
showDatePicker(): boolean {
|
|
92
|
+
return [Xsd.dateTime, Xsd.date].indexOf(this.component.valueInfo.temporalType) > -1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
dateFormat(): string {
|
|
96
|
+
let format = DatePickerComponent.YEAR_MONTH_DAY_FORMAT;
|
|
97
|
+
|
|
98
|
+
if (this.component.valueInfo.temporalType === Xsd.date) {
|
|
99
|
+
switch (this.component.basicInfo.temporalGranularity) {
|
|
100
|
+
case Temporal.month:
|
|
101
|
+
format = DatePickerComponent.YEAR_MONTH_FORMAT;
|
|
102
|
+
break;
|
|
103
|
+
case Temporal.year:
|
|
104
|
+
format = DatePickerComponent.YEAR_FORMAT;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return format;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
showTimePicker(): boolean {
|
|
112
|
+
return [Xsd.dateTime, Xsd.time].indexOf(this.component.valueInfo.temporalType) > -1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
enableMeridian(): boolean {
|
|
116
|
+
return (this.component.basicInfo.inputTimeFormat === Temporal.inputType12h);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
disableMinute(): boolean {
|
|
120
|
+
return (this.component.basicInfo.temporalGranularity === Temporal.hour);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
showSeconds(): boolean {
|
|
124
|
+
return [Temporal.second, Temporal.decimalSecond].indexOf(this.component.basicInfo.temporalGranularity) > -1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
showDecimalSeconds(): boolean {
|
|
128
|
+
return (this.component.basicInfo.temporalGranularity === Temporal.decimalSecond);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
showTimezonePicker(): boolean {
|
|
132
|
+
return (this.component.basicInfo.timezoneEnabled === true);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
setCurrentValue(currentValue: any): void {
|
|
136
|
+
if (currentValue) {
|
|
137
|
+
this.datetimeParsed = DatetimeRepresentation.fromStorageRepresentation(currentValue as string, this.enableMeridian());
|
|
138
|
+
|
|
139
|
+
if (this.datetimeParsed.dateIsSet) {
|
|
140
|
+
const m = moment();
|
|
141
|
+
m.set('date', +this.datetimeParsed.day);
|
|
142
|
+
m.set('month', +this.datetimeParsed.month - 1);
|
|
143
|
+
m.set('year', +this.datetimeParsed.year);
|
|
144
|
+
this.dateMonthYearControl = new FormControl(m);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (this.datetimeParsed.timeIsSet) {
|
|
148
|
+
// reset timepicker UI
|
|
149
|
+
this.timePickerTime = new Date();
|
|
150
|
+
this.timePickerTime.setHours(+this.datetimeParsed.hours, +this.datetimeParsed.minutes, +this.datetimeParsed.seconds);
|
|
151
|
+
|
|
152
|
+
// reset decimal seconds
|
|
153
|
+
if (this.datetimeParsed.decimalSeconds.length > 0) {
|
|
154
|
+
this.decimalSeconds = +this.datetimeParsed.decimalSeconds;
|
|
155
|
+
} else {
|
|
156
|
+
this.decimalSeconds = null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (this.datetimeParsed.timezoneIsSet) {
|
|
160
|
+
this.timezone = {
|
|
161
|
+
id: this.datetimeParsed.timezoneOffset,
|
|
162
|
+
label: this.datetimeParsed.timezoneName
|
|
163
|
+
};
|
|
164
|
+
} else {
|
|
165
|
+
this.resetTimezone();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// set datetime UI to default view
|
|
170
|
+
else {
|
|
171
|
+
this.resetDate();
|
|
172
|
+
this.resetTime();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private resetDate(): void {
|
|
177
|
+
if (this.showDatePicker()) {
|
|
178
|
+
const defDate = this.getDefaultDate();
|
|
179
|
+
this.dateMonthYearControl = new FormControl(defDate);
|
|
180
|
+
this.datetimeParsed.setDate(defDate);
|
|
181
|
+
this.handlerContext.changeValue(this.component, this.datetimeParsed.toStorageRepresentation());
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private resetTime(): void {
|
|
186
|
+
if (this.showTimePicker()) {
|
|
187
|
+
this.timePickerTime = this.getDefaultTime();
|
|
188
|
+
this.decimalSeconds = null;
|
|
189
|
+
this.datetimeParsed.setDecimalSeconds(null);
|
|
190
|
+
this.resetTimezone();
|
|
191
|
+
this.handlerContext.changeValue(this.component, this.datetimeParsed.toStorageRepresentation());
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private resetTimezone(): void {
|
|
196
|
+
if (this.showTimezonePicker()) {
|
|
197
|
+
let tz = null;
|
|
198
|
+
|
|
199
|
+
if (this.setDefaultZone) {
|
|
200
|
+
tz = TimezonePickerComponent.guessedUserZone();
|
|
201
|
+
}
|
|
202
|
+
this.timezone = tz;
|
|
203
|
+
this.datetimeParsed.setTimezone(tz);
|
|
204
|
+
this.handlerContext.changeValue(this.component, this.datetimeParsed.toStorageRepresentation());
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private getDefaultDate(): Moment {
|
|
209
|
+
const dt = moment();
|
|
210
|
+
const format = this.dateFormat();
|
|
211
|
+
|
|
212
|
+
switch (format) {
|
|
213
|
+
case DatePickerComponent.YEAR_MONTH_FORMAT:
|
|
214
|
+
dt.set('date', 1);
|
|
215
|
+
break;
|
|
216
|
+
case DatePickerComponent.YEAR_FORMAT:
|
|
217
|
+
dt.set('date', 1);
|
|
218
|
+
dt.set('month', 0);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
return dt;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private getDefaultTime(): Date {
|
|
225
|
+
const dt = new Date();
|
|
226
|
+
// dt.setHours(0,0,0,0);
|
|
227
|
+
return dt;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export class DatetimeRepresentation {
|
|
232
|
+
|
|
233
|
+
static readonly DATE_SEPARATOR = '-';
|
|
234
|
+
static readonly TIME_SEPARATOR = ':';
|
|
235
|
+
static readonly DATE_TIME_SEPARATOR = 'T';
|
|
236
|
+
static readonly TIME_DECIMAL_SECOND_SEPARATOR = '.';
|
|
237
|
+
static readonly DATE_STORED_FORMAT = 'YYYY-MM-DD';
|
|
238
|
+
|
|
239
|
+
dateIsSet: boolean;
|
|
240
|
+
timeIsSet: boolean;
|
|
241
|
+
timezoneIsSet: boolean;
|
|
242
|
+
|
|
243
|
+
year: string;
|
|
244
|
+
month: string;
|
|
245
|
+
day: string;
|
|
246
|
+
|
|
247
|
+
hours: string;
|
|
248
|
+
minutes: string;
|
|
249
|
+
seconds: string;
|
|
250
|
+
decimalSeconds: string;
|
|
251
|
+
ampm: boolean;
|
|
252
|
+
|
|
253
|
+
timezoneName: string;
|
|
254
|
+
timezoneOffset: string;
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
constructor() {
|
|
258
|
+
// set default values
|
|
259
|
+
const DEF_ZERO = '00';
|
|
260
|
+
const DEF_ONE = '01';
|
|
261
|
+
|
|
262
|
+
this.dateIsSet = false;
|
|
263
|
+
this.timeIsSet = false;
|
|
264
|
+
this.timezoneIsSet = false;
|
|
265
|
+
|
|
266
|
+
this.year = '';
|
|
267
|
+
this.month = DEF_ONE;
|
|
268
|
+
this.day = DEF_ONE;
|
|
269
|
+
|
|
270
|
+
this.hours = DEF_ZERO;
|
|
271
|
+
this.minutes = DEF_ZERO;
|
|
272
|
+
this.seconds = DEF_ZERO;
|
|
273
|
+
this.decimalSeconds = '';
|
|
274
|
+
this.ampm = true;
|
|
275
|
+
|
|
276
|
+
this.timezoneName = '';
|
|
277
|
+
this.timezoneOffset = '';
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
static fromStorageRepresentation(storedDateStr: string, ampm: boolean): DatetimeRepresentation {
|
|
281
|
+
const that = new DatetimeRepresentation();
|
|
282
|
+
const datePatternStr = '^\\d{4}\\' + DatetimeRepresentation.DATE_SEPARATOR + '\\d{2}\\' + DatetimeRepresentation.DATE_SEPARATOR + '\\d{2}';
|
|
283
|
+
const datePattern = new RegExp(datePatternStr);
|
|
284
|
+
const dateStr = storedDateStr.match(datePattern);
|
|
285
|
+
|
|
286
|
+
if (dateStr && dateStr.length > 0) {
|
|
287
|
+
that.dateIsSet = true;
|
|
288
|
+
that.setDate(moment(dateStr[0], DatetimeRepresentation.DATE_STORED_FORMAT));
|
|
289
|
+
}
|
|
290
|
+
const timePatternStr = '(\\d{2}\\' + DatetimeRepresentation.TIME_SEPARATOR + '\\d{2}\\' + DatetimeRepresentation.TIME_SEPARATOR + '\\d{2})(\\.[\\d\\.]+)*';
|
|
291
|
+
const timePattern = new RegExp(timePatternStr);
|
|
292
|
+
const timeStr = storedDateStr.match(timePattern);
|
|
293
|
+
|
|
294
|
+
if (timeStr && timeStr.length > 1) {
|
|
295
|
+
that.setAMPM(ampm);
|
|
296
|
+
const timeArr = timeStr[1].split(DatetimeRepresentation.TIME_SEPARATOR);
|
|
297
|
+
that.setHours(+timeArr[0]);
|
|
298
|
+
that.setMinutes(+timeArr[1]);
|
|
299
|
+
that.setSeconds(+timeArr[2]);
|
|
300
|
+
|
|
301
|
+
if (timeStr.length > 2 && timeStr[2]) {
|
|
302
|
+
that.setDecimalSeconds(+timeStr[2].substring(1));
|
|
303
|
+
}
|
|
304
|
+
const timezonePatternStr = 'Z|[\\-\\+]{1}\\d{2}\\' + DatetimeRepresentation.TIME_SEPARATOR + '\\d{2}$';
|
|
305
|
+
const timezonePattern = new RegExp(timezonePatternStr);
|
|
306
|
+
const timezoneStr = storedDateStr.match(timezonePattern);
|
|
307
|
+
|
|
308
|
+
if (timezoneStr && timezoneStr.length > 0) {
|
|
309
|
+
const timezone = TimezonePickerComponent.AVAILABLE_TIMEZONES.find(z => z.id === timezoneStr[0]);
|
|
310
|
+
that.setTimezone(timezone);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return that;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
static regexIndexOf(text, re, i): number {
|
|
317
|
+
const indexInSuffix = text.slice(i).search(re);
|
|
318
|
+
return indexInSuffix < 0 ? indexInSuffix : indexInSuffix + i;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
static indexOfEnd(sourceStr, matchStr): number {
|
|
322
|
+
const io = sourceStr.indexOf(matchStr);
|
|
323
|
+
return io === -1 ? -1 : io + matchStr.length;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
setDate(dateIn: Moment): void {
|
|
327
|
+
if (!dateIn){
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.dateIsSet = true;
|
|
331
|
+
this.year = dateIn.year().toLocaleString().replace(/,/,'');
|
|
332
|
+
this.month = this.stringify((dateIn.month() + 1).toLocaleString());
|
|
333
|
+
this.day = this.stringify(dateIn.date().toLocaleString());
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
setHours(hoursIn: number): void {
|
|
337
|
+
this.timeIsSet = true;
|
|
338
|
+
this.hours = this.stringify(hoursIn);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
setMinutes(minutesIn: number): void {
|
|
342
|
+
this.timeIsSet = true;
|
|
343
|
+
this.minutes = this.stringify(minutesIn);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
setSeconds(secondsIn: number): void {
|
|
347
|
+
this.timeIsSet = true;
|
|
348
|
+
this.seconds = this.stringify(secondsIn);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
setAMPM(val: boolean): void {
|
|
352
|
+
this.ampm = val;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
setDecimalSeconds(decSecondsIn: number): void {
|
|
356
|
+
this.timeIsSet = true;
|
|
357
|
+
|
|
358
|
+
if (decSecondsIn == null) {
|
|
359
|
+
this.decimalSeconds = '';
|
|
360
|
+
} else {
|
|
361
|
+
this.decimalSeconds = decSecondsIn.toString();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
setTimezone(timezoneIn: TZone): void {
|
|
366
|
+
if (timezoneIn) {
|
|
367
|
+
this.timezoneIsSet = true;
|
|
368
|
+
this.timezoneOffset = timezoneIn.id;
|
|
369
|
+
this.timezoneName = timezoneIn.label;
|
|
370
|
+
} else {
|
|
371
|
+
this.timezoneIsSet = false;
|
|
372
|
+
this.timezoneOffset = '';
|
|
373
|
+
this.timezoneName = '';
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
toDateRepresentation(): string {
|
|
378
|
+
const m = moment();
|
|
379
|
+
const formatArr = [];
|
|
380
|
+
|
|
381
|
+
if (this.timezoneIsSet) {
|
|
382
|
+
m.utcOffset(this.timezoneOffset);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (this.dateIsSet) {
|
|
386
|
+
m.set({year: +this.year, month: +this.month - 1, date: +this.day});
|
|
387
|
+
formatArr.push(DatePickerComponent.YEAR_MONTH_DAY_FORMAT);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (this.timeIsSet) {
|
|
391
|
+
m.set({hour: +this.hours, minute: +this.minutes, second: +this.seconds});
|
|
392
|
+
|
|
393
|
+
if (this.dateIsSet) {
|
|
394
|
+
formatArr.push(' ');
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (this.ampm) {
|
|
398
|
+
formatArr.push('hh:mm:ss A');
|
|
399
|
+
} else {
|
|
400
|
+
formatArr.push('HH:mm:ss'); // 24-hour clock time
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (this.timezoneIsSet) {
|
|
405
|
+
formatArr.push('Z');
|
|
406
|
+
}
|
|
407
|
+
return m.format(formatArr.join(''));
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
toStorageRepresentation(): string {
|
|
411
|
+
let dateStr = '';
|
|
412
|
+
|
|
413
|
+
if (this.dateIsSet) {
|
|
414
|
+
dateStr += this.year + DatetimeRepresentation.DATE_SEPARATOR +
|
|
415
|
+
this.month + DatetimeRepresentation.DATE_SEPARATOR +
|
|
416
|
+
this.day;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (this.timeIsSet) {
|
|
420
|
+
if (this.dateIsSet) {
|
|
421
|
+
dateStr += DatetimeRepresentation.DATE_TIME_SEPARATOR;
|
|
422
|
+
}
|
|
423
|
+
dateStr += this.hours + DatetimeRepresentation.TIME_SEPARATOR +
|
|
424
|
+
this.minutes + DatetimeRepresentation.TIME_SEPARATOR +
|
|
425
|
+
this.seconds;
|
|
426
|
+
|
|
427
|
+
if (this.decimalSeconds.length > 0) {
|
|
428
|
+
dateStr += DatetimeRepresentation.TIME_DECIMAL_SECOND_SEPARATOR +
|
|
429
|
+
this.decimalSeconds;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (this.timezoneIsSet) {
|
|
434
|
+
dateStr += this.timezoneOffset;
|
|
435
|
+
}
|
|
436
|
+
return dateStr;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
toString(): string {
|
|
440
|
+
return this.toStorageRepresentation();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
private stringify(valIn: any): string {
|
|
444
|
+
let str = valIn.toString();
|
|
445
|
+
if (valIn < 10) {
|
|
446
|
+
str = '0' + str;
|
|
447
|
+
}
|
|
448
|
+
return str;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
}
|
package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.html
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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" placeholder="example@domain.com"
|
|
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('email')" class="mat-error">{{'Validation.Email.Invalid' | translate}}</mat-error>
|
|
13
|
+
<mat-error align="start" *ngIf="inputValueControl.getError('required')" class="mat-error">{{'Validation.Required' | translate}}</mat-error>
|
|
14
|
+
</mat-form-field>
|
|
15
|
+
</form>
|
|
16
|
+
|
package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.scss
ADDED
|
File without changes
|
package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.spec.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import {CedarInputEmailComponent} from './cedar-input-email.component';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe('CedarInputEmailComponent', () => {
|
|
6
|
+
let component: CedarInputEmailComponent;
|
|
7
|
+
let fixture: ComponentFixture<CedarInputEmailComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ CedarInputEmailComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(CedarInputEmailComponent);
|
|
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-email/cedar-input-email.component.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
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-email',
|
|
18
|
+
templateUrl: './cedar-input-email.component.html',
|
|
19
|
+
styleUrls: ['./cedar-input-email.component.scss'],
|
|
20
|
+
encapsulation: ViewEncapsulation.None
|
|
21
|
+
})
|
|
22
|
+
export class CedarInputEmailComponent 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
|
+
validators.push(Validators.email);
|
|
45
|
+
|
|
46
|
+
if (this.component.valueInfo.requiredValue) {
|
|
47
|
+
validators.push(Validators.required);
|
|
48
|
+
}
|
|
49
|
+
this.inputValueControl = new FormControl(null, validators);
|
|
50
|
+
if (this.component.valueInfo.defaultValue != null) {
|
|
51
|
+
this.setValueUIAndModel(this.component.valueInfo.defaultValue);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Input() set componentToRender(componentToRender: FieldComponent) {
|
|
56
|
+
this.component = componentToRender;
|
|
57
|
+
this.activeComponentRegistry.registerComponent(this.component, this);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
inputChanged($event: Event): void {
|
|
61
|
+
let val = ($event.target as HTMLTextAreaElement).value;
|
|
62
|
+
|
|
63
|
+
if (val.length === 0) {
|
|
64
|
+
val = null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.handlerContext.changeValue(this.component, val);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setCurrentValue(currentValue: any): void {
|
|
71
|
+
this.inputValueControl.setValue(currentValue);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
clearValue(): void {
|
|
75
|
+
this.setValueUIAndModel(null);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private setValueUIAndModel(value: string): void {
|
|
79
|
+
this.inputValueControl.setValue(value);
|
|
80
|
+
this.handlerContext.changeValue(this.component, value);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getCharCountHint(): string {
|
|
84
|
+
let len = 0;
|
|
85
|
+
if (this.inputValueControl.value != null) {
|
|
86
|
+
len = this.inputValueControl.value.length;
|
|
87
|
+
}
|
|
88
|
+
const s = '' + len;
|
|
89
|
+
return s;
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.html
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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('link')" class="mat-error">{{'Validation.Link.Invalid' | translate}}</mat-error>
|
|
13
|
+
<mat-error align="start" *ngIf="inputValueControl.getError('required')" class="mat-error">{{'Validation.Required' | translate}}</mat-error>
|
|
14
|
+
</mat-form-field>
|
|
15
|
+
</form>
|
|
16
|
+
|
package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.scss
ADDED
|
File without changes
|
package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.spec.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import {CedarInputLinkComponent} from './cedar-input-link.component';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe('CedarInputLinkComponent', () => {
|
|
6
|
+
let component: CedarInputLinkComponent;
|
|
7
|
+
let fixture: ComponentFixture<CedarInputLinkComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ CedarInputLinkComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(CedarInputLinkComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|