Skip to content

Commit

Permalink
Layout Editor Viewer: Enable adding over selected object (#2906)
Browse files Browse the repository at this point in the history
relates to xibosignage/xibo#3585

- also prevent double click add
  • Loading branch information
maurofmferrao authored Feb 10, 2025
1 parent 18a4800 commit 9ab1c67
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions ui/src/layout-editor/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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') &&
Expand Down

0 comments on commit 9ab1c67

Please sign in to comment.