From 0c3133a7c5ea234192c0409965714abeb5f330d9 Mon Sep 17 00:00:00 2001 From: Jonas De Keukelaere Date: Wed, 2 Oct 2024 07:15:05 +0100 Subject: [PATCH] Fix time pickers --- src/js/Framework/DateTimePicker/DatePicker.js | 6 ++++-- src/js/Framework/DateTimePicker/DateTimePicker.js | 4 +--- src/js/Framework/DateTimePicker/TimePicker.js | 5 +---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/js/Framework/DateTimePicker/DatePicker.js b/src/js/Framework/DateTimePicker/DatePicker.js index 1d200d7..3f9f913 100644 --- a/src/js/Framework/DateTimePicker/DatePicker.js +++ b/src/js/Framework/DateTimePicker/DatePicker.js @@ -21,7 +21,7 @@ import { Spanish } from 'flatpickr/dist/l10n/es.js' import { Slovenian } from 'flatpickr/dist/l10n/sl.js' export class DatePicker { - constructor (element) { + constructor (element, enableTime = false, noCalendar = false) { this.element = element let locale = document.documentElement.lang @@ -31,7 +31,9 @@ export class DatePicker { try { this.element._flatpickr = flatpickr(this.element, { - locale: locale + locale: locale, + enableTime: enableTime, + noCalendar: noCalendar }) } catch (ex) { console.log('No translation found for ' + locale) diff --git a/src/js/Framework/DateTimePicker/DateTimePicker.js b/src/js/Framework/DateTimePicker/DateTimePicker.js index 9594b5b..13aaa97 100644 --- a/src/js/Framework/DateTimePicker/DateTimePicker.js +++ b/src/js/Framework/DateTimePicker/DateTimePicker.js @@ -2,8 +2,6 @@ import { DatePicker } from './DatePicker.js' export class DateTimePicker extends DatePicker { constructor (element) { - super(element) - - this.element._flatpickr.config.enableTime = true + super(element, true) } } diff --git a/src/js/Framework/DateTimePicker/TimePicker.js b/src/js/Framework/DateTimePicker/TimePicker.js index 01ff679..67b1a55 100644 --- a/src/js/Framework/DateTimePicker/TimePicker.js +++ b/src/js/Framework/DateTimePicker/TimePicker.js @@ -2,10 +2,7 @@ import { DatePicker } from './DatePicker.js' export class TimePicker extends DatePicker { constructor (element) { - super(element) - - this.element._flatpickr.config.enableTime = true - this.element._flatpickr.config.noCalendar = true + super(element, true, true) element.parentNode.querySelector('[data-flatpicker-clear]').addEventListener('click', event => this.element._flatpickr.clear()) }