diff --git a/src/Squidex/app/framework/angular/forms/date-time-editor.component.ts b/src/Squidex/app/framework/angular/forms/date-time-editor.component.ts index 9c0f06a54..fdd5f03f4 100644 --- a/src/Squidex/app/framework/angular/forms/date-time-editor.component.ts +++ b/src/Squidex/app/framework/angular/forms/date-time-editor.component.ts @@ -28,8 +28,8 @@ export const SQX_DATE_TIME_EDITOR_CONTROL_VALUE_ACCESSOR: any = { }) export class DateTimeEditorComponent extends StatefulControlComponent<{}, string | null> implements OnInit, AfterViewInit { private picker: any; - private timeValue: any | null = null; - private dateValue: any | null = null; + private timeValue: moment.Moment | null = null; + private dateValue: moment.Moment | null = null; private suppressEvents = false; @Input() @@ -65,10 +65,10 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string if (!value || value.length === 0) { this.timeValue = null; } else { - this.timeValue = moment(value, 'HH:mm:ss'); + this.timeValue = moment.utc(value, 'HH:mm:ss'); } - this.updateValue(); + this.callChangeFormatted(); })); this.own( @@ -76,10 +76,10 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string if (!value || value.length === 0) { this.dateValue = null; } else { - this.dateValue = moment(value, 'YYYY-MM-DD'); + this.dateValue = moment.utc(value, 'YYYY-MM-DD'); } - this.updateValue(); + this.callChangeFormatted(); })); } @@ -87,10 +87,10 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string if (Types.isString(obj) && obj.length > 0) { const parsed = moment.parseZone(obj); - this.dateValue = moment(parsed); + this.dateValue = parsed; if (this.showTime) { - this.timeValue = moment(parsed); + this.timeValue = parsed; } } else { this.timeValue = null; @@ -128,7 +128,7 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string } this.dateValue = this.picker.getMoment(); - this.updateValue(); + this.callChangeFormatted(); this.callTouched(); } }); @@ -140,7 +140,7 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string this.writeValue(new Date().toUTCString()); this.updateControls(); - this.updateValue(); + this.callChangeFormatted(); this.callTouched(); return false; @@ -158,26 +158,30 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string return false; } - private updateValue() { - let result: string | null; + private callChangeFormatted() { + this.callChange(this.getValue()); + } - if ((this.dateValue && !this.dateValue.isValid()) || (this.timeValue && !this.timeValue.isValid())) { - result = null; - } else if (!this.dateValue && !this.timeValue) { - result = null; - } else { - result = this.dateValue.format('YYYY-MM-DD'); - - if (this.showTime && this.timeValue) { - result += 'T'; - result += this.timeValue.format('HH:mm:ss'); - result += 'Z'; - } else if (this.enforceTime) { - result += 'T00:00:00Z'; - } + private getValue(): string | null { + if (!this.dateValue || !this.dateValue.isValid()) { + return null; + } + + if (this.timeValue && !this.timeValue.isValid()) { + return null; } - this.callChange(result); + let result = this.dateValue.format('YYYY-MM-DD'); + + if (this.showTime && this.timeValue) { + result += 'T'; + result += this.timeValue.format('HH:mm:ss'); + result += 'Z'; + } else if (this.enforceTime) { + result += 'T00:00:00Z'; + } + + return result; } private updateControls() { @@ -190,13 +194,16 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string } if (this.dateValue && this.dateValue.isValid() && this.picker) { - this.dateControl.setValue(this.dateValue.format('YYYY-MM-DD'), { emitEvent: false }); + const dateString = this.dateValue.format('YYYY-MM-DD'); + const dateLocal = moment(dateString); + + this.dateControl.setValue(dateString, { emitEvent: false }); - this.picker.setMoment(this.dateValue); + this.picker.setMoment(dateLocal); } else { this.dateControl.setValue(null, { emitEvent: false }); } this.suppressEvents = false; } -} +} \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.html b/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.html index 510e462f3..04d8088f6 100644 --- a/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.html +++ b/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.html @@ -1,6 +1,6 @@ -
-
+
+
diff --git a/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.ts b/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.ts index dac338b4c..cc1e55afa 100644 --- a/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.ts +++ b/src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.ts @@ -58,7 +58,7 @@ export class OnboardingTooltipComponent extends StatefulComponent implements OnD if (this.for && this.helpId && Types.isFunction(this.for.addEventListener)) { this.own( timer(this.after).subscribe(() => { - if (true || this.onboardingService.shouldShow(this.helpId)) { + if (this.onboardingService.shouldShow(this.helpId)) { const forRect = this.for.getBoundingClientRect(); const x = forRect.left + 0.5 * forRect.width;