ecabs-components 0.0.59 → 0.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/images/nothing-here.svg +22 -0
- package/esm2020/lib/base/directives/digits-only.directive.mjs +2 -2
- package/esm2020/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.mjs +9 -5
- package/esm2020/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.mjs +1 -1
- package/esm2020/lib/ecabs-increment/ecabs-increment.component.mjs +2 -2
- package/esm2020/lib/ecabs-picker-header/ecabs-picker-header.component.mjs +2 -2
- package/fesm2015/ecabs-components.mjs +14 -10
- package/fesm2015/ecabs-components.mjs.map +1 -1
- package/fesm2020/ecabs-components.mjs +14 -10
- package/fesm2020/ecabs-components.mjs.map +1 -1
- package/lib/base/consts/date-mask.consts.ts +70 -0
- package/lib/base/directives/date-mask.directive.module.ts +15 -0
- package/lib/base/directives/date-mask.directive.ts +58 -0
- package/lib/base/directives/digits-only.directive.module.ts +15 -0
- package/lib/base/directives/digits-only.directive.ts +129 -0
- package/lib/base/directives/number-border.directive.module.ts +14 -0
- package/lib/base/directives/number-border.directive.ts +57 -0
- package/lib/base/element-base.ts +72 -0
- package/lib/base/element-wrapper/element-wrapper.component.html +30 -0
- package/lib/base/element-wrapper/element-wrapper.component.ts +33 -0
- package/lib/base/element-wrapper/element-wrapper.module.ts +30 -0
- package/lib/base/hint/hint.component.html +1 -0
- package/lib/base/hint/hint.component.scss +0 -0
- package/lib/base/hint/hint.component.ts +12 -0
- package/lib/base/hint/hint.module.ts +13 -0
- package/lib/base/validation/validation.component.html +8 -0
- package/lib/base/validation/validation.component.scss +0 -0
- package/lib/base/validation/validation.component.ts +84 -0
- package/lib/base/validation/validation.module.ts +12 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.component.html +14 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.component.scss +16 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.component.ts +23 -0
- package/lib/ecabs-active-status-filter/ecabs-active-status-filter.module.ts +13 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.html +11 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.scss +0 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.spec.ts +24 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.component.ts +12 -0
- package/lib/ecabs-breadcrumb/ecabs-breadcrumb.module.ts +12 -0
- package/lib/ecabs-buttons/ecabs-buttons.component.html +18 -0
- package/lib/ecabs-buttons/ecabs-buttons.component.ts +54 -0
- package/lib/ecabs-buttons/ecabs-buttons.module.ts +13 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.d.ts +5 -3
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.html +27 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.scss +15 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.component.ts +86 -0
- package/lib/ecabs-checkbox-toggle/ecabs-checkbox-toggle.module.ts +21 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.html +4 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.scss +0 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.spec.ts +23 -0
- package/lib/ecabs-date-picker/components/ecabs-date-picker-header/ecabs-date-picker-header.component.ts +11 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.html +31 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.scss +10 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.spec.ts +24 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.component.ts +72 -0
- package/lib/ecabs-date-picker/ecabs-date-picker.module.ts +28 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.html +4 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.scss +1 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.spec.ts +23 -0
- package/lib/ecabs-date-range-picker/components/ecabs-date-range-picker-header/ecabs-date-range-picker-header.component.ts +11 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.html +31 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.scss +23 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.spec.ts +23 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.component.ts +113 -0
- package/lib/ecabs-date-range-picker/ecabs-date-range-picker.module.ts +48 -0
- package/lib/ecabs-date-time-picker/components/ecabs-date-time-picker-header/ecabs-date-time-picker-header.component.html +4 -0
- package/lib/ecabs-date-time-picker/components/ecabs-date-time-picker-header/ecabs-date-time-picker-header.component.scss +14 -0
- package/lib/ecabs-date-time-picker/components/ecabs-date-time-picker-header/ecabs-date-time-picker-header.component.ts +11 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.html +87 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.scss +68 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.spec.ts +23 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.component.ts +185 -0
- package/lib/ecabs-date-time-picker/ecabs-date-time-picker.module.ts +36 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.html +4 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.scss +11 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.spec.ts +23 -0
- package/lib/ecabs-date-time-range-picker/components/ecabs-date-time-range-picker-header/ecabs-date-time-range-picker-header.component.ts +10 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.html +107 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.scss +51 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.spec.ts +24 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.component.ts +206 -0
- package/lib/ecabs-date-time-range-picker/ecabs-date-time-range-picker.module.ts +37 -0
- package/lib/ecabs-date-time-range-picker/time-range.directive.ts +38 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.component.html +32 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.component.scss +24 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.component.ts +57 -0
- package/lib/ecabs-dialog-confirm/ecabs-dialog-confirm.module.ts +12 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.html +27 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.scss +25 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.spec.ts +38 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.component.ts +49 -0
- package/lib/ecabs-dialog-message/ecabs-dialog-message.module.ts +12 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.html +9 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.scss +0 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.spec.ts +34 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.component.ts +22 -0
- package/lib/ecabs-empty-placeholder/ecabs-empty-placeholder.module.ts +11 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.html +33 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.scss +79 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.spec.ts +26 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.component.ts +77 -0
- package/lib/ecabs-expansion-panel/ecabs-expansion-panel.module.ts +16 -0
- package/lib/ecabs-increment/ecabs-increment.component.html +18 -0
- package/lib/ecabs-increment/ecabs-increment.component.scss +33 -0
- package/lib/ecabs-increment/ecabs-increment.component.ts +74 -0
- package/lib/ecabs-increment/ecabs-increment.module.ts +16 -0
- package/lib/ecabs-input/ecabs-input.component.html +27 -0
- package/lib/ecabs-input/ecabs-input.component.ts +86 -0
- package/lib/ecabs-input/ecabs-input.module.ts +14 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.component.html +17 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.component.scss +24 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.component.ts +56 -0
- package/lib/ecabs-language-selector/ecabs-language-selector.module.ts +21 -0
- package/lib/ecabs-loading/ecabs-loading.component.html +7 -0
- package/lib/ecabs-loading/ecabs-loading.component.spec.ts +24 -0
- package/lib/ecabs-loading/ecabs-loading.component.ts +11 -0
- package/lib/ecabs-loading/ecabs-loading.module.ts +11 -0
- package/lib/ecabs-loading/spinner/spinner.component.html +5 -0
- package/lib/ecabs-loading/spinner/spinner.component.scss +61 -0
- package/lib/ecabs-loading/spinner/spinner.component.spec.ts +24 -0
- package/lib/ecabs-loading/spinner/spinner.component.ts +11 -0
- package/lib/ecabs-note/ecabs-note.component.html +10 -0
- package/lib/ecabs-note/ecabs-note.component.scss +29 -0
- package/lib/ecabs-note/ecabs-note.component.ts +27 -0
- package/lib/ecabs-note/ecabs-note.module.ts +11 -0
- package/lib/ecabs-phone/ecabs-phone.component.html +17 -0
- package/lib/ecabs-phone/ecabs-phone.component.ts +108 -0
- package/lib/ecabs-phone/ecabs-phone.module.ts +15 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.component.html +12 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.component.scss +12 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.component.ts +61 -0
- package/lib/ecabs-picker-header/ecabs-picker-header.module.ts +15 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.component.html +13 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.component.scss +16 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.component.ts +60 -0
- package/lib/ecabs-radio-button-list/ecabs-radio-button-list.module.ts +20 -0
- package/lib/ecabs-select/ecabs-select.component.html +38 -0
- package/lib/ecabs-select/ecabs-select.component.ts +346 -0
- package/lib/ecabs-select/ecabs-select.module.ts +37 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.html +7 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.scss +11 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.spec.ts +34 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.component.ts +14 -0
- package/lib/ecabs-table/ecabs-table-filter-wrapper/ecabs-table-filter-wrapper.module.ts +14 -0
- package/lib/ecabs-table/ecabs-table.component.html +26 -0
- package/lib/ecabs-table/ecabs-table.component.scss +6 -0
- package/lib/ecabs-table/ecabs-table.component.spec.ts +24 -0
- package/lib/ecabs-table/ecabs-table.component.ts +42 -0
- package/lib/ecabs-table/ecabs-table.module.ts +19 -0
- package/lib/ecabs-textarea/ecabs-textarea.component.html +13 -0
- package/lib/ecabs-textarea/ecabs-textarea.component.ts +61 -0
- package/lib/ecabs-textarea/ecabs-textarea.module.ts +12 -0
- package/lib/ecabs-timepicker/componets/ecabs-time-list-panel/ecabs-time-list-panel.component.html +16 -0
- package/lib/ecabs-timepicker/componets/ecabs-time-list-panel/ecabs-time-list-panel.component.ts +126 -0
- package/lib/ecabs-timepicker/config.model.ts +5 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.component.html +36 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.component.scss +5 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.component.ts +330 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.module.ts +12 -0
- package/lib/ecabs-timepicker/ecabs-timepicker.service.ts +28 -0
- package/lib/ecabs-validation/ecabs-validation.component.html +9 -0
- package/lib/ecabs-validation/ecabs-validation.component.scss +23 -0
- package/lib/ecabs-validation/ecabs-validation.component.ts +14 -0
- package/lib/ecabs-validation/ecabs-validation.module.ts +12 -0
- package/lib/models/bread-crumb.ts +5 -0
- package/lib/models/language.models.ts +0 -0
- package/lib/models/timepicker.models.ts +7 -0
- package/lib/models/validation.models.ts +4 -0
- package/lib/services/ecabs-components.service.ts +33 -0
- package/package.json +1 -1
- package/public-api.ts +58 -0
- package/styles/material/overrides/_form.scss +5 -0
- package/test.ts +27 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const maxValueMonth = [31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
2
|
+
const formatOrder = ['yyyy', 'yy', 'mm', 'dd', 'HH', 'MM', 'SS'];
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
5
|
+
export function createAutoCorrectedDatePipe(dateFormat = 'dd mm yyyy', { minYear = 1, maxYear = 9999 } = {}) {
|
|
6
|
+
const dateFormatArray = dateFormat
|
|
7
|
+
.split(/[^dmyHMS]+/)
|
|
8
|
+
.sort((a, b) => formatOrder.indexOf(a) - formatOrder.indexOf(b));
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11
|
+
return function (conformedValue) {
|
|
12
|
+
const indexesOfPipedChars = [];
|
|
13
|
+
const maxValue = { dd: 31, mm: 12, yy: 99, yyyy: maxYear, HH: 23, MM: 59, SS: 59 };
|
|
14
|
+
const minValue = { dd: 1, mm: 1, yy: 0, yyyy: minYear, HH: 0, MM: 0, SS: 0 };
|
|
15
|
+
const conformedValueArr = conformedValue.split('');
|
|
16
|
+
|
|
17
|
+
// Check first digit
|
|
18
|
+
dateFormatArray.forEach((format) => {
|
|
19
|
+
const position = dateFormat.indexOf(format);
|
|
20
|
+
const maxFirstDigit = parseInt(maxValue[format].toString().substr(0, 1), 10);
|
|
21
|
+
|
|
22
|
+
if (parseInt(conformedValueArr[position], 10) > maxFirstDigit) {
|
|
23
|
+
conformedValueArr[position + 1] = conformedValueArr[position];
|
|
24
|
+
conformedValueArr[position] = 0;
|
|
25
|
+
indexesOfPipedChars.push(position);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Check for invalid date
|
|
30
|
+
let month = 0;
|
|
31
|
+
const isInvalid = dateFormatArray.some((format) => {
|
|
32
|
+
const position = dateFormat.indexOf(format);
|
|
33
|
+
const length = format.length;
|
|
34
|
+
const textValue = conformedValue.substr(position, length).replace(/\D/g, '');
|
|
35
|
+
const value = parseInt(textValue, 10);
|
|
36
|
+
|
|
37
|
+
if (format === 'mm') {
|
|
38
|
+
// tslint:disable-next-line: strict-boolean-expressions
|
|
39
|
+
month = value || 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const maxValueForFormat = format === 'dd' ? maxValueMonth[month] : maxValue[format];
|
|
43
|
+
|
|
44
|
+
if (format === 'yyyy' && (minYear !== 1 || maxYear !== 9999)) {
|
|
45
|
+
const scopedMaxValue = parseInt(maxValue[format].toString().substring(0, textValue.length), 10);
|
|
46
|
+
const scopedMinValue = parseInt(minValue[format].toString().substring(0, textValue.length), 10);
|
|
47
|
+
|
|
48
|
+
return value < scopedMinValue || value > scopedMaxValue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (format === 'HH' || format === 'MM') {
|
|
52
|
+
const scopedMaxValue = parseInt(maxValue[format].toString().substring(0, textValue.length), 10);
|
|
53
|
+
const scopedMinValue = parseInt(minValue[format].toString().substring(0, textValue.length), 10);
|
|
54
|
+
|
|
55
|
+
return value < scopedMinValue || value > scopedMaxValue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return value > maxValueForFormat || (textValue.length === length && value < minValue[format]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (isInvalid) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
value: conformedValueArr.join(''),
|
|
67
|
+
indexesOfPipedChars,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { MaskDateDirective } from './date-mask.directive';
|
|
4
|
+
import { NumberBorderDirective } from './number-border.directive';
|
|
5
|
+
|
|
6
|
+
@NgModule( {
|
|
7
|
+
imports: [ CommonModule ],
|
|
8
|
+
declarations: [
|
|
9
|
+
MaskDateDirective,
|
|
10
|
+
],
|
|
11
|
+
exports: [
|
|
12
|
+
MaskDateDirective,
|
|
13
|
+
],
|
|
14
|
+
} )
|
|
15
|
+
export class MaskDateDirectiveModule { }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import * as textMask from 'vanilla-text-mask/dist/vanillaTextMask';
|
|
3
|
+
import { createAutoCorrectedDatePipe } from '../consts/date-mask.consts';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: '[appMaskDate]',
|
|
7
|
+
})
|
|
8
|
+
export class MaskDateDirective implements OnInit, OnDestroy {
|
|
9
|
+
@Input() isDateTimeMask = false;
|
|
10
|
+
@Input() considerSeconds = false;
|
|
11
|
+
|
|
12
|
+
maskedInputController;
|
|
13
|
+
mask = [/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/]; // dd/mm/yyyy
|
|
14
|
+
maskDateTime = [/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/, ',', ' ', /\d/, /\d/, ':', /\d/, /\d/]; // dd/mm/yyyy, hh:mm
|
|
15
|
+
maskDateTimeWithSeconds = [
|
|
16
|
+
/\d/,
|
|
17
|
+
/\d/,
|
|
18
|
+
'/',
|
|
19
|
+
/\d/,
|
|
20
|
+
/\d/,
|
|
21
|
+
'/',
|
|
22
|
+
/\d/,
|
|
23
|
+
/\d/,
|
|
24
|
+
/\d/,
|
|
25
|
+
/\d/,
|
|
26
|
+
',',
|
|
27
|
+
' ',
|
|
28
|
+
/\d/,
|
|
29
|
+
/\d/,
|
|
30
|
+
':',
|
|
31
|
+
/\d/,
|
|
32
|
+
/\d/,
|
|
33
|
+
':',
|
|
34
|
+
/\d/,
|
|
35
|
+
/\d/,
|
|
36
|
+
]; // dd/mm/yyyy, hh:mm:ss
|
|
37
|
+
|
|
38
|
+
constructor(private readonly element: ElementRef) {}
|
|
39
|
+
|
|
40
|
+
ngOnInit(): void {
|
|
41
|
+
this.maskedInputController = textMask.maskInput({
|
|
42
|
+
inputElement: this.element.nativeElement,
|
|
43
|
+
guide: true,
|
|
44
|
+
showMask: false,
|
|
45
|
+
pipe: this.isDateTimeMask
|
|
46
|
+
? this.considerSeconds
|
|
47
|
+
? createAutoCorrectedDatePipe('dd/mm/yyyy, HH:MM:SS')
|
|
48
|
+
: createAutoCorrectedDatePipe('dd/mm/yyyy, HH:MM')
|
|
49
|
+
: createAutoCorrectedDatePipe('dd/mm/yyyy'),
|
|
50
|
+
keepCharPositions: true,
|
|
51
|
+
mask: this.isDateTimeMask ? (this.considerSeconds ? this.maskDateTimeWithSeconds : this.maskDateTime) : this.mask,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ngOnDestroy(): void {
|
|
56
|
+
this.maskedInputController.destroy();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
import { DigitsOnlyDirective } from './digits-only.directive';
|
|
5
|
+
|
|
6
|
+
@NgModule( {
|
|
7
|
+
imports: [ CommonModule ],
|
|
8
|
+
declarations: [
|
|
9
|
+
DigitsOnlyDirective,
|
|
10
|
+
],
|
|
11
|
+
exports: [
|
|
12
|
+
DigitsOnlyDirective,
|
|
13
|
+
],
|
|
14
|
+
} )
|
|
15
|
+
export class DigitsOnlyDirectivesModule { }
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Directive, ElementRef, HostListener, Input, OnInit } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[appDigitsOnly]',
|
|
5
|
+
})
|
|
6
|
+
export class DigitsOnlyDirective implements OnInit {
|
|
7
|
+
@Input()
|
|
8
|
+
digitsOnly = false;
|
|
9
|
+
|
|
10
|
+
@Input()
|
|
11
|
+
allowHyphen = false;
|
|
12
|
+
|
|
13
|
+
@Input() decimal? = false;
|
|
14
|
+
@Input() decimalSeparator? = '.';
|
|
15
|
+
@Input() unit? = 0;
|
|
16
|
+
|
|
17
|
+
inputElement: HTMLInputElement;
|
|
18
|
+
minus = '-';
|
|
19
|
+
minusCounter = 0;
|
|
20
|
+
regex!: RegExp;
|
|
21
|
+
|
|
22
|
+
private decimalCounter = 0;
|
|
23
|
+
private readonly navigationKeys = [
|
|
24
|
+
'Backspace',
|
|
25
|
+
'Delete',
|
|
26
|
+
'Tab',
|
|
27
|
+
'Escape',
|
|
28
|
+
'Enter',
|
|
29
|
+
'Home',
|
|
30
|
+
'End',
|
|
31
|
+
'ArrowLeft',
|
|
32
|
+
'ArrowRight',
|
|
33
|
+
'Clear',
|
|
34
|
+
'Copy',
|
|
35
|
+
'Paste',
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
constructor(public el: ElementRef) {
|
|
39
|
+
this.inputElement = el.nativeElement;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@HostListener('keydown', ['$event'])
|
|
43
|
+
onKeyDown(e: KeyboardEvent): void {
|
|
44
|
+
if (this.digitsOnly) {
|
|
45
|
+
if (
|
|
46
|
+
this.navigationKeys.indexOf(e.key) > -1 || // Allow: navigation keys: backspace, delete, arrows etc.
|
|
47
|
+
(e.key === 'a' && e.ctrlKey) || // Allow: Ctrl+A
|
|
48
|
+
(e.key === 'c' && e.ctrlKey) || // Allow: Ctrl+C
|
|
49
|
+
(e.key === 'v' && e.ctrlKey) || // Allow: Ctrl+V
|
|
50
|
+
(e.key === 'x' && e.ctrlKey) || // Allow: Ctrl+X
|
|
51
|
+
(e.key === 'a' && e.metaKey) || // Allow: Cmd+A (Mac)
|
|
52
|
+
(e.key === 'c' && e.metaKey) || // Allow: Cmd+C (Mac)
|
|
53
|
+
(e.key === 'v' && e.metaKey) || // Allow: Cmd+V (Mac)
|
|
54
|
+
(e.key === 'x' && e.metaKey) || // Allow: Cmd+X (Mac)
|
|
55
|
+
(this.decimal && e.key === this.decimalSeparator && this.decimalCounter <= 1) || // Allow: only one decimal point
|
|
56
|
+
(this.decimal && e.key === this.minus && this.minusCounter < 1) // Allow: only one minus
|
|
57
|
+
) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Ensure that it is a number and stop the keypress
|
|
62
|
+
if (e.key === ' ' || !this.regex.test(e.key)) {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@HostListener('keyup', ['$event'])
|
|
69
|
+
onKeyUp(): void {
|
|
70
|
+
if (this.digitsOnly) {
|
|
71
|
+
if (!this.decimal) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.decimalCounter = this.el.nativeElement.value.split(this.decimalSeparator).length - 1;
|
|
76
|
+
this.minusCounter = this.el.nativeElement.value.split(this.minus).length - 1;
|
|
77
|
+
|
|
78
|
+
if (isNaN(+this.inputElement.value)) {
|
|
79
|
+
this.inputElement.value = this.sanitizeInput(this.inputElement.value);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@HostListener('paste', ['$event'])
|
|
85
|
+
onPaste(event: ClipboardEvent): void {
|
|
86
|
+
if (this.digitsOnly) {
|
|
87
|
+
const pastedInput = event.clipboardData?.getData('text/plain') as string;
|
|
88
|
+
this.pasteData(pastedInput);
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
ngOnInit(): void {
|
|
94
|
+
this.regex = new RegExp(this.allowHyphen ? '^[\\d -]+$' : '\\d');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private pasteData(pastedContent: string): void {
|
|
98
|
+
const sanitizedContent = isNaN(+pastedContent) ? this.sanitizeInput(pastedContent) : pastedContent;
|
|
99
|
+
const pasted = document.execCommand('insertText', false, sanitizedContent);
|
|
100
|
+
if (!pasted) {
|
|
101
|
+
const { selectionStart: start, selectionEnd: end } = this.inputElement;
|
|
102
|
+
this.inputElement.setRangeText(sanitizedContent, start as number, end as number, 'end');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private sanitizeInput(input: string): string {
|
|
107
|
+
let result = '';
|
|
108
|
+
if (this.decimal && this.isValidDecimal(input)) {
|
|
109
|
+
const regex = new RegExp(`^[\d -${this.decimalSeparator}]+$`, 'g');
|
|
110
|
+
result = input.replace(regex, '');
|
|
111
|
+
} else {
|
|
112
|
+
result = input.replace(`/${this.regex}/g`, '');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const maxLength = this.inputElement.maxLength;
|
|
116
|
+
|
|
117
|
+
if (maxLength > 0) {
|
|
118
|
+
// the input element has maxLength limit
|
|
119
|
+
const allowedLength = maxLength - this.inputElement.value.length;
|
|
120
|
+
result = allowedLength > 0 ? result.substring(0, allowedLength) : '';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private isValidDecimal(inputString: string): boolean {
|
|
127
|
+
return inputString.split(this.decimalSeparator as string).length <= 2;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { NumberBorderDirective } from './number-border.directive';
|
|
4
|
+
|
|
5
|
+
@NgModule( {
|
|
6
|
+
imports: [ CommonModule ],
|
|
7
|
+
declarations: [
|
|
8
|
+
NumberBorderDirective,
|
|
9
|
+
],
|
|
10
|
+
exports: [
|
|
11
|
+
NumberBorderDirective,
|
|
12
|
+
],
|
|
13
|
+
} )
|
|
14
|
+
export class NumberBorderDirectiveModule { }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Directive, ElementRef, HostListener, Input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[appNumberBorder]',
|
|
5
|
+
})
|
|
6
|
+
export class NumberBorderDirective {
|
|
7
|
+
@Input() maxValue: number;
|
|
8
|
+
@Input() minValue: number;
|
|
9
|
+
|
|
10
|
+
inputElement: HTMLInputElement;
|
|
11
|
+
|
|
12
|
+
constructor(public el: ElementRef) {
|
|
13
|
+
this.inputElement = el.nativeElement;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@HostListener('keyup', ['$event'])
|
|
17
|
+
onKeyUp(e): void {
|
|
18
|
+
const value = +e.target.value;
|
|
19
|
+
|
|
20
|
+
if (isNaN(value)) {
|
|
21
|
+
this.inputElement.value = this.sanitizeInput(e.target.value);
|
|
22
|
+
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (this.maxValue) {
|
|
27
|
+
if (value > this.maxValue) {
|
|
28
|
+
this.inputElement.value = this.sanitizeInput(this.maxValue.toString());
|
|
29
|
+
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (this.minValue && this.minValue !== value) {
|
|
35
|
+
if (value < this.minValue) {
|
|
36
|
+
this.inputElement.value = this.sanitizeInput(this.minValue.toString());
|
|
37
|
+
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private sanitizeInput(input: string): string {
|
|
44
|
+
let result = '';
|
|
45
|
+
const regex = new RegExp(`/\d+/g`);
|
|
46
|
+
result = input.replace(regex, '');
|
|
47
|
+
|
|
48
|
+
const maxLength = this.inputElement.maxLength;
|
|
49
|
+
|
|
50
|
+
if (maxLength > 0) {
|
|
51
|
+
const allowedLength = maxLength - this.inputElement.value.length;
|
|
52
|
+
result = allowedLength > 0 ? result.substring(0, allowedLength) : '';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Input, Output, EventEmitter, Component } from '@angular/core';
|
|
2
|
+
import { AbstractControl, UntypedFormControl } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
template: '',
|
|
6
|
+
})
|
|
7
|
+
export default class ElementBaseComponent {
|
|
8
|
+
@Input() type!:string;
|
|
9
|
+
@Input() name!:string;
|
|
10
|
+
@Input() label!:string;
|
|
11
|
+
@Input() placeholder = '';
|
|
12
|
+
@Input() validationLabel!:string;
|
|
13
|
+
@Input() disabled = false;
|
|
14
|
+
@Input() showValidation = true;
|
|
15
|
+
@Input() showValidationOnNotTouched = false;
|
|
16
|
+
@Input() hideValidationMessage = false;
|
|
17
|
+
@Input() iconClass = '';
|
|
18
|
+
@Input() loading = false;
|
|
19
|
+
@Input() showHint: boolean = false;
|
|
20
|
+
@Input() maxLength!: number;
|
|
21
|
+
@Input() tooltip!: string;
|
|
22
|
+
@Input() showAsterisk: boolean = true;
|
|
23
|
+
|
|
24
|
+
@Output() focused = new EventEmitter<any>();
|
|
25
|
+
@Output() focusOuted = new EventEmitter<any>();
|
|
26
|
+
|
|
27
|
+
control!: UntypedFormControl;
|
|
28
|
+
required: boolean = false;
|
|
29
|
+
|
|
30
|
+
getData(): any {
|
|
31
|
+
return {
|
|
32
|
+
type: this.type || 'text',
|
|
33
|
+
label: this.label,
|
|
34
|
+
placeholder: this.placeholder,
|
|
35
|
+
validationLabel: this.validationLabel,
|
|
36
|
+
disabled: this.disabled,
|
|
37
|
+
showValidation: this.showValidation,
|
|
38
|
+
showValidationOnNotTouched: this.showValidationOnNotTouched,
|
|
39
|
+
hideValidationMessage: this.hideValidationMessage,
|
|
40
|
+
iconClass: this.iconClass,
|
|
41
|
+
control: this.control,
|
|
42
|
+
loading: this.loading,
|
|
43
|
+
showHint: this.showHint,
|
|
44
|
+
maxLength: this.maxLength,
|
|
45
|
+
tooltip: this.tooltip,
|
|
46
|
+
name: this.name,
|
|
47
|
+
required: this.isRequired(this.control),
|
|
48
|
+
showAsterisk: this.showAsterisk,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private isRequired = (ctrl: any): boolean => {
|
|
53
|
+
if (ctrl?.validator) {
|
|
54
|
+
const validator = ctrl.validator({} as AbstractControl);
|
|
55
|
+
if (validator && validator['required']) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (ctrl?.['controls']) {
|
|
61
|
+
for (const name in ctrl['controls']) {
|
|
62
|
+
if (ctrl['controls'][name]) {
|
|
63
|
+
if (this.isRequired(ctrl['controls'][name])) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<div
|
|
2
|
+
class="form-field"
|
|
3
|
+
[ngClass]="{
|
|
4
|
+
'form-field--invalid':
|
|
5
|
+
data?.showValidation && (data?.control?.touched || data?.showValidationOnNotTouched) && data?.control?.invalid,
|
|
6
|
+
disabled: data?.disabled,
|
|
7
|
+
'form-field--required': data?.required && data?.showAsterisk
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
10
|
+
<div>
|
|
11
|
+
<label class="form-field__label" [attr.for]="data?.name" *ngIf="data?.label">
|
|
12
|
+
<span [innerHTML]="data?.label"></span>
|
|
13
|
+
<mat-icon class="icon" *ngIf="data?.tooltip" [matTooltip]="data?.tooltip">error_outline</mat-icon>
|
|
14
|
+
</label>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<ng-content></ng-content>
|
|
18
|
+
|
|
19
|
+
<ecabs-loading-spinner class="spinner" size="tiny" *ngIf="data.loading"></ecabs-loading-spinner>
|
|
20
|
+
|
|
21
|
+
<app-hint [element]="data?.control" [showHint]="data?.showHint" [maxValue]="data?.maxLength"></app-hint>
|
|
22
|
+
|
|
23
|
+
<ecabs-validations-messages
|
|
24
|
+
*ngIf="data?.showValidation && !data?.hideValidationMessage"
|
|
25
|
+
[element]="data?.control"
|
|
26
|
+
[label]="data?.label ? data?.label : data?.placeholder ? data.placeholder : data?.validationLabel"
|
|
27
|
+
[showValidationOnNotTouched]="data?.showValidationOnNotTouched"
|
|
28
|
+
>
|
|
29
|
+
</ecabs-validations-messages>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'app-element-wrapper',
|
|
5
|
+
templateUrl: './element-wrapper.component.html',
|
|
6
|
+
})
|
|
7
|
+
export class ElementWrapperComponent {
|
|
8
|
+
@Input() data!:any;
|
|
9
|
+
@Input() showCloseIcon!:boolean;
|
|
10
|
+
@Input() focusedFlag!:any;
|
|
11
|
+
@Input() showPassword!:boolean;
|
|
12
|
+
@Input() control!:any;
|
|
13
|
+
@Output() showHidePassword = new EventEmitter<any>();
|
|
14
|
+
@Output() clear = new EventEmitter<any>();
|
|
15
|
+
@Output() increase = new EventEmitter<any>();
|
|
16
|
+
@Output() decrease = new EventEmitter<any>();
|
|
17
|
+
|
|
18
|
+
showHidePasswordFn(event:any): void {
|
|
19
|
+
this.showHidePassword.emit(event);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
clearFn(): void {
|
|
23
|
+
this.clear.emit();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
increaseFn(): void {
|
|
27
|
+
this.increase.emit();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
decreaseFn(): void {
|
|
31
|
+
this.decrease.emit();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { NgModule } from '@angular/core';
|
|
4
|
+
import { FormsModule } from '@angular/forms';
|
|
5
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
|
+
import { MatInputModule } from '@angular/material/input';
|
|
7
|
+
|
|
8
|
+
import { HintModule } from '../hint/hint.module';
|
|
9
|
+
import { EcabsValidationModule } from '../validation/validation.module';
|
|
10
|
+
import { ElementWrapperComponent } from './element-wrapper.component';
|
|
11
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
12
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
13
|
+
import { EcabsLoadingModule } from '../../ecabs-loading/ecabs-loading.module';
|
|
14
|
+
|
|
15
|
+
@NgModule( {
|
|
16
|
+
declarations: [ ElementWrapperComponent ],
|
|
17
|
+
imports: [
|
|
18
|
+
CommonModule,
|
|
19
|
+
FormsModule,
|
|
20
|
+
EcabsLoadingModule,
|
|
21
|
+
EcabsValidationModule,
|
|
22
|
+
MatFormFieldModule,
|
|
23
|
+
MatInputModule,
|
|
24
|
+
MatIconModule,
|
|
25
|
+
MatTooltipModule,
|
|
26
|
+
HintModule,
|
|
27
|
+
],
|
|
28
|
+
exports: [ ElementWrapperComponent ],
|
|
29
|
+
} )
|
|
30
|
+
export class ElementWrapperModule { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="hint" *ngIf="element && showHint">{{ element?.value?.length || 0 }}/{{ this.maxValue }}</div>
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'app-hint',
|
|
5
|
+
templateUrl: './hint.component.html',
|
|
6
|
+
styleUrls: ['./hint.component.scss'],
|
|
7
|
+
})
|
|
8
|
+
export class HintComponent {
|
|
9
|
+
@Input() element!:any;
|
|
10
|
+
@Input() maxValue!:number;
|
|
11
|
+
@Input() showHint = false;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { FormsModule } from '@angular/forms';
|
|
4
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
5
|
+
|
|
6
|
+
import { HintComponent } from './hint.component';
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
declarations: [HintComponent],
|
|
10
|
+
imports: [CommonModule, FormsModule, MatFormFieldModule],
|
|
11
|
+
exports: [HintComponent],
|
|
12
|
+
})
|
|
13
|
+
export class HintModule {}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<div
|
|
2
|
+
class="form-field__validation"
|
|
3
|
+
*ngIf="element && (element?.touched || showValidationOnNotTouched) && element?.invalid"
|
|
4
|
+
>
|
|
5
|
+
<div class="form-field__validation__item" *ngFor="let item of element?.errors | keyvalue">
|
|
6
|
+
{{ getMessageDetail(item.key) }}
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
OnInit,
|
|
4
|
+
Input,
|
|
5
|
+
OnChanges,
|
|
6
|
+
SimpleChanges,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import {
|
|
9
|
+
EcabsComponentsConfig,
|
|
10
|
+
EcabsComponentsService,
|
|
11
|
+
} from '../../services/ecabs-components.service';
|
|
12
|
+
|
|
13
|
+
@Component( {
|
|
14
|
+
selector: 'ecabs-validations-messages',
|
|
15
|
+
templateUrl: './validation.component.html',
|
|
16
|
+
styleUrls: [ './validation.component.scss' ],
|
|
17
|
+
} )
|
|
18
|
+
export class ValidationComponent implements OnInit, OnChanges {
|
|
19
|
+
@Input() element!: any;
|
|
20
|
+
@Input() label!: string;
|
|
21
|
+
@Input() showValidationOnNotTouched = false;
|
|
22
|
+
@Input() updatedErrors!: { type: string; message: string }[];
|
|
23
|
+
config!: EcabsComponentsConfig;
|
|
24
|
+
private _messages: any = {};
|
|
25
|
+
|
|
26
|
+
get messages(): any {
|
|
27
|
+
if ( this.element ) {
|
|
28
|
+
for ( const errorKey in this.element.errors ) {
|
|
29
|
+
for ( const key in this.element.errors[ errorKey ] ) {
|
|
30
|
+
if ( this._messages[ errorKey ] ) {
|
|
31
|
+
this._messages[ errorKey ] = this._messages[ errorKey ].replace(
|
|
32
|
+
`[${ key }]`,
|
|
33
|
+
this.element.errors[ errorKey ][ key ]
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return this._messages;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
set messages( m ) {
|
|
44
|
+
this._messages = m;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
constructor( private ecabsService: EcabsComponentsService ) { }
|
|
48
|
+
|
|
49
|
+
ngOnInit() {
|
|
50
|
+
this.config = this.ecabsService.getConfig();
|
|
51
|
+
for ( let error of this.config.errorMessages ) {
|
|
52
|
+
this.messages[ error.type ] = this.replaceTokens( error.message );
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ngOnChanges( changes: SimpleChanges ): void {
|
|
57
|
+
const { updatedErrors } = changes;
|
|
58
|
+
|
|
59
|
+
if (
|
|
60
|
+
updatedErrors &&
|
|
61
|
+
updatedErrors.currentValue &&
|
|
62
|
+
updatedErrors.currentValue.length > 0
|
|
63
|
+
) {
|
|
64
|
+
for ( const error of updatedErrors.currentValue ) {
|
|
65
|
+
this.messages[ error.type ] = error.message;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
replaceTokens( message: string ): string {
|
|
71
|
+
let retMessage: string;
|
|
72
|
+
if ( this.label ) {
|
|
73
|
+
retMessage = message.replace( '[label]', this.label );
|
|
74
|
+
} else {
|
|
75
|
+
retMessage = message;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return retMessage;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getMessageDetail( key: any ): string {
|
|
82
|
+
return this.messages[ key ];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { ValidationComponent } from './validation.component';
|
|
3
|
+
import { FormsModule } from '@angular/forms';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
|
+
|
|
7
|
+
@NgModule( {
|
|
8
|
+
declarations: [ ValidationComponent ],
|
|
9
|
+
imports: [ CommonModule, FormsModule, MatFormFieldModule ],
|
|
10
|
+
exports: [ ValidationComponent ],
|
|
11
|
+
} )
|
|
12
|
+
export class EcabsValidationModule { }
|