Skip to content

Commit 9d4b58c

Browse files
authored
Datetime NPE fixes and save timezone per default for time control (#84)
* DateTime control: * fix NPE issues * only reset the value when action buttons are present * remove unnecessary set in Date renderer * add vueCompilerOptions * Adapt default time save format of the time control to include the timezone to fulfill RFC3339 time
1 parent a085e69 commit 9d4b58c

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

Diff for: example/src/examples/control/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"number": 50.5,
55
"integer": 50,
66
"date": "2020-06-25",
7-
"time": "23:08:00",
7+
"time": "23:08:00Z",
88
"dateTime": "2020-06-25T23:08:42+02:00",
99
"enum": "Two"
1010
}

Diff for: example/tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@
3636
],
3737
"exclude": [
3838
"node_modules"
39-
]
39+
],
40+
"vueCompilerOptions": {
41+
"target": 2.7
42+
}
4043
}

Diff for: vue2-vuetify/src/controls/DateControlRenderer.vue

-3
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,6 @@ const controlRenderer = defineComponent({
293293
onYear(year: number): void {
294294
if (this.pickerType === 'year') {
295295
this.pickerValue = `${year}`;
296-
if (this.$refs?.picker) {
297-
(this.$refs.picker as any).internalActivePicker = 'YEAR';
298-
}
299296
if (!this.showActions) {
300297
this.okHandler();
301298
}

Diff for: vue2-vuetify/src/controls/DateTimeControlRenderer.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ const controlRenderer = defineComponent({
414414
return date ? date.format('YYYY-MM-DD') : undefined;
415415
},
416416
set(val: string) {
417-
this.onPickerChange(val, (this.$refs.timePicker as any).genValue());
417+
this.onPickerChange(val, this.timePickerValue);
418418
},
419419
},
420420
timePickerValue: {
@@ -430,7 +430,7 @@ const controlRenderer = defineComponent({
430430
: undefined;
431431
},
432432
set(val: string) {
433-
this.onPickerChange((this.$refs.datePicker as any).inputDate, val);
433+
this.onPickerChange(this.datePickerValue, val);
434434
},
435435
},
436436
pickerValue: {
@@ -445,7 +445,9 @@ const controlRenderer = defineComponent({
445445
},
446446
set(val: string) {
447447
const dateTime = parseDateTime(val, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
448-
this.onChange(dateTime!.format(this.dateTimeSaveFormat));
448+
if (dateTime && this.showActions) {
449+
this.onChange(dateTime.format(this.dateTimeSaveFormat));
450+
}
449451
},
450452
},
451453
clearLabel(): string {
@@ -484,7 +486,7 @@ const controlRenderer = defineComponent({
484486
this.onChange(newdata);
485487
}
486488
},
487-
onPickerChange(dateValue: string, timeValue: string): void {
489+
onPickerChange(dateValue?: string, timeValue?: string): void {
488490
const date = parseDateTime(dateValue, 'YYYY-MM-DD');
489491
const time = parseDateTime(
490492
timeValue ?? (this.useSeconds ? '00:00:00' : '00:00'),

Diff for: vue2-vuetify/src/controls/TimeControlRenderer.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const controlRenderer = defineComponent({
174174
timeSaveFormat(): string {
175175
return typeof this.appliedOptions.timeSaveFormat == 'string'
176176
? this.appliedOptions.timeSaveFormat
177-
: 'HH:mm:ss';
177+
: 'HH:mm:ssZ';
178178
},
179179
formats(): string[] {
180180
return [

Diff for: vue2-vuetify/tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@
3030
"exclude": [
3131
"node_modules",
3232
"lib"
33-
]
33+
],
34+
"vueCompilerOptions": {
35+
"target": 2.7
36+
}
3437
}

0 commit comments

Comments
 (0)