2021-11-03 16:05:16 +01:00
|
|
|
/**
|
|
|
|
* EGroupware eTemplate2 - Date+Time widget (WebComponent)
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
|
|
|
* @link https://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2022-02-15 19:47:42 +01:00
|
|
|
import {css} from "@lion/core";
|
|
|
|
import {Et2Date} from "./Et2Date";
|
2021-11-03 16:05:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
export class Et2DateTime extends Et2Date
|
|
|
|
{
|
|
|
|
static get styles()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
...super.styles,
|
|
|
|
css`
|
|
|
|
:host([focused]) ::slotted(button), :host(:hover) ::slotted(button) {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
::slotted(.calendar_button) {
|
|
|
|
border: none;
|
|
|
|
background: transparent;
|
|
|
|
margin-left: -20px;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
static get properties()
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
...super.properties
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor()
|
|
|
|
{
|
|
|
|
super();
|
2022-02-22 19:23:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
2021-11-03 16:05:16 +01:00
|
|
|
|
2022-02-15 19:47:42 +01:00
|
|
|
let dateFormat = (this.egw().preference("dateformat") || "Y-m-d");
|
|
|
|
let timeFormat = ((<string>window.egw.preference("timeformat") || "24") == "24" ? "H:i" : "h:i K");
|
2022-02-22 19:23:54 +01:00
|
|
|
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;
|
2021-11-03 16:05:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// @ts-ignore TypeScript is not recognizing that Et2DateTime is a LitElement
|
2022-01-19 09:57:06 +01:00
|
|
|
customElements.define("et2-date-time", Et2DateTime);
|