diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 9f1834f80d..f65333870d 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -27,10 +27,9 @@ */ define( [ - '../../../representation/src/gestures/GestureConstants', - '../../edit/src/objects/EditableDomainObject' + '../../../representation/src/gestures/GestureConstants' ], - function (GestureConstants, EditableDomainObject) { + function (GestureConstants) { "use strict"; var ROOT_ID = "ROOT", diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index b0a93a991a..daf157e2c3 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -22,11 +22,8 @@ /*global define,Promise*/ define( - [ - '../../../representation/src/gestures/GestureConstants', - '../../edit/src/objects/EditableDomainObject' - ], - function (GestureConstants, EditableDomainObject) { + [], + function () { "use strict"; /** @@ -57,10 +54,9 @@ define( function updateQueryParam(viewKey) { var unlisten, - priorRoute = $route.current, - isEditMode = $scope.domainObject && $scope.domainObject.hasCapability('editor'); + priorRoute = $route.current; - if (viewKey && !isEditMode) { + if (viewKey) { $location.search('view', viewKey); unlisten = $scope.$on('$locationChangeSuccess', function () { // Checks path to make sure /browse/ is at front @@ -76,10 +72,6 @@ define( $scope.$watch('domainObject', setViewForDomainObject); $scope.$watch('representation.selected.key', updateQueryParam); - $scope.cancelEditing = function() { - navigationService.setNavigation($scope.domainObject.getDomainObject()); - }; - $scope.doAction = function (action){ return $scope[action] && $scope[action](); }; diff --git a/platform/commonUI/browse/src/navigation/NavigationService.js b/platform/commonUI/browse/src/navigation/NavigationService.js index e2b7168b3c..1d43971166 100644 --- a/platform/commonUI/browse/src/navigation/NavigationService.js +++ b/platform/commonUI/browse/src/navigation/NavigationService.js @@ -50,6 +50,8 @@ define( /** * Set the current navigation state. This will invoke listeners. + * Changing the navigation state will be blocked if any of the + * 'before' navigation state change listeners return 'false'. * @param {DomainObject} domainObject the domain object to navigate to */ NavigationService.prototype.setNavigation = function (value) { @@ -57,7 +59,11 @@ define( if (this.navigated !== value) { canNavigate = (this.callbacks['before'] || []) .reduce(function (previous, callback) { - return callback(value) && previous; + //Check whether the callback returned a value of + // 'false' indicating that navigation should not + // continue. All other return values will allow + // navigation to continue + return (callback(value)!==false) && previous; }, true); if (canNavigate) { this.navigated = value; @@ -72,7 +78,11 @@ define( /** * Listen for changes in navigation. The passed callback will * be invoked with the new domain object of navigation when - * this changes. + * this changes. Callbacks can be registered to listen to pre or + * post-navigation events. The event to listen to is specified using + * the event parameter. In the case of pre-navigation events + * returning a false value will prevent the navigation event from + * going ahead. * @param {function} callback the callback to invoke when * navigation state changes * @param {string} [event=after] the navigation event to listen to. @@ -89,7 +99,7 @@ define( * @param {function} callback the callback which should * no longer be invoked when navigation state * changes - * @param {string} [event=after] the navigation event to the + * @param {string} [event=after] the navigation event that the * callback is registered to. One of 'before' or 'after'. */ NavigationService.prototype.removeListener = function (callback, event) { diff --git a/platform/commonUI/edit/bundle.js b/platform/commonUI/edit/bundle.js index 9fc0c98939..e4b0953267 100644 --- a/platform/commonUI/edit/bundle.js +++ b/platform/commonUI/edit/bundle.js @@ -22,7 +22,6 @@ /*global define*/ define([ - "./src/controllers/EditController", "./src/controllers/EditActionController", "./src/controllers/EditPanesController", "./src/controllers/ElementsController", @@ -37,7 +36,6 @@ define([ "./src/policies/EditActionPolicy", "./src/representers/EditRepresenter", "./src/representers/EditToolbarRepresenter", - "text!./res/templates/edit.html", "text!./res/templates/library.html", "text!./res/templates/edit-object.html", "text!./res/templates/edit-action-buttons.html", @@ -45,7 +43,6 @@ define([ "text!./res/templates/topbar-edit.html", 'legacyRegistry' ], function ( - EditController, EditActionController, EditPanesController, ElementsController, @@ -60,7 +57,6 @@ define([ EditActionPolicy, EditRepresenter, EditToolbarRepresenter, - editTemplate, libraryTemplate, editObjectTemplate, editActionButtonsTemplate, @@ -72,22 +68,7 @@ define([ legacyRegistry.register("platform/commonUI/edit", { "extensions": { - "routes": [ - { - "when": "/edit", - "template": editTemplate - } - ], "controllers": [ - { - "key": "EditController", - "implementation": EditController, - "depends": [ - "$scope", - "$q", - "navigationService" - ] - }, { "key": "EditActionController", "implementation": EditActionController, diff --git a/platform/commonUI/edit/res/templates/edit-object.html b/platform/commonUI/edit/res/templates/edit-object.html index 7b2f32e1b3..9da28714a7 100644 --- a/platform/commonUI/edit/res/templates/edit-object.html +++ b/platform/commonUI/edit/res/templates/edit-object.html @@ -19,9 +19,8 @@ this source code distribution or the Licensing information page available at runtime from the About dialog for additional information. --> -