flatpickr fix + add end date in slide list

This commit is contained in:
jr-k 2024-05-27 10:51:54 +02:00
parent 4991f6e2be
commit 745e21d2a3
2 changed files with 22 additions and 6 deletions

View File

@ -21,8 +21,10 @@ jQuery(document).ready(function ($) {
const loadDateTimePicker = function($els) { const loadDateTimePicker = function($els) {
$els.each(function() { $els.each(function() {
var $el = $(this); var $el = $(this);
$el.val(''); if (!$el.val()) {
const pickr = $el.flatpickr({ $el.val(prettyTimestamp(Date.now()).slice(0, -4));
}
$el.flatpickr({
enableTime: true, enableTime: true,
time_24hr: true, time_24hr: true,
allowInput: false, allowInput: false,
@ -199,7 +201,6 @@ jQuery(document).ready(function ($) {
$(document).on('click', '.slide-edit', function () { $(document).on('click', '.slide-edit', function () {
const slide = JSON.parse($(this).parents('tr:eq(0)').attr('data-entity')); const slide = JSON.parse($(this).parents('tr:eq(0)').attr('data-entity'));
showModal('modal-slide-edit'); showModal('modal-slide-edit');
loadDateTimePicker($('.modal-slide-edit .datetimepicker'))
const hasCron = slide.cron_schedule && slide.cron_schedule.length > 0; const hasCron = slide.cron_schedule && slide.cron_schedule.length > 0;
const hasDateTime = hasCron && validateCronDateTime(slide.cron_schedule); const hasDateTime = hasCron && validateCronDateTime(slide.cron_schedule);
@ -233,6 +234,8 @@ jQuery(document).ready(function ($) {
hasDateTimeEnd ? getCronDateTime(slide.cron_schedule_end) : '' hasDateTimeEnd ? getCronDateTime(slide.cron_schedule_end) : ''
); );
$('#slide-edit-id').val(slide.id); $('#slide-edit-id').val(slide.id);
loadDateTimePicker($('.modal-slide-edit .datetimepicker'));
inputSchedulerUpdate(); inputSchedulerUpdate();
}); });

View File

@ -9,7 +9,7 @@
{% endif %} {% endif %}
<th class="tac">{{ l.slideshow_slide_panel_th_enabled }}</th> <th class="tac">{{ l.slideshow_slide_panel_th_enabled }}</th>
<th class="">{{ l.slideshow_slide_panel_th_cron_scheduled }}</th> <th class="">{{ l.slideshow_slide_panel_th_cron_scheduled }}</th>
<th class="tac">{{ l.slideshow_slide_panel_th_duration }}</th> <th class="">{{ l.slideshow_slide_panel_th_duration }}</th>
<th class="tac">{{ l.slideshow_slide_panel_th_activity }}</th> <th class="tac">{{ l.slideshow_slide_panel_th_activity }}</th>
</tr> </tr>
</thead> </thead>
@ -74,8 +74,21 @@
🔄 {{ l.slideshow_slide_panel_td_cron_scheduled_loop }} 🔄 {{ l.slideshow_slide_panel_td_cron_scheduled_loop }}
{% endif %} {% endif %}
</td> </td>
<td class="tac"> <td class="">
{{ slide.duration }} {{ l.slideshow_slide_panel_th_duration_unit }} {% if slide.cron_schedule_end %}
{% set cron_desc_end = cron_descriptor(slide.cron_schedule_end) %}
{% if cron_desc_end %}
{% if is_validate_cron_date_time(slide.cron_schedule_end) %}
📆 {{ cron_desc_end }}
{% else %}
⏳ {{ cron_desc_end }}
{% endif %}
{% else %}
<span class="error">⚠️ {{ l.slideshow_slide_panel_td_cron_scheduled_bad_cron }}</span>
{% endif %}
{% else %}
⏱️ {{ slide.duration }} {{ l.slideshow_slide_panel_th_duration_unit }}
{% endif %}
</td> </td>
<td class="actions tac"> <td class="actions tac">
<a href="javascript:void(0);" class="item-edit slide-edit"> <a href="javascript:void(0);" class="item-edit slide-edit">