Skip to content

Commit de75948

Browse files
Fix yet another problem with handling masks
1 parent 0164e31 commit de75948

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

projects/angular-datepicker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-art-eg/angular-datepicker",
3-
"version": "10.0.3",
3+
"version": "10.0.7",
44
"private": false,
55
"description": "A date and time picker for Angular 10",
66
"author": "Sherif Elmetainy (Code Art)",

projects/angular-datepicker/src/lib/directives/base-date-picker-directive.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,6 @@ export abstract class BaseDatePickerDirective extends BaseDatePickerAccessorDire
4949

5050
public abstract resolveFactory(resolver: ComponentFactoryResolver): ComponentFactory<BaseDatePickerComponentDirective>;
5151

52-
public parseValue(val: any): any {
53-
if (typeof val !== 'string') {
54-
return val;
55-
}
56-
const index = val.indexOf(' - ');
57-
if (index < 0) {
58-
return val;
59-
}
60-
const from = val.substring(0, index);
61-
const to = val.substring(index + 3);
62-
return {
63-
from,
64-
to,
65-
};
66-
}
67-
6852
public formatValue(val: any, locale: string, format: string): string {
6953
if (val === undefined || val === null) {
7054
return '';

projects/angular-datepicker/src/lib/directives/date-range-picker.directive.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,20 @@ export class DateRangePickerDirective extends BaseDatePickerDirective {
1919
public resolveFactory(resolver: ComponentFactoryResolver): ComponentFactory<BaseDatePickerComponentDirective> {
2020
return resolver.resolveComponentFactory(DateRangePickerComponent);
2121
}
22+
23+
public parseValue(val: any): any {
24+
if (typeof val !== 'string') {
25+
return val;
26+
}
27+
const index = val.indexOf(' - ');
28+
if (index < 0) {
29+
return val;
30+
}
31+
const from = val.substring(0, index);
32+
const to = val.substring(index + 3);
33+
return {
34+
from,
35+
to,
36+
};
37+
}
2238
}

projects/angular-datepicker/src/lib/directives/popup-implementation.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,18 @@ export abstract class PopupImplentation<T> implements IPopupDirective<T>, IPopup
219219
const coercedValue = val === null ? val : this.coerceValue(val);
220220
if (val !== null) {
221221
if (coercedValue) {
222-
this.value = val;
223-
this.raiseOnChange(val);
222+
if (!this.compareValues(coercedValue, this.value)) {
223+
this.value = coercedValue;
224+
this.raiseOnChange(coercedValue);
225+
}
224226
} else {
225227
this.raiseOnChange(v);
226228
}
227229
} else {
228-
this.value = null;
229-
this.raiseOnChange(null);
230+
if (this.value != null) {
231+
this.value = null;
232+
this.raiseOnChange(null);
233+
}
230234
}
231235
}
232236

0 commit comments

Comments
 (0)