@mediafly/js-ui 51.6.0-10 → 51.6.0-11
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/lib/src/components/date-time-zone-city-picker/date-time-zone-city-picker.d.ts +7 -3
- package/lib/src/components/date-time-zone-city-picker/date-time-zone-city-picker.js +31 -38
- package/lib/src/components/date-time-zone-city-picker/date-time-zone-city-picker.js.map +1 -1
- package/lib/src/components/date-time-zone-city-picker/time-zone-city-picker.js +0 -2
- package/lib/src/components/date-time-zone-city-picker/time-zone-city-picker.js.map +1 -1
- package/lib/tsconfig.deploy.tsbuildinfo +3 -3
- package/package.json +1 -1
- package/src/components/date-time-zone-city-picker/date-time-zone-city-picker.ts +32 -38
- package/src/components/date-time-zone-city-picker/time-zone-city-picker.ts +0 -2
|
@@ -5,22 +5,26 @@ export interface DateTimeZoneCity {
|
|
|
5
5
|
timeZoneName: string | null;
|
|
6
6
|
}
|
|
7
7
|
export default class DateTimeZoneCityPickerController implements IComponentController {
|
|
8
|
+
value?: DateTimeZoneCity;
|
|
8
9
|
format: string;
|
|
9
10
|
inputId: string;
|
|
10
|
-
isDisabled
|
|
11
|
+
isDisabled?: boolean;
|
|
11
12
|
isRequired: boolean;
|
|
12
13
|
onOpen: () => void;
|
|
13
14
|
onChange: (param: {
|
|
14
15
|
newValue: DateTimeZoneCity;
|
|
15
16
|
}) => void;
|
|
16
|
-
protected ngModelCtrl: ng.INgModelController;
|
|
17
17
|
protected dateLuxon: DateTime | null;
|
|
18
18
|
protected timeLuxon: DateTime | null;
|
|
19
19
|
protected timeZoneName: string | null;
|
|
20
20
|
$onInit(): void;
|
|
21
|
-
|
|
21
|
+
$onChanges(changes: {
|
|
22
|
+
value: ng.IChangesObject<DateTimeZoneCity>;
|
|
23
|
+
}): void;
|
|
24
|
+
private initFromValue;
|
|
22
25
|
protected updateDate(dateLuxon: DateTime): void;
|
|
23
26
|
protected updateTime(timeLuxon: DateTime): void;
|
|
24
27
|
protected updateTimeZone(timeZoneName: string): void;
|
|
25
28
|
private updateModel;
|
|
29
|
+
private datesMatch;
|
|
26
30
|
}
|
|
@@ -14,33 +14,14 @@ const luxon_1 = require("luxon");
|
|
|
14
14
|
const time_zone_city_service_1 = require("./time-zone-city.service");
|
|
15
15
|
let DateTimeZoneCityPickerController = class DateTimeZoneCityPickerController {
|
|
16
16
|
$onInit() {
|
|
17
|
-
|
|
18
|
-
this.ngModelCtrl.$formatters.push((modelValue) => {
|
|
19
|
-
var _a;
|
|
20
|
-
if (modelValue) {
|
|
21
|
-
this.initModelFromAPI(modelValue);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this.dateLuxon = null;
|
|
25
|
-
this.timeLuxon = luxon_1.DateTime.fromObject({
|
|
26
|
-
hour: 0,
|
|
27
|
-
minute: 0,
|
|
28
|
-
second: 0,
|
|
29
|
-
millisecond: 0
|
|
30
|
-
});
|
|
31
|
-
this.timeZoneName = null;
|
|
32
|
-
}
|
|
33
|
-
(_a = this.onChange) === null || _a === void 0 ? void 0 : _a.call(this, { newValue: modelValue });
|
|
34
|
-
return modelValue;
|
|
35
|
-
});
|
|
36
|
-
this.ngModelCtrl.$parsers.push((modelValue) => {
|
|
37
|
-
var _a;
|
|
38
|
-
(_a = this.onChange) === null || _a === void 0 ? void 0 : _a.call(this, { newValue: modelValue });
|
|
39
|
-
return modelValue;
|
|
40
|
-
});
|
|
17
|
+
this.initFromValue(this.value);
|
|
41
18
|
}
|
|
42
|
-
|
|
43
|
-
|
|
19
|
+
$onChanges(changes) {
|
|
20
|
+
if (changes.value) {
|
|
21
|
+
this.initFromValue(changes.value.currentValue);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
initFromValue(value) {
|
|
44
25
|
let luxon;
|
|
45
26
|
if (!(value === null || value === void 0 ? void 0 : value.dateTime)) {
|
|
46
27
|
luxon = undefined;
|
|
@@ -79,26 +60,25 @@ let DateTimeZoneCityPickerController = class DateTimeZoneCityPickerController {
|
|
|
79
60
|
millisecond: 0
|
|
80
61
|
});
|
|
81
62
|
}
|
|
82
|
-
const bestMatchTimeZone = time_zone_city_service_1.getTimeZone(value.timeZoneName);
|
|
63
|
+
const bestMatchTimeZone = time_zone_city_service_1.getTimeZone(value === null || value === void 0 ? void 0 : value.timeZoneName);
|
|
83
64
|
this.timeZoneName = (bestMatchTimeZone === null || bestMatchTimeZone === void 0 ? void 0 : bestMatchTimeZone.timeZoneName) || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
84
|
-
console.log(`-----> and so: ${this.dateLuxon} and ${this.timeLuxon} and ${this.timeZoneName}`);
|
|
85
65
|
}
|
|
86
66
|
updateDate(dateLuxon) {
|
|
87
|
-
console.log(`-----> updateDate: ${dateLuxon} (time is ${this.timeLuxon})`);
|
|
88
67
|
this.dateLuxon = dateLuxon;
|
|
89
68
|
this.updateModel();
|
|
90
69
|
}
|
|
91
70
|
updateTime(timeLuxon) {
|
|
92
|
-
console.log(`-----> updateTime: ${timeLuxon}`);
|
|
93
71
|
this.timeLuxon = timeLuxon;
|
|
94
72
|
this.updateModel();
|
|
95
73
|
}
|
|
96
74
|
updateTimeZone(timeZoneName) {
|
|
97
|
-
console.log(`-----> updateTimeZone: ${timeZoneName}`);
|
|
98
75
|
this.timeZoneName = timeZoneName;
|
|
99
76
|
this.updateModel();
|
|
100
77
|
}
|
|
101
78
|
updateModel() {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
const oldDateTime = (_a = this.value) === null || _a === void 0 ? void 0 : _a.dateTime;
|
|
81
|
+
const oldTimeZoneName = (_b = this.value) === null || _b === void 0 ? void 0 : _b.timeZoneName;
|
|
102
82
|
let dateTime;
|
|
103
83
|
if (this.dateLuxon && this.timeLuxon) {
|
|
104
84
|
const targetZone = this.timeZoneName || 'utc';
|
|
@@ -114,12 +94,28 @@ let DateTimeZoneCityPickerController = class DateTimeZoneCityPickerController {
|
|
|
114
94
|
zone: targetZone
|
|
115
95
|
});
|
|
116
96
|
}
|
|
117
|
-
this.
|
|
118
|
-
dateTime,
|
|
97
|
+
this.value = {
|
|
98
|
+
dateTime: dateTime || null,
|
|
119
99
|
timeZoneName: this.timeZoneName
|
|
120
|
-
}
|
|
100
|
+
};
|
|
101
|
+
if (!this.datesMatch(oldDateTime, dateTime) || oldTimeZoneName !== this.timeZoneName) {
|
|
102
|
+
(_c = this.onChange) === null || _c === void 0 ? void 0 : _c.call(this, { newValue: this.value });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
datesMatch(dateTime1, dateTime2) {
|
|
106
|
+
if (dateTime1 instanceof luxon_1.DateTime && dateTime2 instanceof luxon_1.DateTime) {
|
|
107
|
+
return dateTime1.toISO() === dateTime2.toISO();
|
|
108
|
+
}
|
|
109
|
+
else if (dateTime1 instanceof Date && dateTime2 instanceof Date) {
|
|
110
|
+
return dateTime1.toISOString() === dateTime2.toISOString();
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
121
113
|
}
|
|
122
114
|
};
|
|
115
|
+
__decorate([
|
|
116
|
+
decorators_1.Input(),
|
|
117
|
+
__metadata("design:type", Object)
|
|
118
|
+
], DateTimeZoneCityPickerController.prototype, "value", void 0);
|
|
123
119
|
__decorate([
|
|
124
120
|
decorators_1.Input('@'),
|
|
125
121
|
__metadata("design:type", String)
|
|
@@ -129,7 +125,7 @@ __decorate([
|
|
|
129
125
|
__metadata("design:type", String)
|
|
130
126
|
], DateTimeZoneCityPickerController.prototype, "inputId", void 0);
|
|
131
127
|
__decorate([
|
|
132
|
-
decorators_1.Input(
|
|
128
|
+
decorators_1.Input(),
|
|
133
129
|
__metadata("design:type", Boolean)
|
|
134
130
|
], DateTimeZoneCityPickerController.prototype, "isDisabled", void 0);
|
|
135
131
|
__decorate([
|
|
@@ -148,9 +144,6 @@ DateTimeZoneCityPickerController = __decorate([
|
|
|
148
144
|
decorators_1.Component({
|
|
149
145
|
selector: 'mflyDateTimeZoneCityPicker',
|
|
150
146
|
template: require('./date-time-zone-city-picker.html'),
|
|
151
|
-
require: {
|
|
152
|
-
ngModelCtrl: 'ngModel'
|
|
153
|
-
}
|
|
154
147
|
})
|
|
155
148
|
], DateTimeZoneCityPickerController);
|
|
156
149
|
exports.default = DateTimeZoneCityPickerController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time-zone-city-picker.js","sourceRoot":"","sources":["../../../../src/components/date-time-zone-city-picker/date-time-zone-city-picker.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,8CAAwD;AACxD,iCAAgC;AAChC,qEAAsD;
|
|
1
|
+
{"version":3,"file":"date-time-zone-city-picker.js","sourceRoot":"","sources":["../../../../src/components/date-time-zone-city-picker/date-time-zone-city-picker.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,8CAAwD;AACxD,iCAAgC;AAChC,qEAAsD;AAWtD,IAAqB,gCAAgC,GAArD,MAAqB,gCAAgC;IAcpD,OAAO;QAEN,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IAED,UAAU,CAAC,OAAuD;QAEjE,IAAI,OAAO,CAAC,KAAK,EAAE;YAClB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;SAC9C;IACF,CAAC;IAEO,aAAa,CAAC,KAAmC;QAExD,IAAI,KAA2B,CAAA;QAC/B,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAA,EAAE;YACrB,KAAK,GAAG,SAAS,CAAA;SACjB;aAAM,IAAI,KAAK,CAAC,QAAQ,YAAY,gBAAQ,EAAE;YAC9C,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAA;SACtB;aAAM,IAAI,KAAK,CAAC,QAAQ,YAAY,IAAI,EAAE;YAC1C,KAAK,GAAG,gBAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;SAC3C;aAAM,IAAI,OAAO,KAAK,CAAC,QAAQ,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QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;SACzC;IACF,CAAC;IAEO,UAAU,CAAC,SAA6C,EAAE,SAA6C;QAE9G,IAAI,SAAS,YAAY,gBAAQ,IAAI,SAAS,YAAY,gBAAQ,EAAE;YACnE,OAAO,SAAS,CAAC,KAAK,EAAE,KAAK,SAAS,CAAC,KAAK,EAAE,CAAA;SAC9C;aAAM,IAAI,SAAS,YAAY,IAAI,IAAI,SAAS,YAAY,IAAI,EAAE;YAClE,OAAO,SAAS,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAA;SAC1D;QACD,OAAO,KAAK,CAAA;IACb,CAAC;CACD,CAAA;AA5HS;IAAR,kBAAK,EAAE;;+DAAyB;AACrB;IAAX,kBAAK,CAAC,GAAG,CAAC;;gEAAe;AACd;IAAX,kBAAK,CAAC,GAAG,CAAC;;iEAAgB;AAClB;IAAR,kBAAK,EAAE;;oEAAqB;AACjB;IAAX,kBAAK,CAAC,GAAG,CAAC;;oEAAoB;AACjB;IAAb,mBAAM,CAAC,IAAI,CAAC;;gEAAmB;AAClB;IAAb,mBAAM,CAAC,IAAI,CAAC;;kEAA0D;AARnD,gCAAgC;IAJpD,sBAAS,CAAC;QACV,QAAQ,EAAE,4BAA4B;QACtC,QAAQ,EAAE,OAAO,CAAC,mCAAmC,CAAC;KACtD,CAAC;GACmB,gCAAgC,CA8HpD;kBA9HoB,gCAAgC"}
|
|
@@ -16,7 +16,6 @@ let TimeZoneCityPickerController = class TimeZoneCityPickerController {
|
|
|
16
16
|
this.timeZones = [];
|
|
17
17
|
}
|
|
18
18
|
$onInit() {
|
|
19
|
-
console.log(`-----> $onInit: ${this.timeZoneName} (${typeof this.timeZoneName})`);
|
|
20
19
|
this.timeZones = time_zone_city_service_1.getTimeZones();
|
|
21
20
|
this.setTimeZone(this.timeZoneName);
|
|
22
21
|
}
|
|
@@ -31,7 +30,6 @@ let TimeZoneCityPickerController = class TimeZoneCityPickerController {
|
|
|
31
30
|
}
|
|
32
31
|
setTimeZone(timeZoneName) {
|
|
33
32
|
var _a, _b, _c;
|
|
34
|
-
console.log(`-----> setTimeZone: ${timeZoneName}`);
|
|
35
33
|
const oldTimeZone = this.timeZone;
|
|
36
34
|
this.timeZone = (_c = (_b = (_a = time_zone_city_service_1.getTimeZone(timeZoneName)) !== null && _a !== void 0 ? _a : time_zone_city_service_1.getTimeZone(Intl.DateTimeFormat().resolvedOptions().timeZone)) !== null && _b !== void 0 ? _b : time_zone_city_service_1.getTimeZone('America/Chicago')) !== null && _c !== void 0 ? _c : this.timeZones[0];
|
|
37
35
|
if (oldTimeZone !== this.timeZone) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-zone-city-picker.js","sourceRoot":"","sources":["../../../../src/components/date-time-zone-city-picker/time-zone-city-picker.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,4DAAsE;AACtE,qEAA8E;AAM9E,IAAqB,4BAA4B,GAAjD,MAAqB,4BAA4B;IAAjD;QAOW,cAAS,GAAe,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"time-zone-city-picker.js","sourceRoot":"","sources":["../../../../src/components/date-time-zone-city-picker/time-zone-city-picker.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,4DAAsE;AACtE,qEAA8E;AAM9E,IAAqB,4BAA4B,GAAjD,MAAqB,4BAA4B;IAAjD;QAOW,cAAS,GAAe,EAAE,CAAA;IAgCrC,CAAC;IA9BA,OAAO;QAEN,IAAI,CAAC,SAAS,GAAG,qCAAY,EAAE,CAAA;QAC/B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IACpC,CAAC;IAED,UAAU,CAAC,OAAoD;QAE9D,IAAI,OAAO,CAAC,YAAY,EAAE;YACzB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;SACnD;IACF,CAAC;IAES,cAAc,CAAC,QAAkB;QAE1C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,gBAAgB,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAA;IAC/D,CAAC;IAEO,WAAW,CAAC,YAAoB;;QAEvC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAA;QACjC,IAAI,CAAC,QAAQ,GAAG,MAAA,MAAA,MAAA,oCAAW,CAAC,YAAY,CAAC,mCACrC,oCAAW,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,mCAC7D,oCAAW,CAAC,iBAAiB,CAAC,mCAC9B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACrB,IAAI,WAAW,KAAK,IAAI,CAAC,QAAQ,EAAE;YAClC,IAAI,CAAC,gBAAgB,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAA;SACnE;IACF,CAAC;CACD,CAAA;AArCS;IAAR,kBAAK,EAAE;;6DAAgB;AACf;IAAR,kBAAK,EAAE;;kEAAqB;AACnB;IAAT,mBAAM,EAAE;;sEAA4D;AAJjD,4BAA4B;IAJhD,sBAAS,CAAC;QACV,QAAQ,EAAE,wBAAwB;QAClC,QAAQ,EAAE,OAAO,CAAC,8BAA8B,CAAC;KACjD,CAAC;GACmB,4BAA4B,CAuChD;kBAvCoB,4BAA4B"}
|
|
@@ -477,12 +477,12 @@
|
|
|
477
477
|
"affectsGlobalScope": false
|
|
478
478
|
},
|
|
479
479
|
"../src/components/date-time-zone-city-picker/date-time-zone-city-picker.ts": {
|
|
480
|
-
"version": "
|
|
481
|
-
"signature": "
|
|
480
|
+
"version": "2304b0426e41504967e7924637f16c6f783c3f6f64e7a9acec78d3f1aef9a201",
|
|
481
|
+
"signature": "5a6ac6549676b97300c9324cb292c169a54a41abb3dfcb5e865259af70443998",
|
|
482
482
|
"affectsGlobalScope": false
|
|
483
483
|
},
|
|
484
484
|
"../src/components/date-time-zone-city-picker/time-zone-city-picker.ts": {
|
|
485
|
-
"version": "
|
|
485
|
+
"version": "8ba4cd06787ed0ae0b952d629fd8c0e3147ee8ecd821e6b87728e68c6eeb71ff",
|
|
486
486
|
"signature": "6066bd236b98fe3c130fad8cd2c1644e18e3c86032785958211e875620520c32",
|
|
487
487
|
"affectsGlobalScope": false
|
|
488
488
|
},
|
package/package.json
CHANGED
|
@@ -11,54 +11,35 @@ export interface DateTimeZoneCity {
|
|
|
11
11
|
@Component({
|
|
12
12
|
selector: 'mflyDateTimeZoneCityPicker',
|
|
13
13
|
template: require('./date-time-zone-city-picker.html'),
|
|
14
|
-
require: {
|
|
15
|
-
ngModelCtrl: 'ngModel'
|
|
16
|
-
}
|
|
17
14
|
})
|
|
18
15
|
export default class DateTimeZoneCityPickerController implements IComponentController {
|
|
19
16
|
|
|
17
|
+
@Input() value?: DateTimeZoneCity
|
|
20
18
|
@Input('@') format: string
|
|
21
19
|
@Input('@') inputId: string
|
|
22
|
-
@Input(
|
|
20
|
+
@Input() isDisabled?: boolean
|
|
23
21
|
@Input('@') isRequired: boolean
|
|
24
22
|
@Output('&?') onOpen: () => void
|
|
25
23
|
@Output('&?') onChange: (param: { newValue: DateTimeZoneCity }) => void
|
|
26
24
|
|
|
27
|
-
protected ngModelCtrl: ng.INgModelController
|
|
28
|
-
|
|
29
25
|
protected dateLuxon: DateTime | null
|
|
30
26
|
protected timeLuxon: DateTime | null
|
|
31
27
|
protected timeZoneName: string | null
|
|
32
28
|
|
|
33
29
|
$onInit(): void {
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
this.ngModelCtrl.$formatters.push((modelValue: DateTimeZoneCity) => {
|
|
37
|
-
if (modelValue) {
|
|
38
|
-
this.initModelFromAPI(modelValue)
|
|
39
|
-
} else {
|
|
40
|
-
this.dateLuxon = null
|
|
41
|
-
this.timeLuxon = DateTime.fromObject({
|
|
42
|
-
hour: 0,
|
|
43
|
-
minute: 0,
|
|
44
|
-
second: 0,
|
|
45
|
-
millisecond: 0
|
|
46
|
-
})
|
|
47
|
-
this.timeZoneName = null
|
|
48
|
-
}
|
|
49
|
-
this.onChange?.({ newValue: modelValue })
|
|
50
|
-
return modelValue
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
this.ngModelCtrl.$parsers.push((modelValue: DateTimeZoneCity) => {
|
|
54
|
-
this.onChange?.({ newValue: modelValue })
|
|
55
|
-
return modelValue
|
|
56
|
-
})
|
|
31
|
+
this.initFromValue(this.value)
|
|
57
32
|
}
|
|
58
33
|
|
|
59
|
-
|
|
34
|
+
$onChanges(changes: { value: ng.IChangesObject<DateTimeZoneCity> }): void {
|
|
35
|
+
|
|
36
|
+
if (changes.value) {
|
|
37
|
+
this.initFromValue(changes.value.currentValue)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private initFromValue(value: DateTimeZoneCity | undefined): void {
|
|
60
42
|
|
|
61
|
-
console.log(`-----> initModelFromAPI: ${JSON.stringify(value)}`)
|
|
62
43
|
let luxon: DateTime | undefined
|
|
63
44
|
if (!value?.dateTime) {
|
|
64
45
|
luxon = undefined
|
|
@@ -95,34 +76,33 @@ export default class DateTimeZoneCityPickerController implements IComponentContr
|
|
|
95
76
|
})
|
|
96
77
|
}
|
|
97
78
|
|
|
98
|
-
const bestMatchTimeZone = getTimeZone(value
|
|
79
|
+
const bestMatchTimeZone = getTimeZone(value?.timeZoneName)
|
|
99
80
|
this.timeZoneName = bestMatchTimeZone?.timeZoneName || Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
100
|
-
console.log(`-----> and so: ${this.dateLuxon} and ${this.timeLuxon} and ${this.timeZoneName}`)
|
|
101
81
|
}
|
|
102
82
|
|
|
103
83
|
protected updateDate(dateLuxon: DateTime): void {
|
|
104
84
|
|
|
105
|
-
console.log(`-----> updateDate: ${dateLuxon} (time is ${this.timeLuxon})`)
|
|
106
85
|
this.dateLuxon = dateLuxon
|
|
107
86
|
this.updateModel()
|
|
108
87
|
}
|
|
109
88
|
|
|
110
89
|
protected updateTime(timeLuxon: DateTime): void {
|
|
111
90
|
|
|
112
|
-
console.log(`-----> updateTime: ${timeLuxon}`)
|
|
113
91
|
this.timeLuxon = timeLuxon
|
|
114
92
|
this.updateModel()
|
|
115
93
|
}
|
|
116
94
|
|
|
117
95
|
protected updateTimeZone(timeZoneName: string): void {
|
|
118
96
|
|
|
119
|
-
console.log(`-----> updateTimeZone: ${timeZoneName}`)
|
|
120
97
|
this.timeZoneName = timeZoneName
|
|
121
98
|
this.updateModel()
|
|
122
99
|
}
|
|
123
100
|
|
|
124
101
|
private updateModel(): void {
|
|
125
102
|
|
|
103
|
+
const oldDateTime = this.value?.dateTime
|
|
104
|
+
const oldTimeZoneName = this.value?.timeZoneName
|
|
105
|
+
|
|
126
106
|
let dateTime: DateTime | undefined
|
|
127
107
|
if (this.dateLuxon && this.timeLuxon) {
|
|
128
108
|
const targetZone = this.timeZoneName || 'utc'
|
|
@@ -139,9 +119,23 @@ export default class DateTimeZoneCityPickerController implements IComponentContr
|
|
|
139
119
|
})
|
|
140
120
|
}
|
|
141
121
|
|
|
142
|
-
this.
|
|
143
|
-
dateTime,
|
|
122
|
+
this.value = {
|
|
123
|
+
dateTime: dateTime || null,
|
|
144
124
|
timeZoneName: this.timeZoneName
|
|
145
|
-
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!this.datesMatch(oldDateTime, dateTime) || oldTimeZoneName !== this.timeZoneName) {
|
|
128
|
+
this.onChange?.({ newValue: this.value })
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private datesMatch(dateTime1: DateTime | Date | null | undefined, dateTime2: DateTime | Date | null | undefined): boolean {
|
|
133
|
+
|
|
134
|
+
if (dateTime1 instanceof DateTime && dateTime2 instanceof DateTime) {
|
|
135
|
+
return dateTime1.toISO() === dateTime2.toISO()
|
|
136
|
+
} else if (dateTime1 instanceof Date && dateTime2 instanceof Date) {
|
|
137
|
+
return dateTime1.toISOString() === dateTime2.toISOString()
|
|
138
|
+
}
|
|
139
|
+
return false
|
|
146
140
|
}
|
|
147
141
|
}
|
|
@@ -17,7 +17,6 @@ export default class TimeZoneCityPickerController implements IComponentControlle
|
|
|
17
17
|
|
|
18
18
|
$onInit(): void {
|
|
19
19
|
|
|
20
|
-
console.log(`-----> $onInit: ${this.timeZoneName} (${typeof this.timeZoneName})`)
|
|
21
20
|
this.timeZones = getTimeZones()
|
|
22
21
|
this.setTimeZone(this.timeZoneName)
|
|
23
22
|
}
|
|
@@ -37,7 +36,6 @@ export default class TimeZoneCityPickerController implements IComponentControlle
|
|
|
37
36
|
|
|
38
37
|
private setTimeZone(timeZoneName: string): void {
|
|
39
38
|
|
|
40
|
-
console.log(`-----> setTimeZone: ${timeZoneName}`)
|
|
41
39
|
const oldTimeZone = this.timeZone
|
|
42
40
|
this.timeZone = getTimeZone(timeZoneName)
|
|
43
41
|
?? getTimeZone(Intl.DateTimeFormat().resolvedOptions().timeZone)
|