[Edit Mode] #627 remove edit concerns from browse controller
This commit is contained in:
@@ -170,6 +170,10 @@ define([
|
||||
}
|
||||
],
|
||||
"representations": [
|
||||
{
|
||||
"key": "view-region",
|
||||
"templateUrl": "templates/view-object.html"
|
||||
},
|
||||
{
|
||||
"key": "browse-object",
|
||||
"template": browseObjectTemplate,
|
||||
|
||||
@@ -47,11 +47,6 @@
|
||||
<div ng-if="isEditable" class="holder l-flex-col flex-elem grows l-object-wrapper-inner">
|
||||
<!-- Toolbar and Save/Cancel buttons -->
|
||||
<div class="l-edit-controls flex-elem l-flex-row flex-align-end">
|
||||
<mct-toolbar name="mctToolbar"
|
||||
structure="toolbar.structure"
|
||||
ng-model="toolbar.state"
|
||||
class="flex-elem grows">
|
||||
</mct-toolbar>
|
||||
<mct-representation key="'edit-action-buttons'"
|
||||
mct-object="domainObject"
|
||||
class='flex-elem conclude-editing'>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<mct-split-pane class='l-object-and-inspector contents abs' anchor='right'>
|
||||
<div class='split-pane-component t-object pane primary-pane left'>
|
||||
<mct-representation mct-object="navigatedObject"
|
||||
key="'browse-object'"
|
||||
key="'view-region'"
|
||||
class="abs holder holder-object">
|
||||
</mct-representation>
|
||||
</div>
|
||||
@@ -71,7 +71,7 @@
|
||||
<mct-splitter class="splitter-inspect mobile-hide flush-right edge-shdw"></mct-splitter>
|
||||
|
||||
<div class="split-pane-component t-inspect pane right mobile-hide">
|
||||
<mct-representation key="'object-inspector'"
|
||||
<mct-representation key="'inspector-region'"
|
||||
mct-object="navigatedObject"
|
||||
ng-model="treeModel">
|
||||
</mct-representation>
|
||||
|
||||
33
platform/commonUI/browse/res/templates/view-object.html
Normal file
33
platform/commonUI/browse/res/templates/view-object.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!--
|
||||
Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT Web includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<!--
|
||||
A representation that allows the 'View' region of an object view to change
|
||||
dynamically (eg. between browse and edit modes). Values correspond to a
|
||||
representation key, and currently defaults to 'browse-object'.
|
||||
|
||||
In the case of edit, the EditRepresenter will change this to editable
|
||||
representation of the object as needed.
|
||||
-->
|
||||
<mct-representation mct-object="domainObject"
|
||||
key="viewRegionTemplate || 'browse-object'"
|
||||
class="abs holder holder-object">
|
||||
</mct-representation>
|
||||
@@ -60,13 +60,6 @@ define(
|
||||
($route.current.params.ids || defaultPath).split("/")
|
||||
);
|
||||
|
||||
function isDirty(){
|
||||
var editorCapability = $scope.navigatedObject &&
|
||||
$scope.navigatedObject.getCapability("editor"),
|
||||
hasChanges = editorCapability && editorCapability.dirty();
|
||||
return hasChanges;
|
||||
}
|
||||
|
||||
function updateRoute(domainObject) {
|
||||
var priorRoute = $route.current,
|
||||
// Act as if params HADN'T changed to avoid page reload
|
||||
@@ -83,9 +76,7 @@ define(
|
||||
// urlService.urlForLocation used to adjust current
|
||||
// path to new, addressed, path based on
|
||||
// domainObject
|
||||
$location.path(urlService.urlForLocation("browse",
|
||||
domainObject.hasCapability('editor') ?
|
||||
domainObject.getOriginalObject() : domainObject));
|
||||
$location.path(urlService.urlForLocation("browse", domainObject));
|
||||
|
||||
}
|
||||
|
||||
@@ -97,17 +88,15 @@ define(
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDirty() && !confirm(CONFIRM_MSG)) {
|
||||
$scope.treeModel.selectedObject = $scope.navigatedObject;
|
||||
navigationService.setNavigation($scope.navigatedObject);
|
||||
} else {
|
||||
if ($scope.navigatedObject && $scope.navigatedObject.hasCapability("editor")){
|
||||
$scope.navigatedObject.getCapability("editor").cancel();
|
||||
}
|
||||
if (navigationService.setNavigation(domainObject)) {
|
||||
$scope.navigatedObject = domainObject;
|
||||
$scope.treeModel.selectedObject = domainObject;
|
||||
navigationService.setNavigation(domainObject);
|
||||
updateRoute(domainObject);
|
||||
} else {
|
||||
//If navigation was unsuccessful (ie. blocked), reset
|
||||
// the selected object in the tree to the currently
|
||||
// navigated object
|
||||
$scope.treeModel.selectedObject = $scope.navigatedObject ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,18 +173,13 @@ define(
|
||||
selectedObject: navigationService.getNavigation()
|
||||
};
|
||||
|
||||
$scope.beforeUnloadWarning = function() {
|
||||
return isDirty() ?
|
||||
"Unsaved changes will be lost if you leave this page." :
|
||||
undefined;
|
||||
};
|
||||
|
||||
// Listen for changes in navigation state.
|
||||
navigationService.addListener(setNavigation);
|
||||
|
||||
// Also listen for changes which come from the tree
|
||||
// Also listen for changes which come from the tree. Changes in
|
||||
// the tree will trigger a change in browse navigation state.
|
||||
$scope.$watch("treeModel.selectedObject", setNavigation);
|
||||
|
||||
|
||||
// Clean up when the scope is destroyed
|
||||
$scope.$on("$destroy", function () {
|
||||
navigationService.removeListener(setNavigation);
|
||||
|
||||
@@ -37,7 +37,7 @@ define(
|
||||
*/
|
||||
function NavigationService() {
|
||||
this.navigated = undefined;
|
||||
this.callbacks = [];
|
||||
this.callbacks = {};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,12 +53,20 @@ define(
|
||||
* @param {DomainObject} domainObject the domain object to navigate to
|
||||
*/
|
||||
NavigationService.prototype.setNavigation = function (value) {
|
||||
var canNavigate = true;
|
||||
if (this.navigated !== value) {
|
||||
this.navigated = value;
|
||||
this.callbacks.forEach(function (callback) {
|
||||
callback(value);
|
||||
});
|
||||
canNavigate = (this.callbacks['before'] || [])
|
||||
.reduce(function (previous, callback) {
|
||||
return callback(value) && previous;
|
||||
}, true);
|
||||
if (canNavigate) {
|
||||
this.navigated = value;
|
||||
this.callbacks['after'].forEach(function (callback) {
|
||||
callback(value);
|
||||
});
|
||||
}
|
||||
}
|
||||
return canNavigate;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,9 +75,13 @@ define(
|
||||
* this changes.
|
||||
* @param {function} callback the callback to invoke when
|
||||
* navigation state changes
|
||||
* @param {string} [event=after] the navigation event to listen to.
|
||||
* One of 'before' or 'after'.
|
||||
*/
|
||||
NavigationService.prototype.addListener = function (callback) {
|
||||
this.callbacks.push(callback);
|
||||
NavigationService.prototype.addListener = function (callback, event) {
|
||||
event = event || 'after';
|
||||
this.callbacks[event] = this.callbacks[event] || [];
|
||||
this.callbacks[event].push(callback);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -77,9 +89,12 @@ 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
|
||||
* callback is registered to. One of 'before' or 'after'.
|
||||
*/
|
||||
NavigationService.prototype.removeListener = function (callback) {
|
||||
this.callbacks = this.callbacks.filter(function (cb) {
|
||||
NavigationService.prototype.removeListener = function (callback, event) {
|
||||
event = event || 'after';
|
||||
this.callbacks[event] = this.callbacks[event].filter(function (cb) {
|
||||
return cb !== callback;
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user