mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 21:53:08 +00:00
This commit is contained in:
parent
ba669f1395
commit
2251a0c1e9
@ -55,42 +55,29 @@ define(
|
|||||||
function updateRoute(domainObject) {
|
function updateRoute(domainObject) {
|
||||||
var priorRoute = $route.current,
|
var priorRoute = $route.current,
|
||||||
// Act as if params HADN'T changed to avoid page reload
|
// Act as if params HADN'T changed to avoid page reload
|
||||||
unlisten,
|
unlisten;
|
||||||
navigateToObject = domainObject,
|
|
||||||
mode = "browse";
|
|
||||||
|
|
||||||
unlisten = $scope.$on('$locationChangeSuccess', function () {
|
unlisten = $scope.$on('$locationChangeSuccess', function () {
|
||||||
// Checks path to make sure /browse/ is at front
|
// Checks path to make sure /browse/ is at front
|
||||||
// if so, change $route.current
|
// if so, change $route.current
|
||||||
//if ($location.path().indexOf("/browse/") === 0) {
|
if ($location.path().indexOf("/browse/") === 0) {
|
||||||
$route.current = priorRoute;
|
$route.current = priorRoute;
|
||||||
//}
|
}
|
||||||
setNavigation(domainObject);
|
|
||||||
unlisten();
|
unlisten();
|
||||||
});
|
});
|
||||||
// urlService.urlForLocation used to adjust current
|
// urlService.urlForLocation used to adjust current
|
||||||
// path to new, addressed, path based on
|
// path to new, addressed, path based on
|
||||||
// domainObject
|
// domainObject
|
||||||
if (domainObject && domainObject.hasCapability("editor")){
|
$location.path(urlService.urlForLocation("browse", domainObject.hasCapability('editor') ? domainObject.getOriginalObject() : domainObject));
|
||||||
//Set navigation path to edit mode
|
|
||||||
mode = "edit";
|
|
||||||
//Unwrap non-editable object for url calculation (needs
|
|
||||||
// context capability
|
|
||||||
navigateToObject = domainObject.getOriginalObject();
|
|
||||||
}
|
|
||||||
$location.path(urlService.urlForLocation(mode, navigateToObject));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSelectedObject(domainObject) {
|
function setSelectedObject(domainObject) {
|
||||||
/* if (domainObject !== $scope.navigatedObject && isDirty()
|
if (domainObject !== $scope.navigatedObject && isDirty() && !confirm(CONFIRM_MSG)) {
|
||||||
&& !confirm(CONFIRM_MSG)) {
|
|
||||||
|
|
||||||
$scope.treeModel.selectedObject = $scope.navigatedObject;
|
$scope.treeModel.selectedObject = $scope.navigatedObject;
|
||||||
} else {
|
} else {
|
||||||
setNavigation(domainObject);
|
setNavigation(domainObject);
|
||||||
}*/
|
}
|
||||||
updateRoute(domainObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback for updating the in-scope reference to the object
|
// Callback for updating the in-scope reference to the object
|
||||||
@ -98,7 +85,8 @@ define(
|
|||||||
function setNavigation(domainObject) {
|
function setNavigation(domainObject) {
|
||||||
$scope.navigatedObject = domainObject;
|
$scope.navigatedObject = domainObject;
|
||||||
$scope.treeModel.selectedObject = domainObject;
|
$scope.treeModel.selectedObject = domainObject;
|
||||||
//navigationService.setNavigation(domainObject);
|
navigationService.setNavigation(domainObject);
|
||||||
|
updateRoute(domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigateTo(domainObject) {
|
function navigateTo(domainObject) {
|
||||||
@ -191,17 +179,14 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Listen for changes in navigation state.
|
// Listen for changes in navigation state.
|
||||||
navigationService.addListener(updateRoute);
|
navigationService.addListener(setNavigation);
|
||||||
|
|
||||||
// If the selected tree node changes, update the route. This
|
// Also listen for changes which come from the tree
|
||||||
// ensures navigation is always in sync with browser location,
|
$scope.$watch("treeModel.selectedObject", setSelectedObject);
|
||||||
// and also allows unload event to be used for catching
|
|
||||||
// navigation as well as browse events.
|
|
||||||
$scope.$watch("treeModel.selectedObject", updateRoute);
|
|
||||||
|
|
||||||
// Clean up when the scope is destroyed
|
// Clean up when the scope is destroyed
|
||||||
$scope.$on("$destroy", function () {
|
$scope.$on("$destroy", function () {
|
||||||
navigationService.removeListener(updateRoute);
|
navigationService.removeListener(setNavigation);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
"implementation": "actions/CancelAction.js",
|
"implementation": "actions/CancelAction.js",
|
||||||
"name": "Cancel",
|
"name": "Cancel",
|
||||||
"description": "Discard changes made to these objects.",
|
"description": "Discard changes made to these objects.",
|
||||||
"depends": ["$location", "urlService"]
|
"depends": ["$injector", "navigationService"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"policies": [
|
"policies": [
|
||||||
|
@ -33,10 +33,10 @@ define(
|
|||||||
* @memberof platform/commonUI/edit
|
* @memberof platform/commonUI/edit
|
||||||
* @implements {Action}
|
* @implements {Action}
|
||||||
*/
|
*/
|
||||||
function CancelAction($location, urlService, context) {
|
function CancelAction($injector, navigationService, context) {
|
||||||
this.domainObject = context.domainObject;
|
this.domainObject = context.domainObject;
|
||||||
this.$location = $location;
|
this.navigationService = navigationService;
|
||||||
this.urlService = urlService;
|
this.objectService = $injector.get('objectService');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,8 +47,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
CancelAction.prototype.perform = function () {
|
CancelAction.prototype.perform = function () {
|
||||||
var domainObject = this.domainObject,
|
var domainObject = this.domainObject,
|
||||||
$location = this.$location,
|
self = this;
|
||||||
urlService = this.urlService;
|
|
||||||
|
|
||||||
// Look up the object's "editor.completion" capability;
|
// Look up the object's "editor.completion" capability;
|
||||||
// this is introduced by EditableDomainObject which is
|
// this is introduced by EditableDomainObject which is
|
||||||
@ -64,13 +63,10 @@ define(
|
|||||||
return editor.cancel();
|
return editor.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard the current root view (which will be the editing
|
//Discard current 'editable' object, and retrieve original
|
||||||
// UI, which will have been pushed atop the Browise UI.)
|
// un-edited object.
|
||||||
function returnToBrowse() {
|
function returnToBrowse() {
|
||||||
$location.path(urlService.urlForLocation(
|
return self.navigationService.setNavigation(self.domainObject.getOriginalObject());
|
||||||
"browse",
|
|
||||||
domainObject.getOriginalObject()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return doCancel(getEditorCapability())
|
return doCancel(getEditorCapability())
|
||||||
|
@ -70,16 +70,27 @@ define(
|
|||||||
urlService = this.urlService,
|
urlService = this.urlService,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
function doWizardSave(domainObject, parent) {
|
function resolveWith(object){
|
||||||
|
return function() {return object};
|
||||||
|
}
|
||||||
|
|
||||||
|
function doWizardSave(parent) {
|
||||||
var context = domainObject.getCapability("context");
|
var context = domainObject.getCapability("context");
|
||||||
var wizard = new CreateWizard(domainObject.useCapability('type'), parent, self.policyService);
|
var wizard = new CreateWizard(domainObject.useCapability('type'), parent, self.policyService);
|
||||||
|
|
||||||
// Create and persist the new object, based on user
|
// Create and persist the new object, based on user
|
||||||
// input.
|
// input.
|
||||||
function persistResult(formValue) {
|
function buildObjectFromInput(formValue) {
|
||||||
var parent = wizard.getLocation(formValue),
|
var parent = wizard.getLocation(formValue),
|
||||||
newModel = wizard.createModel(formValue);
|
newModel = wizard.createModel(formValue);
|
||||||
return self.creationService.createObject(newModel, parent);
|
//Replace domain object model with model collected
|
||||||
|
// from user form.
|
||||||
|
domainObject.useCapability("mutation", function(){
|
||||||
|
newModel.location = parent.getId();
|
||||||
|
newModel.composition = domainObject.getModel().composition;
|
||||||
|
return newModel;
|
||||||
|
});
|
||||||
|
return domainObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
function doNothing() {
|
function doNothing() {
|
||||||
@ -87,29 +98,65 @@ define(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAllComposees(domainObject){
|
||||||
|
return domainObject.useCapability('composition');
|
||||||
|
}
|
||||||
|
|
||||||
|
function addComposeesToObject(object){
|
||||||
|
return function(composees){
|
||||||
|
return self.$q.all(composees.map(function (composee) {
|
||||||
|
return object.getCapability('composition').add(composee);
|
||||||
|
})).then(resolveWith(object));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the composees of the 'virtual' object to the
|
* Add the composees of the 'virtual' object to the
|
||||||
* persisted object
|
* persisted object
|
||||||
* @param object
|
* @param object
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function composeObject(object){
|
function composeNewObject(object){
|
||||||
return object && self.$q.when(object.hasCapability('composition') && domainObject.hasCapability('composition'))
|
if (self.$q.when(object.hasCapability('composition') && domainObject.hasCapability('composition'))) {
|
||||||
.then(function(){
|
return getAllComposees(domainObject)
|
||||||
return domainObject.useCapability('composition')
|
.then(addComposeesToObject(object))
|
||||||
.then(function(composees){
|
}
|
||||||
return self.$q.all(composees.map(function(composee){
|
|
||||||
object.getCapability('composition').add(composee);
|
|
||||||
return object;
|
|
||||||
})).then(function(){return object});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.dialogService.getUserInput(
|
return self.dialogService
|
||||||
wizard.getFormStructure(),
|
.getUserInput(wizard.getFormStructure(), wizard.getInitialFormValue())
|
||||||
wizard.getInitialFormValue()
|
.then(buildObjectFromInput, doNothing)
|
||||||
).then(persistResult, doNothing).then(composeObject);
|
//.then(composeNewObject)
|
||||||
|
//.then(object.getCapability("persistence"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function persistObject(object){
|
||||||
|
|
||||||
|
return (object.hasCapability('editor') && object.getCapability('editor').save() || object.getCapability('persistence').persist())
|
||||||
|
.then(resolveWith(object));
|
||||||
|
/*
|
||||||
|
if (object.hasCapability('editor')){
|
||||||
|
return object.getCapability('editor').save(true)
|
||||||
|
.then(resolveWith(object));
|
||||||
|
} else {
|
||||||
|
return object.useCapability(persistence);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchObject(objectId){
|
||||||
|
return self.getObjectService().getObjects([objectId]).then(function(objects){
|
||||||
|
return objects[objectId];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getParent(object){
|
||||||
|
return fetchObject(object.getModel().location);
|
||||||
|
}
|
||||||
|
|
||||||
|
function locateObjectInParent(parent){
|
||||||
|
parent.getCapability('composition').add(domainObject.getId());
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke any save behavior introduced by the editor capability;
|
// Invoke any save behavior introduced by the editor capability;
|
||||||
@ -121,20 +168,30 @@ define(
|
|||||||
//This is a new 'virtual panel' that has not been persisted
|
//This is a new 'virtual panel' that has not been persisted
|
||||||
// yet.
|
// yet.
|
||||||
if (domainObject.getModel().type === 'telemetry.panel' && !domainObject.getModel().persisted){
|
if (domainObject.getModel().type === 'telemetry.panel' && !domainObject.getModel().persisted){
|
||||||
return self.getObjectService()
|
return getParent(domainObject)
|
||||||
.getObjects([domainObject.getModel().location])
|
.then(doWizardSave)
|
||||||
.then(function(objs){ return doWizardSave(domainObject, objs[domainObject.getModel().location])});
|
.then(persistObject)
|
||||||
|
.then(getParent)//Parent may have changed based
|
||||||
|
// on user selection
|
||||||
|
.then(locateObjectInParent)
|
||||||
|
.then(persistObject)
|
||||||
|
.then(function(){return fetchObject(domainObject.getId());})
|
||||||
} else {
|
} else {
|
||||||
return domainObject.getCapability("editor").save().then(function(){return domainObject.getOriginalObject()});
|
return domainObject.getCapability("editor").save()
|
||||||
|
.then(resolveWith(domainObject.getOriginalObject()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard the current root view (which will be the editing
|
// Discard the current root view (which will be the editing
|
||||||
// UI, which will have been pushed atop the Browse UI.)
|
// UI, which will have been pushed atop the Browse UI.)
|
||||||
function returnToBrowse(object) {
|
function returnToBrowse(object) {
|
||||||
self.navigationService.setNavigation(object)
|
if (object) {
|
||||||
|
self.navigationService.setNavigation(object);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//return doSave().then(returnToBrowse);
|
||||||
return doSave().then(returnToBrowse);
|
return doSave().then(returnToBrowse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,7 +71,6 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldCreateVirtualPanel(domainObject){
|
function shouldCreateVirtualPanel(domainObject){
|
||||||
//
|
|
||||||
return domainObject.useCapability('view').filter(function (view){
|
return domainObject.useCapability('view').filter(function (view){
|
||||||
return view.key==='plot' && domainObject.getModel().type!== 'telemetry.panel'
|
return view.key==='plot' && domainObject.getModel().type!== 'telemetry.panel'
|
||||||
}).length > 0;
|
}).length > 0;
|
||||||
@ -116,8 +115,7 @@ define(
|
|||||||
newPanel = undefined;
|
newPanel = undefined;
|
||||||
|
|
||||||
model.type = typeKey;
|
model.type = typeKey;
|
||||||
model.name = 'New telemetry panel';
|
newPanel = new EditableDomainObject(instantiate(model, id), $q);
|
||||||
newPanel = instantiate(model, id);
|
|
||||||
|
|
||||||
[base.getId(), overlayId].forEach(function(id){
|
[base.getId(), overlayId].forEach(function(id){
|
||||||
newPanel.getCapability('composition').add(id)
|
newPanel.getCapability('composition').add(id)
|
||||||
@ -125,11 +123,11 @@ define(
|
|||||||
|
|
||||||
newPanel.getCapability('location').setPrimaryLocation(base.getCapability('location').getContextualLocation());
|
newPanel.getCapability('location').setPrimaryLocation(base.getCapability('location').getContextualLocation());
|
||||||
|
|
||||||
//ObjectService is wrapped by a decorator which is obscuring
|
//var virtualPanel = new EditableDomainObject(newPanel, $q);
|
||||||
// the newObject method.
|
//virtualPanel.setOriginalObject(base);
|
||||||
var virtualPanel = new EditableDomainObject(newPanel, $q);
|
newPanel.setOriginalObject(base);
|
||||||
virtualPanel.setOriginalObject(base);
|
//return virtualPanel;
|
||||||
return virtualPanel;
|
return newPanel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user