From f0e293a5133d36e2c9cdde03d1aacdcc5472c080 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 11 Nov 2015 14:59:00 -0800 Subject: [PATCH] Virtual panels working again with refactored code --- .../browse/src/BrowseObjectController.js | 2 +- platform/commonUI/edit/bundle.json | 4 ++-- .../commonUI/edit/src/actions/CancelAction.js | 17 +++++++---------- .../commonUI/edit/src/actions/EditAction.js | 5 +++-- platform/representation/bundle.json | 2 +- .../representation/src/gestures/DropGesture.js | 10 +++++----- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index 0953d06f4d..88b8e49af2 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -50,7 +50,7 @@ define( ((domainObject && domainObject.useCapability('view')) || []) .forEach(selectViewIfMatching); } - $scope.editMode = domainObject.getDomainObject ? true : false; + $scope.editMode = domainObject.hasCapability('editor') ? true : false; navigatedObject = domainObject; } diff --git a/platform/commonUI/edit/bundle.json b/platform/commonUI/edit/bundle.json index 37c6175d6b..8eb5703c02 100644 --- a/platform/commonUI/edit/bundle.json +++ b/platform/commonUI/edit/bundle.json @@ -38,7 +38,7 @@ { "key": "edit", "implementation": "actions/EditAction.js", - "depends": [ "$location", "navigationService", "$log" ], + "depends": [ "$location", "navigationService", "$log", "$q" ], "description": "Edit this object.", "category": "view-control", "glyph": "p" @@ -78,7 +78,7 @@ "implementation": "actions/CancelAction.js", "name": "Cancel", "description": "Discard changes made to these objects.", - "depends": [ "$location", "urlService", "navigationService" ] + "depends": ["$injector", "navigationService"] } ], "policies": [ diff --git a/platform/commonUI/edit/src/actions/CancelAction.js b/platform/commonUI/edit/src/actions/CancelAction.js index b1585f0bfc..1fc5ff3ac1 100644 --- a/platform/commonUI/edit/src/actions/CancelAction.js +++ b/platform/commonUI/edit/src/actions/CancelAction.js @@ -33,11 +33,10 @@ define( * @memberof platform/commonUI/edit * @implements {Action} */ - function CancelAction($location, urlService, navigationService, context) { + function CancelAction($injector, navigationService, context) { this.domainObject = context.domainObject; - this.$location = $location; - this.urlService = urlService; this.navigationService = navigationService; + this.objectService = $injector.get('objectService'); } /** @@ -48,8 +47,6 @@ define( */ CancelAction.prototype.perform = function () { var domainObject = this.domainObject, - $location = this.$location, - urlService = this.urlService, self = this; // Look up the object's "editor.completion" capability; @@ -69,11 +66,11 @@ define( // Discard the current root view (which will be the editing // UI, which will have been pushed atop the Browise UI.) function returnToBrowse() { - return self.navigationService.setNavigation(self.domainObject.getDomainObject()); - /*$location.path($location.path(urlService.urlForLocation( - "browse", - domainObject - )));*/ + self.objectService.getObjects([self.domainObject.getId()]).then(function(objects){ + return self.navigationService.setNavigation(objects[self.domainObject.getId()]); + }) + //return + // self.navigationService.setNavigation(self.domainObject.getDomainObject()); } return doCancel(getEditorCapability()) diff --git a/platform/commonUI/edit/src/actions/EditAction.js b/platform/commonUI/edit/src/actions/EditAction.js index a699036a18..6aa5919ccd 100644 --- a/platform/commonUI/edit/src/actions/EditAction.js +++ b/platform/commonUI/edit/src/actions/EditAction.js @@ -46,7 +46,7 @@ define( * @constructor * @implements {Action} */ - function EditAction($location, navigationService, $log, context) { + function EditAction($location, navigationService, $log, $q, context) { var domainObject = (context || {}).domainObject; // We cannot enter Edit mode if we have no domain object to @@ -65,6 +65,7 @@ define( this.domainObject = domainObject; this.$location = $location; this.navigationService = navigationService; + this.$q = $q; } /** @@ -72,7 +73,7 @@ define( */ EditAction.prototype.perform = function () { if (!this.domainObject.getDomainObject) { - this.navigationService.setNavigation(new EditableDomainObject(this.domainObject)); + this.navigationService.setNavigation(new EditableDomainObject(this.domainObject, this.$q)); } //this.$location.path("/edit"); }; diff --git a/platform/representation/bundle.json b/platform/representation/bundle.json index d1695247f4..cfbf66c393 100644 --- a/platform/representation/bundle.json +++ b/platform/representation/bundle.json @@ -22,7 +22,7 @@ "key": "drop", "implementation": "gestures/DropGesture.js", "depends": [ "dndService", "$q", "navigationService", - "objectService" ] + "objectService", "instantiate" ] }, { "key": "menu", diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index aea8f3b645..cb9ed09970 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -42,7 +42,7 @@ define( * @param {DomainObject} domainObject the domain object whose * composition should be modified as a result of the drop. */ - function DropGesture(dndService, $q, navigationService, objectService, element, domainObject) { + function DropGesture(dndService, $q, navigationService, objectService, instantiate, element, domainObject) { var actionCapability = domainObject.getCapability('action'), editableDomainObject, action; // Action for the drop, when it occurs @@ -73,15 +73,15 @@ define( function shouldCreateVirtualPanel(domainObject){ // return domainObject.useCapability('view').filter(function (view){ - return view.key==='plot' && domainObject.getModel().type!== 'telemetry.panel' - }).length > 0; + return view.key==='plot' && domainObject.getModel().type!== 'telemetry.panel' + }).length > 0; } function dragOver(e) { //Refresh domain object on each dragOver to catch external // updates to the model //Don't use EditableDomainObject for folders, allow immediate persistence - editableDomainObject = domainObject.getDomainObject || domainObject.getModel().type==='folder' ? domainObject : new EditableDomainObject(domainObject, $q); + editableDomainObject = domainObject.hasCapability('editor') || domainObject.getModel().type==='folder' ? domainObject : new EditableDomainObject(domainObject, $q); actionCapability = editableDomainObject.getCapability('action'); var event = (e || {}).originalEvent || e, @@ -117,7 +117,7 @@ define( id = uuid(); //ObjectService is wrapped by a decorator which is obscuring // the newObject method. - return objectService.objectService.newObject(id, model); + return instantiate(model, id); }