mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 18:03:39 +01:00
Add missing et2-date-timeonly widget
This commit is contained in:
parent
3f2c156914
commit
7cc9006e19
69
api/js/etemplate/Et2Date/Et2DateTimeOnly.ts
Normal file
69
api/js/etemplate/Et2Date/Et2DateTimeOnly.ts
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 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 {Et2DateTime} from "./Et2DateTime";
|
||||
|
||||
|
||||
export class Et2DateTimeOnly extends Et2DateTime
|
||||
{
|
||||
static get styles()
|
||||
{
|
||||
return [
|
||||
...super.styles,
|
||||
];
|
||||
}
|
||||
|
||||
static get properties()
|
||||
{
|
||||
return {
|
||||
...super.properties
|
||||
}
|
||||
}
|
||||
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
|
||||
// Configure flatpickr
|
||||
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();
|
||||
}
|
||||
|
||||
set_value(value)
|
||||
{
|
||||
if(!value || value == 0 || value == "0")
|
||||
{
|
||||
value = '';
|
||||
}
|
||||
// Handle timezone offset, flatpickr uses local time
|
||||
let date = new Date(value);
|
||||
let formatDate = new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000);
|
||||
formatDate.setDate(1);
|
||||
formatDate.setMonth(0)
|
||||
formatDate.setFullYear(1970);
|
||||
if(!this._instance)
|
||||
{
|
||||
this.defaultDate = formatDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setDate(formatDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore TypeScript is not recognizing that this is a LitElement
|
||||
customElements.define("et2-date-timeonly", Et2DateTimeOnly);
|
@ -31,6 +31,7 @@ import './Et2Date/Et2DateDurationReadonly';
|
||||
import './Et2Date/Et2DateReadonly';
|
||||
import './Et2Date/Et2DateSinceReadonly';
|
||||
import './Et2Date/Et2DateTime';
|
||||
import './Et2Date/Et2DateTimeOnly';
|
||||
import './Et2Date/Et2DateTimeReadonly';
|
||||
import './Et2Date/Et2DateTimeToday';
|
||||
import './Et2Description/Et2Description';
|
||||
|
Loading…
Reference in New Issue
Block a user