@c10t/nice-component-library 0.0.21-e → 0.0.21-g
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/components/cva-input.component.d.ts +3 -4
- package/components/cva-live-searching.component.d.ts +1 -1
- package/components/datepicker/cva-date-picker.component.d.ts +3 -0
- package/components/datepicker/cva-range-date-picker.component.d.ts +2 -0
- package/fesm2022/c10t-nice-component-library.mjs +207 -193
- package/fesm2022/c10t-nice-component-library.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1578,7 +1578,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
1578
1578
|
|
|
1579
1579
|
class ValidatorService {
|
|
1580
1580
|
static invalid(control) {
|
|
1581
|
-
return !!control
|
|
1581
|
+
return !!control ? (control?.invalid || !!control?.errors) : false;
|
|
1582
1582
|
}
|
|
1583
1583
|
static getErrorMessage(control, errorMessages) {
|
|
1584
1584
|
if (!control) {
|
|
@@ -1654,13 +1654,13 @@ class ValidatorService {
|
|
|
1654
1654
|
if (conditions.required) {
|
|
1655
1655
|
validationFns.push(Validators.required);
|
|
1656
1656
|
}
|
|
1657
|
-
if (conditions.min != undefined
|
|
1657
|
+
if (conditions.min != undefined) {
|
|
1658
1658
|
const validationMin = (control) => {
|
|
1659
1659
|
return ValidatorService.customMinValueNsCounterInput(control.value, ValidatorService.getMinMaxDynamic(conditions.min));
|
|
1660
1660
|
};
|
|
1661
1661
|
validationFns.push(validationMin);
|
|
1662
1662
|
}
|
|
1663
|
-
if (conditions.max != undefined
|
|
1663
|
+
if (conditions.max != undefined) {
|
|
1664
1664
|
const validationMax = (control) => {
|
|
1665
1665
|
return ValidatorService.customMaxValueNsCounterInput(control.value, ValidatorService.getMinMaxDynamic(conditions.max));
|
|
1666
1666
|
};
|
|
@@ -1673,12 +1673,6 @@ class ValidatorService {
|
|
|
1673
1673
|
if (conditions.required) {
|
|
1674
1674
|
validationFns.push(Validators.required);
|
|
1675
1675
|
}
|
|
1676
|
-
// if (conditions.min) {
|
|
1677
|
-
// validationFns.push(new NsValidator({minDate: conditions.min}).customMinDateValidator());
|
|
1678
|
-
// }
|
|
1679
|
-
// if (conditions.max) {
|
|
1680
|
-
// validationFns.push(new NsValidator({maxDate: conditions.max}).customMaxDateValidator());
|
|
1681
|
-
// }
|
|
1682
1676
|
return validationFns;
|
|
1683
1677
|
}
|
|
1684
1678
|
static getRequiredDynamic(isRequired) {
|
|
@@ -1686,8 +1680,6 @@ class ValidatorService {
|
|
|
1686
1680
|
}
|
|
1687
1681
|
static generateNsDateRangePickerValidators(conditions) {
|
|
1688
1682
|
const validationFns = [];
|
|
1689
|
-
// if (NsValidator.getRequiredDynamic(conditions.requiredFromDate)
|
|
1690
|
-
// || NsValidator.getRequiredDynamic(conditions.requiredToDate)) {
|
|
1691
1683
|
const validation = (control) => {
|
|
1692
1684
|
const range = control.value;
|
|
1693
1685
|
if (!range?.fromDate && ValidatorService.getRequiredDynamic(conditions.requiredFromDate)) {
|
|
@@ -1699,12 +1691,8 @@ class ValidatorService {
|
|
|
1699
1691
|
return null;
|
|
1700
1692
|
};
|
|
1701
1693
|
validationFns.push(validation);
|
|
1702
|
-
// }
|
|
1703
1694
|
return validationFns;
|
|
1704
1695
|
}
|
|
1705
|
-
// customMinDateValidator(): ValidatorFn {
|
|
1706
|
-
// return this.customMinDateValidatorControl;
|
|
1707
|
-
// }
|
|
1708
1696
|
static customMinDateValidatorControl(value, minDate) {
|
|
1709
1697
|
if (!minDate || !value) {
|
|
1710
1698
|
return null;
|
|
@@ -1715,9 +1703,6 @@ class ValidatorService {
|
|
|
1715
1703
|
}
|
|
1716
1704
|
return null;
|
|
1717
1705
|
}
|
|
1718
|
-
// customMaxDateValidator(): ValidatorFn {
|
|
1719
|
-
// return this.customMaxDateValidatorControl;
|
|
1720
|
-
// }
|
|
1721
1706
|
static customMaxDateValidatorControl(value, maxDate) {
|
|
1722
1707
|
if (!maxDate || !value) {
|
|
1723
1708
|
return null;
|
|
@@ -1747,96 +1732,113 @@ class ValidatorService {
|
|
|
1747
1732
|
return null;
|
|
1748
1733
|
}
|
|
1749
1734
|
static generateNsSmartTableValidators(conditions) {
|
|
1750
|
-
|
|
1735
|
+
return (control) => {
|
|
1751
1736
|
let errors = null;
|
|
1752
|
-
if (control) {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1737
|
+
if (!control) {
|
|
1738
|
+
return errors;
|
|
1739
|
+
}
|
|
1740
|
+
const controlValueLength = control.value ? control.value.length : 0;
|
|
1741
|
+
if (conditions.minRow > controlValueLength) {
|
|
1742
|
+
return { minRow: { valid: false, min: conditions.minRow, actual: controlValueLength } };
|
|
1743
|
+
}
|
|
1744
|
+
if (conditions.maxRow < controlValueLength) {
|
|
1745
|
+
return { maxRow: { valid: false, max: conditions.maxRow, actual: controlValueLength } };
|
|
1746
|
+
}
|
|
1747
|
+
if (!control.value) {
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
control.value.forEach((row) => {
|
|
1751
|
+
if (errors || !conditions.columns) {
|
|
1752
|
+
return;
|
|
1762
1753
|
}
|
|
1763
|
-
|
|
1764
|
-
if (errors
|
|
1754
|
+
conditions.columns.forEach((column) => {
|
|
1755
|
+
if (errors) {
|
|
1765
1756
|
return;
|
|
1766
1757
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1758
|
+
const tempControl = new FormControl();
|
|
1759
|
+
tempControl.setValue(row[column.columnDef]);
|
|
1760
|
+
const columnType = TableService.getColumnType(column, row);
|
|
1761
|
+
if (columnType === ColumnTypeEnum.MULTI_SELECT_AUTOCOMPLETE) {
|
|
1762
|
+
if (ValidatorService.getRequired(column)) {
|
|
1763
|
+
tempControl.setValidators(Validators.required);
|
|
1770
1764
|
}
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1765
|
+
}
|
|
1766
|
+
else if (columnType === ColumnTypeEnum.INPUT_COUNTER) {
|
|
1767
|
+
tempControl.setValidators(ValidatorService.generateNsCounterInputValidators({
|
|
1768
|
+
required: ValidatorService.getRequired(column),
|
|
1769
|
+
min: null,
|
|
1770
|
+
max: null,
|
|
1771
|
+
isDecimal: ValidatorService.getIsDecimal(column),
|
|
1772
|
+
}));
|
|
1773
|
+
}
|
|
1774
|
+
else if (columnType === ColumnTypeEnum.INPUT_CURRENCY) {
|
|
1775
|
+
tempControl.setValidators(ValidatorService.generateNsCounterInputValidators({
|
|
1776
|
+
required: ValidatorService.getRequired(column),
|
|
1777
|
+
min: null,
|
|
1778
|
+
max: null,
|
|
1779
|
+
isDecimal: ValidatorService.getIsDecimal(column),
|
|
1780
|
+
}));
|
|
1781
|
+
}
|
|
1782
|
+
else if (columnType === ColumnTypeEnum.DATE_PICKER) {
|
|
1783
|
+
tempControl.setValidators(ValidatorService.generateNsDatePickerValidators({
|
|
1784
|
+
required: ValidatorService.getRequired(column),
|
|
1785
|
+
min: null,
|
|
1786
|
+
max: null,
|
|
1787
|
+
}));
|
|
1788
|
+
}
|
|
1789
|
+
else if (columnType === ColumnTypeEnum.INPUT) {
|
|
1790
|
+
tempControl.setValidators(ValidatorService.generateNsInputValidators({
|
|
1791
|
+
required: ValidatorService.getRequired(column),
|
|
1792
|
+
maxLength: column.max ? column.max(row) : undefined,
|
|
1793
|
+
minLength: column.min ? column.min(row) : undefined,
|
|
1794
|
+
pattern: undefined,
|
|
1795
|
+
}));
|
|
1796
|
+
}
|
|
1797
|
+
else if (columnType === ColumnTypeEnum.LIVE_SEARCHING) {
|
|
1798
|
+
tempControl.setValidators(ValidatorService.generateNsInputValidators({
|
|
1799
|
+
required: ValidatorService.getRequired(column),
|
|
1800
|
+
maxLength: column.max ? column.max(row) : undefined,
|
|
1801
|
+
minLength: column.min ? column.min(row) : undefined,
|
|
1802
|
+
pattern: undefined,
|
|
1803
|
+
}));
|
|
1804
|
+
}
|
|
1805
|
+
tempControl.updateValueAndValidity();
|
|
1806
|
+
if (columnType === ColumnTypeEnum.DATE_PICKER) {
|
|
1807
|
+
const errorsArr = [];
|
|
1808
|
+
if (tempControl.errors) {
|
|
1809
|
+
errorsArr.push(tempControl.errors);
|
|
1777
1810
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
required: ValidatorService.getRequired(column),
|
|
1781
|
-
min: null,
|
|
1782
|
-
max: null,
|
|
1783
|
-
isDecimal: ValidatorService.getIsDecimal(column),
|
|
1784
|
-
}));
|
|
1811
|
+
if (ValidatorService.customMinDateValidatorControl(tempControl.value, column.min ? column.min(row) : null)) {
|
|
1812
|
+
errorsArr.push(ValidatorService.customMinDateValidatorControl(tempControl.value, column.min ? column.min(row) : null));
|
|
1785
1813
|
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
required: ValidatorService.getRequired(column),
|
|
1789
|
-
min: null,
|
|
1790
|
-
max: null,
|
|
1791
|
-
}));
|
|
1814
|
+
if (ValidatorService.customMaxDateValidatorControl(tempControl.value, column.max ? column.max(row) : null)) {
|
|
1815
|
+
errorsArr.push(ValidatorService.customMaxDateValidatorControl(tempControl.value, column.max ? column.max(row) : null));
|
|
1792
1816
|
}
|
|
1793
|
-
|
|
1794
|
-
tempControl.
|
|
1795
|
-
required: ValidatorService.getRequired(column),
|
|
1796
|
-
maxLength: column.max ? column.max(row) : undefined,
|
|
1797
|
-
minLength: column.min ? column.min(row) : undefined,
|
|
1798
|
-
pattern: undefined,
|
|
1799
|
-
}));
|
|
1817
|
+
if (errorsArr.length > 0) {
|
|
1818
|
+
tempControl.setErrors(errorsArr);
|
|
1800
1819
|
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
}
|
|
1807
|
-
if (ValidatorService.customMinDateValidatorControl(tempControl.value, column.min ? column.min(row) : null)) {
|
|
1808
|
-
errorsArr.push(ValidatorService.customMinDateValidatorControl(tempControl.value, column.min ? column.min(row) : null));
|
|
1809
|
-
}
|
|
1810
|
-
if (ValidatorService.customMaxDateValidatorControl(tempControl.value, column.max ? column.max(row) : null)) {
|
|
1811
|
-
errorsArr.push(ValidatorService.customMaxDateValidatorControl(tempControl.value, column.max ? column.max(row) : null));
|
|
1812
|
-
}
|
|
1813
|
-
if (errorsArr.length > 0) {
|
|
1814
|
-
tempControl.setErrors(errorsArr);
|
|
1815
|
-
}
|
|
1820
|
+
}
|
|
1821
|
+
if (columnType === ColumnTypeEnum.INPUT_COUNTER || columnType === ColumnTypeEnum.INPUT_CURRENCY) {
|
|
1822
|
+
const errorsArr = [];
|
|
1823
|
+
if (tempControl.errors) {
|
|
1824
|
+
errorsArr.push(tempControl.errors);
|
|
1816
1825
|
}
|
|
1817
|
-
if (
|
|
1818
|
-
|
|
1819
|
-
if (tempControl.errors) {
|
|
1820
|
-
errorsArr.push(tempControl.errors);
|
|
1821
|
-
}
|
|
1822
|
-
if (ValidatorService.customMinValueNsCounterInput(tempControl.value, column.min ? column.min(row) : null)) {
|
|
1823
|
-
errorsArr.push(ValidatorService.customMinValueNsCounterInput(tempControl.value, column.min ? column.min(row) : null));
|
|
1824
|
-
}
|
|
1825
|
-
if (ValidatorService.customMaxValueNsCounterInput(tempControl.value, column.max ? column.max(row) : null)) {
|
|
1826
|
-
errorsArr.push(ValidatorService.customMaxValueNsCounterInput(tempControl.value, column.max ? column.max(row) : null));
|
|
1827
|
-
}
|
|
1828
|
-
if (errorsArr.length > 0) {
|
|
1829
|
-
tempControl.setErrors(errorsArr);
|
|
1830
|
-
}
|
|
1826
|
+
if (ValidatorService.customMinValueNsCounterInput(tempControl.value, column.min ? column.min(row) : null)) {
|
|
1827
|
+
errorsArr.push(ValidatorService.customMinValueNsCounterInput(tempControl.value, column.min ? column.min(row) : null));
|
|
1831
1828
|
}
|
|
1832
|
-
tempControl.
|
|
1833
|
-
|
|
1834
|
-
|
|
1829
|
+
if (ValidatorService.customMaxValueNsCounterInput(tempControl.value, column.max ? column.max(row) : null)) {
|
|
1830
|
+
errorsArr.push(ValidatorService.customMaxValueNsCounterInput(tempControl.value, column.max ? column.max(row) : null));
|
|
1831
|
+
}
|
|
1832
|
+
if (errorsArr.length > 0) {
|
|
1833
|
+
tempControl.setErrors(errorsArr);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
tempControl.markAllAsTouched();
|
|
1837
|
+
errors = tempControl.errors;
|
|
1835
1838
|
});
|
|
1836
|
-
}
|
|
1839
|
+
});
|
|
1837
1840
|
return errors;
|
|
1838
1841
|
};
|
|
1839
|
-
return validator;
|
|
1840
1842
|
}
|
|
1841
1843
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: ValidatorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1842
1844
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: ValidatorService, providedIn: 'root' });
|
|
@@ -2006,7 +2008,7 @@ class CvaCounterInputComponent {
|
|
|
2006
2008
|
{{ hint | translate }}
|
|
2007
2009
|
</mat-hint>
|
|
2008
2010
|
<mat-hint style="color: red" *ngIf="NsValidator.invalid(formControl)">
|
|
2009
|
-
{{ NsValidator.
|
|
2011
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
2010
2012
|
</mat-hint>
|
|
2011
2013
|
</mat-form-field>
|
|
2012
2014
|
|
|
@@ -2062,7 +2064,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
2062
2064
|
{{ hint | translate }}
|
|
2063
2065
|
</mat-hint>
|
|
2064
2066
|
<mat-hint style="color: red" *ngIf="NsValidator.invalid(formControl)">
|
|
2065
|
-
{{ NsValidator.
|
|
2067
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
2066
2068
|
</mat-hint>
|
|
2067
2069
|
</mat-form-field>
|
|
2068
2070
|
|
|
@@ -3327,7 +3329,7 @@ class CvaInputComponent {
|
|
|
3327
3329
|
// Chỉ bằng false khi trong NsSmartTable thôi nhé @@
|
|
3328
3330
|
isFormControl = true;
|
|
3329
3331
|
formatFunc;
|
|
3330
|
-
|
|
3332
|
+
formControl = undefined;
|
|
3331
3333
|
config;
|
|
3332
3334
|
constructor(injector, ngControl) {
|
|
3333
3335
|
this.injector = injector;
|
|
@@ -3346,42 +3348,34 @@ class CvaInputComponent {
|
|
|
3346
3348
|
set textValue(val) {
|
|
3347
3349
|
this.writeValue(val);
|
|
3348
3350
|
}
|
|
3349
|
-
// Vì không thể quất được NgControl ở constructor nên phải quất ở đây :(
|
|
3350
|
-
ngAfterViewInit() {
|
|
3351
|
-
// const ngControl = this.injector.get(NgControl);
|
|
3352
|
-
// if (ngControl) {
|
|
3353
|
-
// this.control = ngControl.control;
|
|
3354
|
-
// this.callValidator();
|
|
3355
|
-
// }
|
|
3356
|
-
}
|
|
3357
3351
|
ngOnInit() {
|
|
3358
3352
|
this.callValidator();
|
|
3359
3353
|
}
|
|
3360
3354
|
callValidator() {
|
|
3361
3355
|
const ngControl = this.injector.get(NgControl);
|
|
3362
3356
|
// Nếu parent FormControl khởi tạo xong và formControl chưa có giá trị lưu
|
|
3363
|
-
if (ngControl && !this.
|
|
3357
|
+
if (ngControl && !this.formControl) {
|
|
3364
3358
|
// Nếu là NsSmartTable thì phải tự new FormControl còn không thì cứ hóng parent FormControl về ^^
|
|
3365
3359
|
if (this.isFormControl) {
|
|
3366
|
-
this.
|
|
3360
|
+
this.formControl = ngControl.control ? ngControl.control : undefined;
|
|
3367
3361
|
}
|
|
3368
3362
|
else {
|
|
3369
|
-
this.
|
|
3363
|
+
this.formControl = new FormControl();
|
|
3370
3364
|
}
|
|
3371
3365
|
// Hành động này gắn validator vào this.formControl
|
|
3372
3366
|
// - Nếu this.formControl là parent FormControl thì sẽ show error lên FormGroup
|
|
3373
3367
|
// - Nếu this.formControl là new FormControl thì sẽ quét QueryList để check {errors}
|
|
3374
|
-
if (this.
|
|
3375
|
-
if (this.
|
|
3376
|
-
this.
|
|
3368
|
+
if (this.formControl) {
|
|
3369
|
+
if (this.formControl.validator) {
|
|
3370
|
+
this.formControl.setValidators([...ValidatorService.generateNsInputValidators({
|
|
3377
3371
|
required: this.required,
|
|
3378
3372
|
minLength: this.minLength,
|
|
3379
3373
|
maxLength: this.maxLength,
|
|
3380
3374
|
pattern: this.pattern,
|
|
3381
|
-
}), this.
|
|
3375
|
+
}), this.formControl.validator]);
|
|
3382
3376
|
}
|
|
3383
3377
|
else {
|
|
3384
|
-
this.
|
|
3378
|
+
this.formControl.setValidators([...ValidatorService.generateNsInputValidators({
|
|
3385
3379
|
required: this.required,
|
|
3386
3380
|
minLength: this.minLength,
|
|
3387
3381
|
maxLength: this.maxLength,
|
|
@@ -3390,13 +3384,13 @@ class CvaInputComponent {
|
|
|
3390
3384
|
}
|
|
3391
3385
|
}
|
|
3392
3386
|
}
|
|
3393
|
-
if (this.
|
|
3387
|
+
if (this.formControl) {
|
|
3394
3388
|
// Nếu this.formControl thuộc NsSmartTable thì setValue lại
|
|
3395
3389
|
if (!this.isFormControl) {
|
|
3396
|
-
this.
|
|
3390
|
+
this.formControl.setValue(this.text);
|
|
3397
3391
|
}
|
|
3398
3392
|
// Nếu là parent FormControl rồi thì kệ
|
|
3399
|
-
this.
|
|
3393
|
+
this.formControl.updateValueAndValidity();
|
|
3400
3394
|
}
|
|
3401
3395
|
}
|
|
3402
3396
|
propagateChange = (_) => {
|
|
@@ -3452,25 +3446,25 @@ class CvaInputComponent {
|
|
|
3452
3446
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: CvaInputComponent, isStandalone: false, selector: "cva-input", inputs: { label: "label", name: "name", placeholder: "placeholder", hint: "hint", required: "required", disabled: "disabled", text: "text", type: "type", pattern: "pattern", errorMessages: "errorMessages", multiline: "multiline", isLabelOutside: "isLabelOutside", isFloatLabel: "isFloatLabel", minLength: "minLength", maxLength: "maxLength", alignText: "alignText", maxLengthDisplay: "maxLengthDisplay", percentOfLabelOutside: "percentOfLabelOutside", suffixFontAwesomeClass: "suffixFontAwesomeClass", patternFilter: "patternFilter", isFormControl: "isFormControl", formatFunc: "formatFunc" }, outputs: { onChange: "onChange" }, ngImport: i0, template: `
|
|
3453
3447
|
<!-- css labelOutside trong base.theme-->
|
|
3454
3448
|
<div class="cva-input"
|
|
3455
|
-
[ngClass]="{'labelOutside':
|
|
3456
|
-
'float_label':
|
|
3457
|
-
'text_area':
|
|
3449
|
+
[ngClass]="{'labelOutside': isLabelOutside,
|
|
3450
|
+
'float_label': isFloatLabel && !isLabelOutside,
|
|
3451
|
+
'text_area': this.multiline}"
|
|
3458
3452
|
fxLayout="row" fxLayout.lt-sm="row wrap">
|
|
3459
3453
|
<mat-label *ngIf="isLabelOutside" class="label_width"
|
|
3460
3454
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
3461
3455
|
<div class="label">
|
|
3462
3456
|
<div>
|
|
3463
3457
|
{{ (label ? label : placeholder) | translate }}<span
|
|
3464
|
-
class="required-label-outside">{{
|
|
3458
|
+
class="required-label-outside">{{ required ? '*' : '' }}</span>
|
|
3465
3459
|
</div>
|
|
3466
3460
|
</div>
|
|
3467
3461
|
</mat-label>
|
|
3468
3462
|
<mat-form-field *ngIf="isShowControl()"
|
|
3469
|
-
appearance="outline" [floatLabel]="
|
|
3463
|
+
appearance="outline" [floatLabel]="isFloatLabel ? 'always' : 'auto'"
|
|
3470
3464
|
[ngClass]="{'cva-input-multiline': multiline}"
|
|
3471
3465
|
[hideRequiredMarker]="!isFloatLabel"
|
|
3472
3466
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
3473
|
-
<mat-label *ngIf="!isLabelOutside &&
|
|
3467
|
+
<mat-label *ngIf="!isLabelOutside && isFloatLabel" [ngClass]="{'cva-input-multiline': multiline}">
|
|
3474
3468
|
{{ (label ? label : placeholder) | translate }}
|
|
3475
3469
|
</mat-label>
|
|
3476
3470
|
<input matInput placeholder="{{placeholder|translate}}" [type]="type" [(ngModel)]="textValue"
|
|
@@ -3508,9 +3502,9 @@ class CvaInputComponent {
|
|
|
3508
3502
|
type="button">
|
|
3509
3503
|
<mat-icon>clear</mat-icon>
|
|
3510
3504
|
</button>
|
|
3511
|
-
<mat-hint align="start" *ngIf="!NsValidator.invalid(
|
|
3512
|
-
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(
|
|
3513
|
-
{{ NsValidator.getErrorMessageV1(
|
|
3505
|
+
<mat-hint align="start" *ngIf="!NsValidator.invalid(formControl)">{{ hint | translate }}</mat-hint>
|
|
3506
|
+
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(formControl)">
|
|
3507
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
3514
3508
|
</mat-hint>
|
|
3515
3509
|
</mat-form-field>
|
|
3516
3510
|
|
|
@@ -3535,25 +3529,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
3535
3529
|
template: `
|
|
3536
3530
|
<!-- css labelOutside trong base.theme-->
|
|
3537
3531
|
<div class="cva-input"
|
|
3538
|
-
[ngClass]="{'labelOutside':
|
|
3539
|
-
'float_label':
|
|
3540
|
-
'text_area':
|
|
3532
|
+
[ngClass]="{'labelOutside': isLabelOutside,
|
|
3533
|
+
'float_label': isFloatLabel && !isLabelOutside,
|
|
3534
|
+
'text_area': this.multiline}"
|
|
3541
3535
|
fxLayout="row" fxLayout.lt-sm="row wrap">
|
|
3542
3536
|
<mat-label *ngIf="isLabelOutside" class="label_width"
|
|
3543
3537
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
3544
3538
|
<div class="label">
|
|
3545
3539
|
<div>
|
|
3546
3540
|
{{ (label ? label : placeholder) | translate }}<span
|
|
3547
|
-
class="required-label-outside">{{
|
|
3541
|
+
class="required-label-outside">{{ required ? '*' : '' }}</span>
|
|
3548
3542
|
</div>
|
|
3549
3543
|
</div>
|
|
3550
3544
|
</mat-label>
|
|
3551
3545
|
<mat-form-field *ngIf="isShowControl()"
|
|
3552
|
-
appearance="outline" [floatLabel]="
|
|
3546
|
+
appearance="outline" [floatLabel]="isFloatLabel ? 'always' : 'auto'"
|
|
3553
3547
|
[ngClass]="{'cva-input-multiline': multiline}"
|
|
3554
3548
|
[hideRequiredMarker]="!isFloatLabel"
|
|
3555
3549
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
3556
|
-
<mat-label *ngIf="!isLabelOutside &&
|
|
3550
|
+
<mat-label *ngIf="!isLabelOutside && isFloatLabel" [ngClass]="{'cva-input-multiline': multiline}">
|
|
3557
3551
|
{{ (label ? label : placeholder) | translate }}
|
|
3558
3552
|
</mat-label>
|
|
3559
3553
|
<input matInput placeholder="{{placeholder|translate}}" [type]="type" [(ngModel)]="textValue"
|
|
@@ -3591,9 +3585,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
3591
3585
|
type="button">
|
|
3592
3586
|
<mat-icon>clear</mat-icon>
|
|
3593
3587
|
</button>
|
|
3594
|
-
<mat-hint align="start" *ngIf="!NsValidator.invalid(
|
|
3595
|
-
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(
|
|
3596
|
-
{{ NsValidator.getErrorMessageV1(
|
|
3588
|
+
<mat-hint align="start" *ngIf="!NsValidator.invalid(formControl)">{{ hint | translate }}</mat-hint>
|
|
3589
|
+
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(formControl)">
|
|
3590
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
3597
3591
|
</mat-hint>
|
|
3598
3592
|
</mat-form-field>
|
|
3599
3593
|
|
|
@@ -3772,6 +3766,7 @@ class CvaDatePickerComponent {
|
|
|
3772
3766
|
// Chỉ bằng false khi trong NsSmartTable thôi @@
|
|
3773
3767
|
isFormControl = true;
|
|
3774
3768
|
formControl;
|
|
3769
|
+
datepicker;
|
|
3775
3770
|
constructor(dateServiceUtil, ngControl, injector) {
|
|
3776
3771
|
this.dateServiceUtil = dateServiceUtil;
|
|
3777
3772
|
this.injector = injector;
|
|
@@ -3912,6 +3907,12 @@ class CvaDatePickerComponent {
|
|
|
3912
3907
|
isShowControl() {
|
|
3913
3908
|
return !this.disabled || (this.disabled && this.config && this.config.STYLE_DISABLE === 'CONTROL');
|
|
3914
3909
|
}
|
|
3910
|
+
openDatepicker(event) {
|
|
3911
|
+
if (!this.disabled && this.datepicker) {
|
|
3912
|
+
event.stopPropagation();
|
|
3913
|
+
this.datepicker.open();
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3915
3916
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: CvaDatePickerComponent, deps: [{ token: DateUtilService }, { token: i1$2.NgControl, optional: true, self: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
|
|
3916
3917
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: CvaDatePickerComponent, isStandalone: false, selector: "cva-date-picker", inputs: { label: "label", placeholder: "placeholder", value: "value", disabled: "disabled", required: "required", minDate: "minDate", maxDate: "maxDate", errorMessages: "errorMessages", isLabelOutside: "isLabelOutside", isFloatLabel: "isFloatLabel", percentOfLabelOutside: "percentOfLabelOutside", isFormControl: "isFormControl" }, outputs: { onChange: "onChange" }, providers: [
|
|
3917
3918
|
{ provide: DateAdapter, useClass: NsDateAdapter },
|
|
@@ -3919,7 +3920,7 @@ class CvaDatePickerComponent {
|
|
|
3919
3920
|
provide: MAT_DATE_FORMATS,
|
|
3920
3921
|
useValue: APP_DATE_FORMATS,
|
|
3921
3922
|
},
|
|
3922
|
-
], ngImport: i0, template: `
|
|
3923
|
+
], viewQueries: [{ propertyName: "datepicker", first: true, predicate: ["xDatepicker"], descendants: true }], ngImport: i0, template: `
|
|
3923
3924
|
<!-- css labelOutside trong base.theme-->
|
|
3924
3925
|
<div class="cva-date-picker"
|
|
3925
3926
|
[ngClass]="{'labelOutside': isLabelOutside, 'float_label': isFloatLabel && !isLabelOutside}"
|
|
@@ -3945,7 +3946,8 @@ class CvaDatePickerComponent {
|
|
|
3945
3946
|
[readonly]="true"
|
|
3946
3947
|
[required]="checkRequired(required)"
|
|
3947
3948
|
[title]="title ? title : ''"
|
|
3948
|
-
[min]="getMinDate()" [max]="getMaxDate()"
|
|
3949
|
+
[min]="getMinDate()" [max]="getMaxDate()"
|
|
3950
|
+
(click)="openDatepicker($event)">
|
|
3949
3951
|
<mat-datepicker-toggle matPrefix [for]="xDatepicker" [disabled]="disabled"></mat-datepicker-toggle>
|
|
3950
3952
|
<mat-datepicker #xDatepicker></mat-datepicker>
|
|
3951
3953
|
<button mat-icon-button color="warn" class="btnDatePicker" matSuffix (click)="onClear()" [disabled]="disabled">
|
|
@@ -3953,7 +3955,7 @@ class CvaDatePickerComponent {
|
|
|
3953
3955
|
</button>
|
|
3954
3956
|
|
|
3955
3957
|
<mat-hint style="color: red" *ngIf="NsValidator.invalid(formControl)">
|
|
3956
|
-
{{ NsValidator.
|
|
3958
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
3957
3959
|
</mat-hint>
|
|
3958
3960
|
|
|
3959
3961
|
</mat-form-field>
|
|
@@ -4002,7 +4004,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4002
4004
|
[readonly]="true"
|
|
4003
4005
|
[required]="checkRequired(required)"
|
|
4004
4006
|
[title]="title ? title : ''"
|
|
4005
|
-
[min]="getMinDate()" [max]="getMaxDate()"
|
|
4007
|
+
[min]="getMinDate()" [max]="getMaxDate()"
|
|
4008
|
+
(click)="openDatepicker($event)">
|
|
4006
4009
|
<mat-datepicker-toggle matPrefix [for]="xDatepicker" [disabled]="disabled"></mat-datepicker-toggle>
|
|
4007
4010
|
<mat-datepicker #xDatepicker></mat-datepicker>
|
|
4008
4011
|
<button mat-icon-button color="warn" class="btnDatePicker" matSuffix (click)="onClear()" [disabled]="disabled">
|
|
@@ -4010,7 +4013,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4010
4013
|
</button>
|
|
4011
4014
|
|
|
4012
4015
|
<mat-hint style="color: red" *ngIf="NsValidator.invalid(formControl)">
|
|
4013
|
-
{{ NsValidator.
|
|
4016
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
4014
4017
|
</mat-hint>
|
|
4015
4018
|
|
|
4016
4019
|
</mat-form-field>
|
|
@@ -4065,6 +4068,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4065
4068
|
type: Input
|
|
4066
4069
|
}], isFormControl: [{
|
|
4067
4070
|
type: Input
|
|
4071
|
+
}], datepicker: [{
|
|
4072
|
+
type: ViewChild,
|
|
4073
|
+
args: ['xDatepicker']
|
|
4068
4074
|
}] } });
|
|
4069
4075
|
|
|
4070
4076
|
class CvaMultiSelectAutocomplete {
|
|
@@ -4445,7 +4451,7 @@ class CvaMultiSelectAutocomplete {
|
|
|
4445
4451
|
<mat-icon matSuffix>expand_more</mat-icon>
|
|
4446
4452
|
<mat-hint *ngIf="!NsValidator.invalid(formControl)">{{ hint | translate }}</mat-hint>
|
|
4447
4453
|
<mat-hint style="color: red" *ngIf="NsValidator.invalid(formControl)">
|
|
4448
|
-
{{ NsValidator.
|
|
4454
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
4449
4455
|
</mat-hint>
|
|
4450
4456
|
</mat-form-field>
|
|
4451
4457
|
<ng-container *ngIf="!isShowControl()">
|
|
@@ -4542,7 +4548,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4542
4548
|
<mat-icon matSuffix>expand_more</mat-icon>
|
|
4543
4549
|
<mat-hint *ngIf="!NsValidator.invalid(formControl)">{{ hint | translate }}</mat-hint>
|
|
4544
4550
|
<mat-hint style="color: red" *ngIf="NsValidator.invalid(formControl)">
|
|
4545
|
-
{{ NsValidator.
|
|
4551
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
4546
4552
|
</mat-hint>
|
|
4547
4553
|
</mat-form-field>
|
|
4548
4554
|
<ng-container *ngIf="!isShowControl()">
|
|
@@ -4626,7 +4632,7 @@ class CvaLiveSearchingComponent {
|
|
|
4626
4632
|
isFormControl = true;
|
|
4627
4633
|
row;
|
|
4628
4634
|
columnDef;
|
|
4629
|
-
|
|
4635
|
+
formControl = undefined;
|
|
4630
4636
|
textControl = new FormControl('');
|
|
4631
4637
|
filteredOptions = [];
|
|
4632
4638
|
selected;
|
|
@@ -4654,37 +4660,37 @@ class CvaLiveSearchingComponent {
|
|
|
4654
4660
|
callValidator() {
|
|
4655
4661
|
const ngControl = this.injector.get(NgControl);
|
|
4656
4662
|
// Nếu parent FormControl khởi tạo xong và formControl chưa có giá trị lưu
|
|
4657
|
-
if (ngControl && !this.
|
|
4663
|
+
if (ngControl && !this.formControl) {
|
|
4658
4664
|
// Nếu là NsSmartTable thì phải tự new FormControl còn không thì cứ hóng parent FormControl về ^^
|
|
4659
4665
|
if (this.isFormControl) {
|
|
4660
|
-
this.
|
|
4666
|
+
this.formControl = ngControl.control ? ngControl.control : undefined;
|
|
4661
4667
|
}
|
|
4662
4668
|
else {
|
|
4663
|
-
this.
|
|
4669
|
+
this.formControl = new FormControl();
|
|
4664
4670
|
}
|
|
4665
4671
|
// Hành động này gắn validator vào this.formControl
|
|
4666
4672
|
// - Nếu this.formControl là parent FormControl thì sẽ show error lên FormGroup
|
|
4667
4673
|
// - Nếu this.formControl là new FormControl thì sẽ quét QueryList để check {errors}
|
|
4668
|
-
if (this.
|
|
4669
|
-
if (this.
|
|
4670
|
-
this.
|
|
4674
|
+
if (this.formControl) {
|
|
4675
|
+
if (this.formControl.validator) {
|
|
4676
|
+
this.formControl.setValidators([...ValidatorService.generateNsAutocompleteValidators({
|
|
4671
4677
|
required: this.required,
|
|
4672
|
-
}), this.
|
|
4678
|
+
}), this.formControl.validator]);
|
|
4673
4679
|
}
|
|
4674
4680
|
else {
|
|
4675
|
-
this.
|
|
4681
|
+
this.formControl.setValidators([...ValidatorService.generateNsAutocompleteValidators({
|
|
4676
4682
|
required: this.required,
|
|
4677
4683
|
})]);
|
|
4678
4684
|
}
|
|
4679
4685
|
}
|
|
4680
4686
|
}
|
|
4681
|
-
if (this.
|
|
4687
|
+
if (this.formControl) {
|
|
4682
4688
|
// Nếu this.formControl thuộc NsSmartTable thì setValue lại
|
|
4683
4689
|
if (!this.isFormControl) {
|
|
4684
|
-
this.
|
|
4690
|
+
this.formControl.setValue(this.selected);
|
|
4685
4691
|
}
|
|
4686
4692
|
// Nếu là parent FormControl rồi thì kệ
|
|
4687
|
-
this.
|
|
4693
|
+
this.formControl.updateValueAndValidity();
|
|
4688
4694
|
}
|
|
4689
4695
|
}
|
|
4690
4696
|
propagateChange = (_) => {
|
|
@@ -4709,20 +4715,13 @@ class CvaLiveSearchingComponent {
|
|
|
4709
4715
|
*/
|
|
4710
4716
|
writeValue(obj) {
|
|
4711
4717
|
if (!obj || typeof obj !== 'string') {
|
|
4712
|
-
this.selected = {};
|
|
4713
4718
|
this.filteredOptions.length = 0;
|
|
4714
4719
|
this.filteredOptions = [];
|
|
4715
|
-
this.textControl.setValue('', { emitEvent: false });
|
|
4716
|
-
this.updateRowOrFormGroup();
|
|
4717
|
-
return;
|
|
4718
4720
|
}
|
|
4719
4721
|
const matched = this.filteredOptions.find(opt => {
|
|
4720
4722
|
return JSON.stringify(opt[this.displayKey] ?? '') === JSON.stringify(obj ?? '');
|
|
4721
4723
|
});
|
|
4722
|
-
if (!matched) {
|
|
4723
|
-
if (!this.searchFn) {
|
|
4724
|
-
return;
|
|
4725
|
-
}
|
|
4724
|
+
if (!matched && this.searchFn && !!obj) {
|
|
4726
4725
|
// Khi textValueChange chưa chạy không tìm thấy
|
|
4727
4726
|
this.searchFn(obj).subscribe(values => {
|
|
4728
4727
|
if (values && values.length > 0) {
|
|
@@ -4732,8 +4731,9 @@ class CvaLiveSearchingComponent {
|
|
|
4732
4731
|
});
|
|
4733
4732
|
return;
|
|
4734
4733
|
}
|
|
4735
|
-
this.selected = matched;
|
|
4736
|
-
this.textControl.setValue(matched[this.displayKey], { emitEvent: false });
|
|
4734
|
+
this.selected = matched ?? null;
|
|
4735
|
+
this.textControl.setValue(matched ? matched[this.displayKey] : '', { emitEvent: false });
|
|
4736
|
+
this.callValidator();
|
|
4737
4737
|
this.updateRowOrFormGroup();
|
|
4738
4738
|
}
|
|
4739
4739
|
onOptionSelect(displayValue) {
|
|
@@ -4762,22 +4762,22 @@ class CvaLiveSearchingComponent {
|
|
|
4762
4762
|
if (!this.isFormControl && this.row) {
|
|
4763
4763
|
for (const targetKey in this.mappingConfig) {
|
|
4764
4764
|
const sourceKey = this.mappingConfig[targetKey];
|
|
4765
|
-
this.row[targetKey] = this.selected[sourceKey];
|
|
4765
|
+
this.row[targetKey] = !!this.selected ? this.selected[sourceKey] : '';
|
|
4766
4766
|
}
|
|
4767
4767
|
}
|
|
4768
|
-
if (this.isFormControl && this.
|
|
4768
|
+
if (this.isFormControl && this.formControl?.parent) {
|
|
4769
4769
|
for (const targetKey in this.mappingConfig) {
|
|
4770
4770
|
const sourceKey = this.mappingConfig[targetKey];
|
|
4771
|
-
const formControl = this.
|
|
4771
|
+
const formControl = this.formControl.parent.get(targetKey);
|
|
4772
4772
|
if (formControl)
|
|
4773
|
-
formControl.setValue(this.selected[sourceKey]);
|
|
4773
|
+
formControl.setValue(!!this.selected ? this.selected[sourceKey] : '');
|
|
4774
4774
|
}
|
|
4775
4775
|
}
|
|
4776
|
-
this.propagateChange(this.selected[this.displayKey]);
|
|
4777
|
-
this.onChange.emit(this.selected[this.displayKey]);
|
|
4776
|
+
this.propagateChange(!!this.selected ? this.selected[this.displayKey] : '');
|
|
4777
|
+
this.onChange.emit(!!this.selected ? this.selected[this.displayKey] : '');
|
|
4778
4778
|
}
|
|
4779
4779
|
onClear() {
|
|
4780
|
-
this.writeValue(
|
|
4780
|
+
this.writeValue('');
|
|
4781
4781
|
}
|
|
4782
4782
|
isShowControl() {
|
|
4783
4783
|
return !this.disabled || (this.disabled && this.config && this.config.STYLE_DISABLE === 'CONTROL');
|
|
@@ -4785,23 +4785,23 @@ class CvaLiveSearchingComponent {
|
|
|
4785
4785
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: CvaLiveSearchingComponent, deps: [{ token: i0.Injector }, { token: i1$2.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
4786
4786
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: CvaLiveSearchingComponent, isStandalone: false, selector: "cva-live-searching", inputs: { label: "label", placeholder: "placeholder", hint: "hint", required: "required", disabled: "disabled", errorMessages: "errorMessages", isLabelOutside: "isLabelOutside", isFloatLabel: "isFloatLabel", percentOfLabelOutside: "percentOfLabelOutside", suffixFontAwesomeClass: "suffixFontAwesomeClass", displayKey: "displayKey", mappingConfig: "mappingConfig", searchFn: "searchFn", isFormControl: "isFormControl", row: "row", columnDef: "columnDef" }, outputs: { onChange: "onChange" }, ngImport: i0, template: `
|
|
4787
4787
|
<div class="cva-live-searching"
|
|
4788
|
-
[ngClass]="{'labelOutside':
|
|
4789
|
-
'float_label':
|
|
4788
|
+
[ngClass]="{'labelOutside': isLabelOutside,
|
|
4789
|
+
'float_label': isFloatLabel && !isLabelOutside}"
|
|
4790
4790
|
fxLayout="row" fxLayout.lt-sm="row wrap">
|
|
4791
4791
|
<mat-label *ngIf="isLabelOutside" class="label_width"
|
|
4792
4792
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
4793
4793
|
<div class="label">
|
|
4794
4794
|
<div>
|
|
4795
4795
|
{{ (label ? label : placeholder) | translate }}<span
|
|
4796
|
-
class="required-label-outside">{{
|
|
4796
|
+
class="required-label-outside">{{ required ? '*' : '' }}</span>
|
|
4797
4797
|
</div>
|
|
4798
4798
|
</div>
|
|
4799
4799
|
</mat-label>
|
|
4800
4800
|
<mat-form-field *ngIf="isShowControl()"
|
|
4801
|
-
appearance="outline" [floatLabel]="
|
|
4801
|
+
appearance="outline" [floatLabel]="isFloatLabel ? 'always' : 'auto'"
|
|
4802
4802
|
[hideRequiredMarker]="!isFloatLabel"
|
|
4803
4803
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
4804
|
-
<mat-label *ngIf="!isLabelOutside &&
|
|
4804
|
+
<mat-label *ngIf="!isLabelOutside && isFloatLabel">
|
|
4805
4805
|
{{ (label ? label : placeholder) | translate }}
|
|
4806
4806
|
</mat-label>
|
|
4807
4807
|
<input type="text"
|
|
@@ -4824,9 +4824,9 @@ class CvaLiveSearchingComponent {
|
|
|
4824
4824
|
</mat-option>
|
|
4825
4825
|
</mat-autocomplete>
|
|
4826
4826
|
<i *ngIf="!!suffixFontAwesomeClass" class="input-suffix {{suffixFontAwesomeClass}}" matSuffix></i>
|
|
4827
|
-
<mat-hint align="start" *ngIf="!NsValidator.invalid(
|
|
4828
|
-
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(
|
|
4829
|
-
{{ NsValidator.getErrorMessageV1(
|
|
4827
|
+
<mat-hint align="start" *ngIf="!NsValidator.invalid(formControl)">{{ hint | translate }}</mat-hint>
|
|
4828
|
+
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(formControl)">
|
|
4829
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
4830
4830
|
</mat-hint>
|
|
4831
4831
|
</mat-form-field>
|
|
4832
4832
|
|
|
@@ -4850,23 +4850,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4850
4850
|
standalone: false,
|
|
4851
4851
|
template: `
|
|
4852
4852
|
<div class="cva-live-searching"
|
|
4853
|
-
[ngClass]="{'labelOutside':
|
|
4854
|
-
'float_label':
|
|
4853
|
+
[ngClass]="{'labelOutside': isLabelOutside,
|
|
4854
|
+
'float_label': isFloatLabel && !isLabelOutside}"
|
|
4855
4855
|
fxLayout="row" fxLayout.lt-sm="row wrap">
|
|
4856
4856
|
<mat-label *ngIf="isLabelOutside" class="label_width"
|
|
4857
4857
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
4858
4858
|
<div class="label">
|
|
4859
4859
|
<div>
|
|
4860
4860
|
{{ (label ? label : placeholder) | translate }}<span
|
|
4861
|
-
class="required-label-outside">{{
|
|
4861
|
+
class="required-label-outside">{{ required ? '*' : '' }}</span>
|
|
4862
4862
|
</div>
|
|
4863
4863
|
</div>
|
|
4864
4864
|
</mat-label>
|
|
4865
4865
|
<mat-form-field *ngIf="isShowControl()"
|
|
4866
|
-
appearance="outline" [floatLabel]="
|
|
4866
|
+
appearance="outline" [floatLabel]="isFloatLabel ? 'always' : 'auto'"
|
|
4867
4867
|
[hideRequiredMarker]="!isFloatLabel"
|
|
4868
4868
|
fxLayout="column" fxFlex="auto" fxFlex.lt-md="100%">
|
|
4869
|
-
<mat-label *ngIf="!isLabelOutside &&
|
|
4869
|
+
<mat-label *ngIf="!isLabelOutside && isFloatLabel">
|
|
4870
4870
|
{{ (label ? label : placeholder) | translate }}
|
|
4871
4871
|
</mat-label>
|
|
4872
4872
|
<input type="text"
|
|
@@ -4889,9 +4889,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4889
4889
|
</mat-option>
|
|
4890
4890
|
</mat-autocomplete>
|
|
4891
4891
|
<i *ngIf="!!suffixFontAwesomeClass" class="input-suffix {{suffixFontAwesomeClass}}" matSuffix></i>
|
|
4892
|
-
<mat-hint align="start" *ngIf="!NsValidator.invalid(
|
|
4893
|
-
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(
|
|
4894
|
-
{{ NsValidator.getErrorMessageV1(
|
|
4892
|
+
<mat-hint align="start" *ngIf="!NsValidator.invalid(formControl)">{{ hint | translate }}</mat-hint>
|
|
4893
|
+
<mat-hint style="color: red" align="start" *ngIf="NsValidator.invalid(formControl)">
|
|
4894
|
+
{{ NsValidator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValidator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
4895
4895
|
</mat-hint>
|
|
4896
4896
|
</mat-form-field>
|
|
4897
4897
|
|
|
@@ -5792,6 +5792,7 @@ class CvaRangeDatePickerComponent {
|
|
|
5792
5792
|
isFormControl = true;
|
|
5793
5793
|
formControl;
|
|
5794
5794
|
defaultFromDate; // lưu giá trị khởi tạo ban đầu khi truyền từ bên ngoài vào
|
|
5795
|
+
picker;
|
|
5795
5796
|
constructor(dateServiceUtil, ngControl, injector) {
|
|
5796
5797
|
this.dateServiceUtil = dateServiceUtil;
|
|
5797
5798
|
this.injector = injector;
|
|
@@ -6002,6 +6003,12 @@ class CvaRangeDatePickerComponent {
|
|
|
6002
6003
|
this.onOpenPicker.emit(picker);
|
|
6003
6004
|
}
|
|
6004
6005
|
}
|
|
6006
|
+
openRangePicker(event) {
|
|
6007
|
+
if (!this.getDisabled(this.disabledAll) && this.picker) {
|
|
6008
|
+
event.stopPropagation();
|
|
6009
|
+
this.picker.open();
|
|
6010
|
+
}
|
|
6011
|
+
}
|
|
6005
6012
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: CvaRangeDatePickerComponent, deps: [{ token: DateUtilService }, { token: i1$2.NgControl, optional: true, self: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
|
|
6006
6013
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: CvaRangeDatePickerComponent, isStandalone: false, selector: "cva-range-date-picker", inputs: { label: "label", placeholderFromDate: "placeholderFromDate", placeholderToDate: "placeholderToDate", disabledAll: "disabledAll", disabledFromDate: "disabledFromDate", value: "value", requiredFromDate: "requiredFromDate", requiredToDate: "requiredToDate", minDate: "minDate", maxDate: "maxDate", errorMessages: "errorMessages", isLabelOutside: "isLabelOutside", isFloatLabel: "isFloatLabel", percentOfLabelOutside: "percentOfLabelOutside", fromDateControlName: "fromDateControlName", toDateControlName: "toDateControlName", isFormControl: "isFormControl" }, outputs: { onChange: "onChange", onOpenPicker: "onOpenPicker" }, providers: [
|
|
6007
6014
|
{ provide: DateAdapter, useClass: NsDateAdapter },
|
|
@@ -6009,7 +6016,7 @@ class CvaRangeDatePickerComponent {
|
|
|
6009
6016
|
provide: MAT_DATE_FORMATS,
|
|
6010
6017
|
useValue: APP_DATE_FORMATS,
|
|
6011
6018
|
},
|
|
6012
|
-
], ngImport: i0, template: `
|
|
6019
|
+
], viewQueries: [{ propertyName: "picker", first: true, predicate: ["picker"], descendants: true }], ngImport: i0, template: `
|
|
6013
6020
|
<div class="cva-range-date-picker"
|
|
6014
6021
|
[ngClass]="{'labelOutside': isLabelOutside, 'float_label': isFloatLabel && !isLabelOutside}"
|
|
6015
6022
|
fxLayout="row" fxLayout.lt-sm="row wrap">
|
|
@@ -6034,11 +6041,13 @@ class CvaRangeDatePickerComponent {
|
|
|
6034
6041
|
<input matStartDate
|
|
6035
6042
|
[(ngModel)]="fromDateValue"
|
|
6036
6043
|
readonly="readonly"
|
|
6037
|
-
[placeholder]="placeholderFromDate|translate"
|
|
6044
|
+
[placeholder]="placeholderFromDate|translate"
|
|
6045
|
+
(click)="openRangePicker($event)">
|
|
6038
6046
|
<input matEndDate
|
|
6039
6047
|
[(ngModel)]="toDateValue"
|
|
6040
6048
|
readOnly="true"
|
|
6041
|
-
[placeholder]="placeholderToDate|translate"
|
|
6049
|
+
[placeholder]="placeholderToDate|translate"
|
|
6050
|
+
(click)="openRangePicker($event)">
|
|
6042
6051
|
</mat-date-range-input>
|
|
6043
6052
|
|
|
6044
6053
|
<mat-datepicker-toggle matPrefix [for]="picker"
|
|
@@ -6054,7 +6063,7 @@ class CvaRangeDatePickerComponent {
|
|
|
6054
6063
|
|
|
6055
6064
|
<mat-date-range-picker #picker (opened)="openPicker(picker)"></mat-date-range-picker>
|
|
6056
6065
|
<mat-hint style="color: red" *ngIf="NsValiator.invalid(formControl)">
|
|
6057
|
-
{{ NsValiator.
|
|
6066
|
+
{{ NsValiator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValiator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
6058
6067
|
</mat-hint>
|
|
6059
6068
|
</mat-form-field>
|
|
6060
6069
|
</div>
|
|
@@ -6090,11 +6099,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
6090
6099
|
<input matStartDate
|
|
6091
6100
|
[(ngModel)]="fromDateValue"
|
|
6092
6101
|
readonly="readonly"
|
|
6093
|
-
[placeholder]="placeholderFromDate|translate"
|
|
6102
|
+
[placeholder]="placeholderFromDate|translate"
|
|
6103
|
+
(click)="openRangePicker($event)">
|
|
6094
6104
|
<input matEndDate
|
|
6095
6105
|
[(ngModel)]="toDateValue"
|
|
6096
6106
|
readOnly="true"
|
|
6097
|
-
[placeholder]="placeholderToDate|translate"
|
|
6107
|
+
[placeholder]="placeholderToDate|translate"
|
|
6108
|
+
(click)="openRangePicker($event)">
|
|
6098
6109
|
</mat-date-range-input>
|
|
6099
6110
|
|
|
6100
6111
|
<mat-datepicker-toggle matPrefix [for]="picker"
|
|
@@ -6110,7 +6121,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
6110
6121
|
|
|
6111
6122
|
<mat-date-range-picker #picker (opened)="openPicker(picker)"></mat-date-range-picker>
|
|
6112
6123
|
<mat-hint style="color: red" *ngIf="NsValiator.invalid(formControl)">
|
|
6113
|
-
{{ NsValiator.
|
|
6124
|
+
{{ NsValiator.getErrorMessageV1(formControl, errorMessages).msg | translate: NsValiator.getErrorMessageV1(formControl, errorMessages).params }}
|
|
6114
6125
|
</mat-hint>
|
|
6115
6126
|
</mat-form-field>
|
|
6116
6127
|
</div>
|
|
@@ -6165,6 +6176,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
6165
6176
|
type: Input
|
|
6166
6177
|
}], isFormControl: [{
|
|
6167
6178
|
type: Input
|
|
6179
|
+
}], picker: [{
|
|
6180
|
+
type: ViewChild,
|
|
6181
|
+
args: ['picker']
|
|
6168
6182
|
}] } });
|
|
6169
6183
|
|
|
6170
6184
|
class DragDropDirective {
|