Et2Date: Add "Today" button

This commit is contained in:
nathan 2022-09-06 11:32:25 -06:00
parent 6b4a16357f
commit 7f94b3ae6c
3 changed files with 29 additions and 4 deletions

View File

@ -16,6 +16,7 @@ import {Et2InputWidget} from "../Et2InputWidget/Et2InputWidget";
import {dateStyles} from "./DateStyles";
import {LitFlatpickr} from "lit-flatpickr";
import "flatpickr/dist/plugins/scrollPlugin.js";
import "shortcut-buttons-flatpickr/dist/shortcut-buttons-flatpickr";
import {holidays} from "./Holidays";
import flatpickr from "flatpickr";
import {egw} from "../../jsapi/egw_global";
@ -409,9 +410,21 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
options.inline = this.inline;
}
// Turn on scroll wheel support
// @ts-ignore TypeScript can't find scrollPlugin, but rollup does
options.plugins = [new scrollPlugin()];
options.plugins = [
// Turn on scroll wheel support
// @ts-ignore TypeScript can't find scrollPlugin, but rollup does
new scrollPlugin(),
// Add "today" button
// @ts-ignore TypeScript can't find ShortcutButtonsPlugin, but rollup does
ShortcutButtonsPlugin({
button: [{label: this.egw().lang("Today")}],
onClick: (button_index, fp) =>
{
fp.setDate(new Date());
}
})
];
// Listen for flatpickr change so we can update internal value, needed for validation
options.onChange = options.onReady = this._updateValueOnChange;

13
package-lock.json generated
View File

@ -19,10 +19,11 @@
"@lion/listbox": "^0.12.0",
"@lion/select": "^0.15.0",
"@lion/textarea": "^0.14.0",
"@shoelace-style/shoelace": "^2.0.0-beta.73",
"@shoelace-style/shoelace": "^2.0.0-beta.79",
"blueimp-gallery": "^3.4.0",
"colortranslator": "^1.9.2",
"lit-flatpickr": "^0.3.0",
"shortcut-buttons-flatpickr": "^0.4.0",
"sortablejs": "^1.14.0"
},
"devDependencies": {
@ -5558,6 +5559,11 @@
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==",
"dev": true
},
"node_modules/shortcut-buttons-flatpickr": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/shortcut-buttons-flatpickr/-/shortcut-buttons-flatpickr-0.4.0.tgz",
"integrity": "sha512-JKmT4my3Hm1e18OvG4Q6RcFhN4WRqqpTMkHrvZ7fup/dp6aTIWGVCHdRYtASkp/FCzDlJh6iCLQ/VcwwNpAMoQ=="
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
@ -10630,6 +10636,11 @@
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==",
"dev": true
},
"shortcut-buttons-flatpickr": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/shortcut-buttons-flatpickr/-/shortcut-buttons-flatpickr-0.4.0.tgz",
"integrity": "sha512-JKmT4my3Hm1e18OvG4Q6RcFhN4WRqqpTMkHrvZ7fup/dp6aTIWGVCHdRYtASkp/FCzDlJh6iCLQ/VcwwNpAMoQ=="
},
"side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",

View File

@ -66,6 +66,7 @@
"blueimp-gallery": "^3.4.0",
"colortranslator": "^1.9.2",
"lit-flatpickr": "^0.3.0",
"shortcut-buttons-flatpickr": "^0.4.0",
"sortablejs": "^1.14.0"
},
"engines": {