Et2Date: change "Today" button label to "Now" for widgets with time (Et2DateTime, Et2Timeonly, etc.)

This commit is contained in:
nathan 2022-10-14 10:05:59 -06:00
parent 2cb826e268
commit dcc6d1eb83
2 changed files with 29 additions and 7 deletions

View File

@ -374,8 +374,8 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
disconnectedCallback()
{
super.disconnectedCallback();
this._inputNode.removeEventListener('change', this._onChange);
this._inputNode.removeEventListener("input", this._handleInputChange);
this._inputNode?.removeEventListener('change', this._onChange);
this._inputNode?.removeEventListener("input", this._handleInputChange);
this.destroy();
}
@ -433,11 +433,7 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
new scrollPlugin(),
// Add "today" button
// @ts-ignore TypeScript can't find ShortcutButtonsPlugin, but rollup does
ShortcutButtonsPlugin({
button: [{label: this.egw().lang("Today")}],
onClick: this._handleShortcutButtonClick
})
this._buttonPlugin()
];
// Listen for flatpickr change so we can update internal value, needed for validation
@ -477,6 +473,19 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
};
}
/**
* Add "today" button below calendar
* @protected
*/
protected _buttonPlugin()
{
// @ts-ignore TypeScript can't find ShortcutButtonsPlugin, but rollup does
return ShortcutButtonsPlugin({
button: [{label: this.egw().lang("Today")}],
onClick: this._handleShortcutButtonClick
})
}
set value(value)
{
if(!value || value == 0 || value == "0")

View File

@ -66,6 +66,19 @@ export class Et2DateTime extends Et2Date
return options;
}
/**
* Add "today" button below calendar
* @protected
*/
protected _buttonPlugin()
{
// @ts-ignore TypeScript can't find ShortcutButtonsPlugin, but rollup does
return ShortcutButtonsPlugin({
button: [{label: this.egw().lang("Now")}],
onClick: this._handleShortcutButtonClick
})
}
}
// @ts-ignore TypeScript is not recognizing that Et2DateTime is a LitElement