From 6f3d6ec12f12d75681e91cfa3b4e5154f3bde8f3 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 25 Jun 2015 11:27:56 -0700 Subject: [PATCH] [Drag-Drop] Prevent redundant drops Mark default as prevented and check for prevention of default when handling mctDrop events (which allow views to follow up on drop gestures by positioning objects within themselves) avoiding redundant drops into embedded views. WTD-1233. --- platform/features/layout/src/FixedController.js | 6 +++++- platform/features/layout/src/LayoutController.js | 9 ++++++++- platform/persistence/elastic/bundle.json | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index b87a6cb9d2..db742aa3da 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -249,6 +249,10 @@ define( // Position a panel after a drop event function handleDrop(e, id, position) { + // Don't handle this event if it has already been handled + if (e.isDefaultPrevented()) { + return; + } // Store the position of this element. addElement({ type: "fixed.telemetry", @@ -372,4 +376,4 @@ define( return FixedController; } -); \ No newline at end of file +); diff --git a/platform/features/layout/src/LayoutController.js b/platform/features/layout/src/LayoutController.js index fc6c8aafba..a3219667f9 100644 --- a/platform/features/layout/src/LayoutController.js +++ b/platform/features/layout/src/LayoutController.js @@ -109,6 +109,9 @@ define( // Position a panel after a drop event function handleDrop(e, id, position) { + if (e.isDefaultPrevented()) { + return; + } // Ensure that configuration field is populated $scope.configuration = $scope.configuration || {}; // Make sure there is a "panels" field in the @@ -129,6 +132,10 @@ define( } // Populate template-facing position for this id populatePosition(id); + // Layout may contain embedded views which will + // listen for drops, so call preventDefault() so + // that they can recognize that this event is handled. + e.preventDefault(); } // Position panes when the model field changes @@ -220,4 +227,4 @@ define( return LayoutController; } -); \ No newline at end of file +); diff --git a/platform/persistence/elastic/bundle.json b/platform/persistence/elastic/bundle.json index 371b8aa17a..e7dfa1ab9d 100644 --- a/platform/persistence/elastic/bundle.json +++ b/platform/persistence/elastic/bundle.json @@ -17,7 +17,7 @@ }, { "key": "ELASTIC_ROOT", - "value": "/elastic", + "value": "http://localhost:9200", "priority": "fallback" }, { @@ -43,4 +43,4 @@ } ] } -} \ No newline at end of file +}