diff --git a/api/js/etemplate/Et2Date/Et2Date.ts b/api/js/etemplate/Et2Date/Et2Date.ts index cb6bcf7c69..8cc928b99a 100644 --- a/api/js/etemplate/Et2Date/Et2Date.ts +++ b/api/js/etemplate/Et2Date/Et2Date.ts @@ -14,6 +14,7 @@ import 'lit-flatpickr'; import {Et2InputWidget} from "../Et2InputWidget/Et2InputWidget"; import {dateStyles} from "./DateStyles"; import {LitFlatpickr} from "lit-flatpickr"; +import "flatpickr/dist/plugins/scrollPlugin.js"; /** @@ -293,13 +294,6 @@ export class Et2Date extends Et2InputWidget(LitFlatpickr) constructor() { super(); - - // Override some flatpickr defaults how we like it - this.altFormat = this.egw().preference("dateformat") || "Y-m-d"; - this.altInput = true; - this.allowInput = true; - this.dateFormat = "Y-m-dT00:00:00\\Z"; - this.weekNumbers = true; } /** @@ -315,6 +309,28 @@ export class Et2Date extends Et2InputWidget(LitFlatpickr) this.initializeComponent(); } + /** + * Override some flatpickr defaults to get things how we like it + * + * @see https://flatpickr.js.org/options/ + * @returns {any} + */ + protected getOptions() + { + let options = super.getOptions(); + + options.altFormat = this.egw().preference("dateformat") || "Y-m-d"; + options.altInput = true; + options.allowInput = true; + options.dateFormat = "Y-m-dT00:00:00\\Z"; + options.weekNumbers = true; + + // Turn on scroll wheel support + options.plugins = [new scrollPlugin()]; + + return options; + } + set_value(value) { if(!value || value == 0 || value == "0") diff --git a/api/js/etemplate/Et2Date/Et2DateTime.ts b/api/js/etemplate/Et2Date/Et2DateTime.ts index b1601ccd11..8db975e429 100644 --- a/api/js/etemplate/Et2Date/Et2DateTime.ts +++ b/api/js/etemplate/Et2Date/Et2DateTime.ts @@ -43,15 +43,28 @@ export class Et2DateTime extends Et2Date constructor() { super(); + } + + + /** + * Override some flatpickr defaults to get things how we like it + * + * @see https://flatpickr.js.org/options/ + * @returns {any} + */ + protected getOptions() + { + let options = super.getOptions(); - // Configure flatpickr let dateFormat = (this.egw().preference("dateformat") || "Y-m-d"); let timeFormat = ((window.egw.preference("timeformat") || "24") == "24" ? "H:i" : "h:i K"); - this.altFormat = dateFormat + " " + timeFormat; - this.enableTime = true; - this.time_24hr = this.egw().preference("timeformat", "common") == "24"; - this.dateFormat = "Y-m-dTH:i:00\\Z"; - this.defaultHour = new Date().getHours(); + options.altFormat = dateFormat + " " + timeFormat; + options.enableTime = true; + options.time_24hr = this.egw().preference("timeformat", "common") == "24"; + options.dateFormat = "Y-m-dTH:i:00\\Z"; + options.defaultHour = new Date().getHours(); + + return options; } } diff --git a/api/js/etemplate/Et2Date/Et2DateTimeOnly.ts b/api/js/etemplate/Et2Date/Et2DateTimeOnly.ts index bd4fe83053..107554c846 100644 --- a/api/js/etemplate/Et2Date/Et2DateTimeOnly.ts +++ b/api/js/etemplate/Et2Date/Et2DateTimeOnly.ts @@ -33,13 +33,24 @@ export class Et2DateTimeOnly extends Et2DateTime super(); // Configure flatpickr + + } + + /** + * Override some flatpickr defaults to get things how we like it + * + * @see https://flatpickr.js.org/options/ + * @returns {any} + */ + protected getOptions() + { + let options = super.getOptions(); let timeFormat = ((window.egw.preference("timeformat") || "24") == "24" ? "H:i" : "h:i K"); - this.altFormat = timeFormat; - this.enableTime = true; - this.noCalendar = true; - this.time_24hr = this.egw().preference("timeformat", "common") == "24"; - this.dateFormat = "1970-01-01TH:i:00\\Z"; - this.defaultHour = new Date().getHours(); + options.altFormat = timeFormat; + options.noCalendar = true; + options.dateFormat = "1970-01-01TH:i:00\\Z"; + + return options; } set_value(value)