From 5bf750c90c1931cc3c3aca31c95431e0cf3b5bc4 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 20 Apr 2016 17:43:26 -0700 Subject: [PATCH] Fixed creation --- platform/commonUI/browse/src/creation/CreateAction.js | 11 +++++++++-- platform/commonUI/edit/src/actions/SaveAction.js | 2 +- platform/commonUI/edit/src/actions/SaveAsAction.js | 3 +-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/platform/commonUI/browse/src/creation/CreateAction.js b/platform/commonUI/browse/src/creation/CreateAction.js index e9029c4aa3..d294814304 100644 --- a/platform/commonUI/browse/src/creation/CreateAction.js +++ b/platform/commonUI/browse/src/creation/CreateAction.js @@ -83,6 +83,7 @@ define( CreateAction.prototype.perform = function () { var newModel = this.type.getInitialModel(), parentObject = this.navigationService.getNavigation(), + editorCapability, newObject; newModel.type = this.type.getKey(); @@ -90,12 +91,18 @@ define( newObject.useCapability('mutation', function(model){ model.location = parentObject.getId(); }); + editorCapability = newObject.getCapability("editor"); if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) { this.navigationService.setNavigation(newObject); - newObject.getCapability("action").perform("edit"); + return newObject.getCapability("action").perform("edit"); } else { - return newObject.getCapability('action').perform('save'); + editorCapability.edit(); + return newObject.useCapability("action").perform("save").then(function () { + return editorCapability.save(); + }, function () { + return editorCapability.cancel() + }); } }; diff --git a/platform/commonUI/edit/src/actions/SaveAction.js b/platform/commonUI/edit/src/actions/SaveAction.js index cf8675682e..fbd5e51e3f 100644 --- a/platform/commonUI/edit/src/actions/SaveAction.js +++ b/platform/commonUI/edit/src/actions/SaveAction.js @@ -60,7 +60,7 @@ define( // during editing. function doSave() { return domainObject.getCapability("editor").save() - .then(resolveWith(domainObject.getOriginalObject())); + .then(resolveWith(domainObject)); } // Discard the current root view (which will be the editing diff --git a/platform/commonUI/edit/src/actions/SaveAsAction.js b/platform/commonUI/edit/src/actions/SaveAsAction.js index 6d73b75308..2f609cfd42 100644 --- a/platform/commonUI/edit/src/actions/SaveAsAction.js +++ b/platform/commonUI/edit/src/actions/SaveAsAction.js @@ -157,8 +157,7 @@ define( SaveAsAction.appliesTo = function (context) { var domainObject = (context || {}).domainObject; return domainObject !== undefined && - domainObject.hasCapability("editor") && - domainObject.getCapability("editor").inEditContext() && + domainObject.getCapability("status").get("editing") && domainObject.getModel().persisted === undefined; };