From 038322e9aa76dcb17d97cf95a37066c4c15faa3c Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 8 Dec 2015 15:04:34 -0800 Subject: [PATCH] [Layout] Update raw positions on drop When handling a drop into the layout, store the panel's new position to the LayoutController's internal table of raw positions (in addition to writing it to the configuration.) Avoids https://github.com/nasa/openmctweb/issues/384 --- .../features/layout/src/LayoutController.js | 2 ++ .../layout/test/LayoutControllerSpec.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/platform/features/layout/src/LayoutController.js b/platform/features/layout/src/LayoutController.js index 017793d2e6..37f434ba88 100644 --- a/platform/features/layout/src/LayoutController.js +++ b/platform/features/layout/src/LayoutController.js @@ -85,6 +85,8 @@ define( $scope.commit("Dropped a frame."); } // Populate template-facing position for this id + self.rawPositions[id] = + $scope.configuration.panels[id]; self.populatePosition(id); // Layout may contain embedded views which will // listen for drops, so call preventDefault() so diff --git a/platform/features/layout/test/LayoutControllerSpec.js b/platform/features/layout/test/LayoutControllerSpec.js index bbed271d2c..338875823b 100644 --- a/platform/features/layout/test/LayoutControllerSpec.js +++ b/platform/features/layout/test/LayoutControllerSpec.js @@ -274,6 +274,23 @@ define( expect(parseInt(style.width, 10)).toBeGreaterThan(63); expect(parseInt(style.height, 10)).toBeGreaterThan(31); }); + + it("updates positions of existing objects on a drop", function () { + var oldStyle; + + mockScope.$watchCollection.mostRecentCall.args[1](); + + oldStyle = controller.getFrameStyle("b"); + + expect(oldStyle).toBeDefined(); + + // ...drop event... + mockScope.$on.mostRecentCall + .args[1](mockEvent, 'b', { x: 300, y: 100 }); + + expect(controller.getFrameStyle("b")) + .not.toEqual(oldStyle); + }); }); } );