Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout Editor Viewer: Enable adding over selected object #2906

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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