From 04880b4154899af564989a8d9e3839926b28cfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauro=20Ferr=C3=A3o?= Date: Tue, 28 Jan 2025 10:00:06 +0000 Subject: [PATCH] Schedule Agenda: Fixes for select and delete Events (#2875) relates to xibosignage/xibo#3576 --- ui/src/core/xibo-calendar.js | 11 +++++++++-- ui/src/core/xibo-cms.js | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ui/src/core/xibo-calendar.js b/ui/src/core/xibo-calendar.js index 9dca2c98b5..ccd7a375d5 100644 --- a/ui/src/core/xibo-calendar.js +++ b/ui/src/core/xibo-calendar.js @@ -891,6 +891,9 @@ $(function() { $('.cal-context tbody tr').removeClass('selected'); $('.cal-context tbody tr').removeClass('selected-linked'); + // Remove previous layout preview + destroyMiniLayoutPreview(); + // If the element was already selected return // so that it can deselect everything if (alreadySelected) { @@ -918,7 +921,8 @@ $(function() { layoutPreviewUrl.replace(':id', $self.data('elemId')), ); - XiboInitialise(''); + // Initialize container for the Schedule modal handling + XiboInitialise('#CalendarContainer'); } // Select the clicked element and the linked elements @@ -1114,8 +1118,11 @@ window.setupScheduleForm = function(dialog) { XiboSubmitResponse(xhr, $form); if (xhr.success && calendar !== undefined) { - // Reload the Calendar + // Clear option cache calendar.options['clearCache'] = true; + // Make sure we remove mini layout preview + destroyMiniLayoutPreview(); + // Reload the Calendar calendar.view(); } }, diff --git a/ui/src/core/xibo-cms.js b/ui/src/core/xibo-cms.js index fbb9cfb73a..c3887ba704 100644 --- a/ui/src/core/xibo-cms.js +++ b/ui/src/core/xibo-cms.js @@ -3059,10 +3059,7 @@ window.createMiniLayoutPreview = function(previewUrl) { }); $layoutPreview.find('#closeBtn').off().on('click', function() { - // Close preview and empty content - $layoutPreview.find('#content').html(''); - $layoutPreview.removeClass('show'); - $layoutPreview.remove(); + destroyMiniLayoutPreview(); }); $layoutPreview.find('#newTabBtn').off().on('click', function() { @@ -3092,6 +3089,18 @@ window.createMiniLayoutPreview = function(previewUrl) { $layoutPreview.addClass('show'); }; +/** + * Destroy mini layout preview + */ +window.destroyMiniLayoutPreview = function() { + const $layoutPreview = $('.mini-layout-preview'); + + // Close preview and empty content + $layoutPreview.find('#content').html(''); + $layoutPreview.removeClass('show'); + $layoutPreview.remove(); +}; + /** * https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript * @param {number} size