diff --git a/platform/commonUI/browse/src/creation/CreateAction.js b/platform/commonUI/browse/src/creation/CreateAction.js index c5097e166d..2e04a0b07e 100644 --- a/platform/commonUI/browse/src/creation/CreateAction.js +++ b/platform/commonUI/browse/src/creation/CreateAction.js @@ -83,25 +83,29 @@ define( CreateAction.prototype.perform = function () { var newModel = this.type.getInitialModel(), 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.location = parentObject.getId(); newObject = parentObject.useCapability('instantiation', newModel); + editorCapability = newObject.hasCapability('editor') && newObject.getCapability("editor"); - editorCapability = newObject.getCapability("editor"); - - if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) { - this.navigationService.setNavigation(newObject); - return newObject.getCapability("action").perform("edit"); - } else { + editAction = newObject.getCapability("action").getActions("edit")[0]; + if (editAction) { + return editAction.perform("edit"); + } else if (editorCapability) { editorCapability.edit(); - return newObject.useCapability("action").perform("save").then(function () { - return editorCapability.save(); - }, function () { - return editorCapability.cancel(); - }); + return newObject.useCapability("action").perform("save").then(onSave, onCancel); } }; diff --git a/platform/commonUI/edit/src/actions/EditAction.js b/platform/commonUI/edit/src/actions/EditAction.js index b2aae8fa1b..9e5c90d897 100644 --- a/platform/commonUI/edit/src/actions/EditAction.js +++ b/platform/commonUI/edit/src/actions/EditAction.js @@ -74,6 +74,12 @@ define( self.domainObject.getCapability('editor').cancel(); 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.domainObject.useCapability("editor"); };