mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-15 04:24:41 +01:00
672ed0aa0e
- Time & Date+time parser & formatter functions - Date widget does not return a time
70 lines
1.3 KiB
TypeScript
70 lines
1.3 KiB
TypeScript
/**
|
|
* 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
|
|
*/
|
|
|
|
|
|
import {css, html} from "@lion/core";
|
|
import {Et2Date, formatDateTime, parseDateTime} from "./Et2Date";
|
|
import {Unparseable} from "@lion/form-core";
|
|
|
|
|
|
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();
|
|
this.parser = parseDateTime;
|
|
this.formatter = formatDateTime;
|
|
}
|
|
|
|
getValue()
|
|
{
|
|
if(this.readOnly)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
// The supplied value was not understandable, return null
|
|
if(this.modelValue instanceof Unparseable || !this.modelValue)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return this.modelValue.toJSON();
|
|
}
|
|
}
|
|
|
|
// @ts-ignore TypeScript is not recognizing that Et2DateTime is a LitElement
|
|
customElements.define("et2-datetime", Et2DateTime);
|