Display: Fix template for DatePicker element

pull/6066/head
Angel Fernando Quiroz Campos 7 months ago
parent 68813ee8ff
commit 47c7b2f4ee
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 27
      public/main/inc/lib/formvalidator/Element/DatePicker.php
  2. 2
      src/CoreBundle/Component/Utils/ActionIcon.php

@ -2,7 +2,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ToolIcon; use Chamilo\CoreBundle\Component\Utils\ActionIcon;
use Chamilo\CoreBundle\Component\Utils\ObjectIcon;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
/** /**
@ -20,7 +21,7 @@ class DatePicker extends HTML_QuickForm_text
if (!isset($attributes['id'])) { if (!isset($attributes['id'])) {
$attributes['id'] = $elementName; $attributes['id'] = $elementName;
} }
$attributes['class'] = 'form-control border flex-grow'; $attributes['class'] = 'p-component p-inputtext p-filled';
parent::__construct($elementName, $elementLabel, $attributes); parent::__construct($elementName, $elementLabel, $attributes);
$this->_appendName = true; $this->_appendName = true;
@ -57,20 +58,18 @@ class DatePicker extends HTML_QuickForm_text
$requiredSymbol = '<span class="form_required">*</span>'; $requiredSymbol = '<span class="form_required">*</span>';
} }
$attrs = $this->_attributes; $this->setAttribute('placeholder', get_lang('Select date'));
unset($attrs['id']);
return ' return '
<div>'.$requiredSymbol.$label.'</div> <label>'.$requiredSymbol.$label.'</label>
<div id="'.$id.'" class="flex items-center mt-1 flatpickr-wrapper" data-wrap="true"> <div id="'.$id.'_container" class="flex items-center mt-1 flatpickr-wrapper" data-wrap="true">
<input '.$this->_getAttrString($this->_attributes).' <input '.$this->_getAttrString($this->_attributes).' value="'.$value.'" data-input>
value="'.$value.'" placeholder="'.get_lang('Select date').'" data-input>
<div class="flex space-x-1 ml-2" id="button-addon3"> <div class="flex space-x-1 ml-2" id="button-addon3">
<button class="btn btn--secondary-outline mr-2" type="button" data-toggle> <button class="btn btn--secondary-outline mr-2" type="button" data-toggle>
<i class="pi pi-calendar pi-lg"></i> '.Display::getMdiIcon(ObjectIcon::AGENDA).'
</button> </button>
<button class="btn btn--secondary-outline" type="button" data-clear> <button class="btn btn--secondary-outline" type="button" data-clear>
<i class="pi pi-times pi-lg"></i> '.Display::getMdiIcon(ActionIcon::CLOSE).'
</button> </button>
</div> </div>
</div> </div>
@ -109,7 +108,7 @@ class DatePicker extends HTML_QuickForm_text
return "<script> return "<script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
function initializeFlatpickr() { function initializeFlatpickr() {
const fp = flatpickr('#{$id}', { const fp = flatpickr('#{$id}_container', {
locale: '{$localeCode}', locale: '{$localeCode}',
altInput: true, altInput: true,
altFormat: '{$altFormat}', altFormat: '{$altFormat}',
@ -119,11 +118,7 @@ class DatePicker extends HTML_QuickForm_text
wrap: true wrap: true
}); });
if ($('label[for=\"".$id."\"]').length > 0) { $('label[for=\"".$id."\"]').hide().addClass('datepicker-label');
$('label[for=\"".$id."\"]').hide();
}
document.querySelector('label[for=\"' + '{$id}' + '\"]').classList.add('datepicker-label');
} }
function loadLocale() { function loadLocale() {

@ -164,4 +164,6 @@ enum ActionIcon: string
case SWAP_FILE = 'file-swap'; case SWAP_FILE = 'file-swap';
case ADD_FILE_VARIATION = 'file-replace'; case ADD_FILE_VARIATION = 'file-replace';
case CLOSE = 'close';
} }

Loading…
Cancel
Save