mirror of
https://github.com/nasa/openmct.git
synced 2025-06-10 19:31:42 +00:00
[New Edit Mode] #628 Removed duplicate logic from Create Action
This commit is contained in:
parent
5b6ea600ba
commit
eff46b076c
@ -83,25 +83,29 @@ define(
|
|||||||
CreateAction.prototype.perform = function () {
|
CreateAction.prototype.perform = function () {
|
||||||
var newModel = this.type.getInitialModel(),
|
var newModel = this.type.getInitialModel(),
|
||||||
parentObject = this.navigationService.getNavigation(),
|
parentObject = this.navigationService.getNavigation(),
|
||||||
editorCapability,
|
newObject,
|
||||||
newObject;
|
editAction,
|
||||||
|
editorCapability;
|
||||||
|
|
||||||
|
function onSave() {
|
||||||
|
return editorCapability.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCancel() {
|
||||||
|
return editorCapability.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
newModel.type = this.type.getKey();
|
newModel.type = this.type.getKey();
|
||||||
newModel.location = parentObject.getId();
|
newModel.location = parentObject.getId();
|
||||||
newObject = parentObject.useCapability('instantiation', newModel);
|
newObject = parentObject.useCapability('instantiation', newModel);
|
||||||
|
editorCapability = newObject.hasCapability('editor') && newObject.getCapability("editor");
|
||||||
|
|
||||||
editorCapability = newObject.getCapability("editor");
|
editAction = newObject.getCapability("action").getActions("edit")[0];
|
||||||
|
if (editAction) {
|
||||||
if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) {
|
return editAction.perform("edit");
|
||||||
this.navigationService.setNavigation(newObject);
|
} else if (editorCapability) {
|
||||||
return newObject.getCapability("action").perform("edit");
|
|
||||||
} else {
|
|
||||||
editorCapability.edit();
|
editorCapability.edit();
|
||||||
return newObject.useCapability("action").perform("save").then(function () {
|
return newObject.useCapability("action").perform("save").then(onSave, onCancel);
|
||||||
return editorCapability.save();
|
|
||||||
}, function () {
|
|
||||||
return editorCapability.cancel();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +74,12 @@ define(
|
|||||||
self.domainObject.getCapability('editor').cancel();
|
self.domainObject.getCapability('editor').cancel();
|
||||||
self.navigationService.removeListener(cancelEditing);
|
self.navigationService.removeListener(cancelEditing);
|
||||||
}
|
}
|
||||||
|
//If this is not the currently navigated object, then navigate
|
||||||
|
// to it.
|
||||||
|
if (this.navigationService.getNavigation() !== this.domainObject) {
|
||||||
|
this.navigationService.setNavigation(this.domainObject);
|
||||||
|
}
|
||||||
|
|
||||||
this.navigationService.addListener(cancelEditing);
|
this.navigationService.addListener(cancelEditing);
|
||||||
this.domainObject.useCapability("editor");
|
this.domainObject.useCapability("editor");
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user