Et2Date fixes

- Fix mobile get / set value was not actually setting value properly
- Set a minimum input width
This commit is contained in:
nathan 2023-02-24 11:58:16 -07:00
parent ae01e30d55
commit 206652307b
2 changed files with 48 additions and 30 deletions

View File

@ -322,32 +322,37 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(LitFlatpickr))
shoelace,
dateStyles,
css`
:host {
:host {
width: auto;
}
::slotted([slot='input'])
{
}
::slotted([slot='input']) {
flex: 1 1 auto;
}
/* Scroll buttons */
.input-group__container {
min-width: 12ex;
}
/* Scroll buttons */
.input-group__container {
position: relative;
}
.input-group__container:hover .et2-date-time__scrollbuttons {
}
.input-group__container:hover .et2-date-time__scrollbuttons {
display: flex;
}
.et2-date-time__scrollbuttons {
}
.et2-date-time__scrollbuttons {
display: none;
flex-direction: column;
width: calc(var(--sl-input-height-medium) / 2);
position: absolute;
right: 0px;
}
.et2-date-time__scrollbuttons > * {
}
.et2-date-time__scrollbuttons > * {
font-size: var(--sl-font-size-2x-small);
height: calc(var(--sl-input-height-medium) / 2);
}
}
.et2-date-time__scrollbuttons > *::part(base) {
padding: 3px;
}
@ -621,16 +626,23 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(LitFlatpickr))
{
date = new Date(value);
}
// Handle timezone offset, flatpickr uses local time
let formatDate = new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000);
if(typeof egwIsMobile == "function" && egwIsMobile())
{
this.updateComplete.then(() =>
if(this._inputNode)
{
this._inputNode.value = this.format(formatDate, {dateFormat: 'Y-m-d'});
});
this._inputNode.value = isNaN(date) ? "" : this.format(date, {dateFormat: 'Y-m-dTH:i'});
}
else
{
this.updateComplete.then(() =>
{
this._inputNode.value = isNaN(date) ? "" : this.format(date, {dateFormat: 'Y-m-dTH:i'});
});
}
return;
}
// Handle timezone offset, flatpickr uses local time
let formatDate = new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000);
if(!this._instance)
{
this.defaultDate = formatDate;
@ -651,7 +663,7 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(LitFlatpickr))
{
return flatpickr.formatDate(<Date>this.defaultDate, this.getOptions().dateFormat);
}
return this._inputNode?.value || '';
return this._inputNode?.value + "Z" || '';
}
let value = this._inputElement.value;

View File

@ -21,16 +21,22 @@ export class Et2DateTime extends Et2Date
return [
...super.styles,
css`
:host([focused]) ::slotted(button), :host(:hover) ::slotted(button) {
:host([focused]) ::slotted(button), :host(:hover) ::slotted(button) {
display: inline-block;
}
::slotted(.calendar_button) {
border: none;
background: transparent;
margin-left: -20px;
display: none;
}
`,
}
::slotted([slot='input']) {
flex: 1 1 auto;
min-width: 17ex;
}
::slotted(.calendar_button) {
border: none;
background: transparent;
margin-left: -20px;
display: none;
}
`,
];
}