From 6e3c770dd9bf8076a7c73a4bcdd5099d9e585990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 9 Mar 2023 10:59:52 +0100 Subject: [PATCH] use the _valueString --- .../property-editor-ui-date-picker.element.ts | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/date-picker/property-editor-ui-date-picker.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/date-picker/property-editor-ui-date-picker.element.ts index 035120e8c3..de79bbf833 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/date-picker/property-editor-ui-date-picker.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/date-picker/property-editor-ui-date-picker.element.ts @@ -6,7 +6,6 @@ import { UmbPropertyValueChangeEvent } from '../..'; import { UmbLitElement } from '@umbraco-cms/element'; import { PropertyEditorConfigDefaultData } from '@umbraco-cms/extensions-registry'; - /** * @element umb-property-editor-ui-date-picker */ @@ -22,19 +21,17 @@ export class UmbPropertyEditorUIDatePickerElement extends UmbLitElement { if (value) { const d = new Date(value); this._value = d; - this._valueString = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}T${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}`; + this._valueString = `${d.getFullYear()}-${ + d.getMonth() + 1 + }-${d.getDate()}T${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}`; } else { this._value = undefined; this._valueString = undefined; } } - get value(): string | undefined { - if (this._value) { - const d = this._value; - return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()} ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}`; - } - return undefined; + get value() { + return this._valueString; } private _onInput(e: InputEvent) { @@ -46,26 +43,25 @@ export class UmbPropertyEditorUIDatePickerElement extends UmbLitElement { private _format?: string; @state() - private _inputType: InputType = "datetime-local"; + private _inputType: InputType = 'datetime-local'; private _offsetTime?: boolean; @property({ type: Array, attribute: false }) public set config(config: Array) { - // Format string prevalue/config this._format = config.find((x) => x.alias === 'format')?.value; const pickTime = this._format?.includes('H') || this._format?.includes('m'); if (pickTime) { - this._inputType = "datetime-local"; + this._inputType = 'datetime-local'; } else { - this._inputType = "date"; + this._inputType = 'date'; } // Based on the type of format string change the UUI-input type - const timeFormatPattern = /^h{1,2}:m{1,2}(:s{1,2})?\s?a?$/gmi; - if (this._format?.toLowerCase().match(timeFormatPattern)) { - this._inputType = "time"; + const timeFormatPattern = /^h{1,2}:m{1,2}(:s{1,2})?\s?a?$/gim; + if (this._format?.toLowerCase().match(timeFormatPattern)) { + this._inputType = 'time'; } // TODO: Warren - Need to deal with offSetTime prevalue/config @@ -74,8 +70,11 @@ export class UmbPropertyEditorUIDatePickerElement extends UmbLitElement { } render() { - return html` - `; + return html` `; } }