From b1dca02fbe76aa8452afc25619d2ffcc093c27fe Mon Sep 17 00:00:00 2001 From: maurofmferrao Date: Fri, 7 Feb 2025 17:37:10 +0000 Subject: [PATCH] Layout Editor Viewer: Enable adding over selected object relates to xibosignage/xibo#3585 - also prevent double click add --- ui/src/layout-editor/viewer.js | 38 ++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/ui/src/layout-editor/viewer.js b/ui/src/layout-editor/viewer.js index a056b9b013..aa110c40c0 100644 --- a/ui/src/layout-editor/viewer.js +++ b/ui/src/layout-editor/viewer.js @@ -660,6 +660,10 @@ Viewer.prototype.handleInteractions = function() { const shiftIsPressed = e.shiftKey; + // Are we adding a card from the toolbar? + const addingFromToolbar = + !$.isEmptyObject(self.parent.toolbar.selectedCard); + // Right click open context menu if (e.which == 3) { return; @@ -827,7 +831,10 @@ Viewer.prototype.handleInteractions = function() { if ( $target.data('subType') === 'playlist' && $target.hasClass('designer-region') && - !$target.hasClass('selected') + ( + !$target.hasClass('selected') || + addingFromToolbar + ) ) { // If we're multi selecting, deselect all if (shiftIsPressed) { @@ -844,8 +851,12 @@ Viewer.prototype.handleInteractions = function() { self.selectObject($target, shiftIsPressed); } else if ( $target.find('.designer-widget').length > 0 && - !$target.find('.designer-widget').hasClass('selected') && - !$target.hasClass('selected') + ( + ( + !$target.find('.designer-widget').hasClass('selected') && + !$target.hasClass('selected') + ) || addingFromToolbar + ) ) { // If we're multi selecting, deselect all if (shiftIsPressed) { @@ -869,7 +880,10 @@ Viewer.prototype.handleInteractions = function() { ) ) && $target.hasClass('designer-region') && - !$target.hasClass('selected') + ( + !$target.hasClass('selected') || + addingFromToolbar + ) ) { // If we're multi selecting, deselect all if (shiftIsPressed) { @@ -888,7 +902,10 @@ Viewer.prototype.handleInteractions = function() { $target.hasClass('designer-element') || $target.hasClass('designer-element-group') ) && - !$target.hasClass('selected') + ( + !$target.hasClass('selected') || + addingFromToolbar + ) ) { // If we're multi selecting, deselect all if (shiftIsPressed) { @@ -905,7 +922,10 @@ Viewer.prototype.handleInteractions = function() { self.selectObject($target, shiftIsPressed); } else if ( $target.hasClass('group-select-overlay') && - !$target.parent().hasClass('selected') + ( + !$target.parent().hasClass('selected') || + addingFromToolbar + ) ) { // If we're multi selecting, deselect all if (shiftIsPressed) { @@ -934,6 +954,12 @@ Viewer.prototype.handleInteractions = function() { clearTimeout(timer); clicks = 0; + // If we're adding from the toolbar + // don't use double click + if (addingFromToolbar) { + return; + } + if ( $target.data('subType') === 'playlist' && !$target.hasClass('playlist-dynamic') &&