From 0b79ec1235952d8dd7c350d9d45755133bb4c692 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Tue, 20 Dec 2016 14:45:08 -0800 Subject: [PATCH] [Browse] Simplify Edit Representation Simplify edit registration and remove extra abstractions. No longer attach a status listener for every representation-- just use a single watch for the edit controller. Simplifies logic involved in switching controllers. https://github.com/nasa/openmct/issues/1360 --- platform/commonUI/browse/bundle.js | 6 --- .../commonUI/browse/res/templates/browse.html | 2 +- .../browse/res/templates/view-object.html | 33 --------------- .../edit/src/representers/EditRepresenter.js | 41 +------------------ 4 files changed, 3 insertions(+), 79 deletions(-) delete mode 100644 platform/commonUI/browse/res/templates/view-object.html diff --git a/platform/commonUI/browse/bundle.js b/platform/commonUI/browse/bundle.js index bed2fd1fbd..0dd556c40c 100644 --- a/platform/commonUI/browse/bundle.js +++ b/platform/commonUI/browse/bundle.js @@ -41,7 +41,6 @@ define([ "text!./res/templates/items/items.html", "text!./res/templates/browse/object-properties.html", "text!./res/templates/browse/inspector-region.html", - "text!./res/templates/view-object.html", 'legacyRegistry' ], function ( BrowseController, @@ -64,7 +63,6 @@ define([ itemsTemplate, objectPropertiesTemplate, inspectorRegionTemplate, - viewObjectTemplate, legacyRegistry ) { @@ -141,10 +139,6 @@ define([ } ], "representations": [ - { - "key": "view-object", - "template": viewObjectTemplate - }, { "key": "browse-object", "template": browseObjectTemplate, diff --git a/platform/commonUI/browse/res/templates/browse.html b/platform/commonUI/browse/res/templates/browse.html index aa1415ca81..214c765add 100644 --- a/platform/commonUI/browse/res/templates/browse.html +++ b/platform/commonUI/browse/res/templates/browse.html @@ -63,7 +63,7 @@
- - - diff --git a/platform/commonUI/edit/src/representers/EditRepresenter.js b/platform/commonUI/edit/src/representers/EditRepresenter.js index 81252977b1..fa08d7be7b 100644 --- a/platform/commonUI/edit/src/representers/EditRepresenter.js +++ b/platform/commonUI/edit/src/representers/EditRepresenter.js @@ -47,7 +47,6 @@ define( var self = this; this.scope = scope; - this.listenHandle = undefined; // Mutate and persist a new version of a domain object's model. function doMutate(model) { @@ -90,51 +89,15 @@ define( // Place the "commit" method in the scope scope.commit = commit; - // Clean up when the scope is destroyed - scope.$on("$destroy", function () { - self.destroy(); - }); - } // Handle a specific representation of a specific domain object - EditRepresenter.prototype.represent = function represent(representation, representedObject) { - var scope = this.scope; - - // Track the key, to know which view configuration to save to. - this.key = (representation || {}).key; - // Track the represented object + EditRepresenter.prototype.represent = function (representation, representedObject) { this.domainObject = representedObject; - - // Ensure existing watches are released - this.destroy(); - - function setEditing() { - scope.viewObjectTemplate = 'edit-object'; - } - - /** - * Listen for changes in object state. If the object becomes - * editable then change the view and inspector regions - * object representation accordingly - */ - this.listenHandle = this.domainObject.getCapability('status').listen(function (statuses) { - if (statuses.indexOf('editing') !== -1) { - setEditing(); - } else { - delete scope.viewObjectTemplate; - } - }); - - if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()) { - setEditing(); - } }; // Respond to the destruction of the current representation. - EditRepresenter.prototype.destroy = function destroy() { - return this.listenHandle && this.listenHandle(); - }; + EditRepresenter.prototype.destroy = function () {}; return EditRepresenter; }