Support scroll wheel on date year, month, hour, minute

This commit is contained in:
nathan 2022-02-22 11:23:54 -07:00
parent 1e23a3c45e
commit 354d15ba57
3 changed files with 59 additions and 19 deletions

View File

@ -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")

View File

@ -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 = ((<string>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;
}
}

View File

@ -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 = ((<string>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)