diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:29:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:29:16 +0000 |
commit | 8a985929ed84cdb458a13c66b25f84e41133b24f (patch) | |
tree | 102a3d6e3cb731c6d23263095d0098f99572626d /library/Reporting/Web/Flatpickr.php | |
parent | Adding upstream version 0.10.0. (diff) | |
download | icingaweb2-module-reporting-upstream.tar.xz icingaweb2-module-reporting-upstream.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Reporting/Web/Flatpickr.php')
-rw-r--r-- | library/Reporting/Web/Flatpickr.php | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/library/Reporting/Web/Flatpickr.php b/library/Reporting/Web/Flatpickr.php deleted file mode 100644 index 5f6605d..0000000 --- a/library/Reporting/Web/Flatpickr.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2 - -namespace Icinga\Module\Reporting\Web; - -use Icinga\Application\Version; -use ipl\Html\Html; -use ipl\Web\Compat\CompatDecorator; - -class Flatpickr extends CompatDecorator -{ - protected $allowInput = true; - - /** - * Set whether to allow manual input - * - * @param bool $state - * - * @return $this - */ - public function setAllowInput(bool $state): self - { - $this->allowInput = $state; - - return $this; - } - - protected function assembleElement() - { - if (version_compare(Version::VERSION, '2.9.0', '>=')) { - $element = parent::assembleElement(); - } else { - $element = $this->formElement; - } - - if (version_compare(Version::VERSION, '2.10.0', '<')) { - $element->getAttributes()->set('data-use-flatpickr-fallback', true); - } else { - $element->getAttributes()->set('data-use-datetime-picker', true); - } - - if (! $this->allowInput) { - return $element; - } - - $element->getAttributes() - ->set('data-input', true) - ->set('data-flatpickr-wrap', true) - ->set('data-flatpickr-allow-input', true) - ->set('data-flatpickr-click-opens', 'false'); - - return [ - $element, - Html::tag('button', ['type' => 'button', 'class' => 'icon-calendar', 'data-toggle' => true]), - Html::tag('button', ['type' => 'button', 'class' => 'icon-cancel', 'data-clear' => true]) - ]; - } - - protected function assemble() - { - if (version_compare(Version::VERSION, '2.9.0', '>=')) { - parent::assemble(); - return; - } - - if ($this->formElement->hasBeenValidated() && ! $this->formElement->isValid()) { - $this->getAttributes()->add('class', 'has-error'); - } - - $this->add(array_filter([ - $this->assembleLabel(), - $this->assembleElement(), - $this->assembleDescription(), - $this->assembleErrors() - ])); - } -} |