diff --git a/platform/commonUI/edit/src/actions/SaveAction.js b/platform/commonUI/edit/src/actions/SaveAction.js index 00dd5bb639..56923d1d51 100644 --- a/platform/commonUI/edit/src/actions/SaveAction.js +++ b/platform/commonUI/edit/src/actions/SaveAction.js @@ -37,11 +37,7 @@ define( * @memberof platform/commonUI/edit */ function SaveAction( - $q, - $location, $injector, - urlService, - navigationService, policyService, dialogService, creationService, @@ -49,17 +45,13 @@ define( context ) { this.domainObject = (context || {}).domainObject; - this.$location = $location; this.injectObjectService = function(){ this.objectService = $injector.get("objectService"); }; - this.urlService = urlService; - this.navigationService = navigationService; this.policyService = policyService; this.dialogService = dialogService; this.creationService = creationService; this.copyService = copyService; - this.$q = $q; } SaveAction.prototype.getObjectService = function(){ @@ -79,35 +71,29 @@ define( */ SaveAction.prototype.perform = function () { var domainObject = this.domainObject, - $location = this.$location, - urlService = this.urlService, copyService = this.copyService, self = this; function resolveWith(object){ - return function() { + return function () { return object; }; } function doWizardSave(parent) { var context = domainObject.getCapability("context"), - wizard = new CreateWizard(domainObject, parent, self.policyService); + wizard = new CreateWizard( + domainObject, + parent, + self.policyService + ); return self.dialogService - .getUserInput(wizard.getFormStructure(true), wizard.getInitialFormValue()) - .then(function(formValue){ - return wizard.populateObjectFromInput(formValue, domainObject); - }); - } - - function persistObject(object){ - - //Persist first to mark dirty - return object.getCapability('persistence').persist().then(function(){ - //then save permanently - return object.getCapability('editor').save(); - }); + .getUserInput( + wizard.getFormStructure(true), + wizard.getInitialFormValue() + ) + .then(wizard.populateObjectFromInput.bind(wizard)); } function fetchObject(objectId){ @@ -120,18 +106,6 @@ define( return fetchObject(object.getModel().location); } - function locateObjectInParent(parent){ - parent.getCapability('composition').add(domainObject.getId()); - return parent.getCapability('persistence').persist().then(function() { - return parent; - }); - } - - function doNothing() { - // Create cancelled, do nothing - return false; - } - function cancelEditingAfterClone(clonedObject) { return domainObject.getCapability("editor").cancel() .then(resolveWith(clonedObject)); @@ -150,7 +124,7 @@ define( .then(getParent) .then(copyService.perform.bind(copyService, domainObject)) .then(cancelEditingAfterClone) - .catch(doNothing); + .catch(resolveWith(false)); } else { return domainObject.getCapability("editor").save() .then(resolveWith(domainObject.getOriginalObject())); @@ -161,7 +135,7 @@ define( // UI, which will have been pushed atop the Browse UI.) function returnToBrowse(object) { if (object) { - self.navigationService.setNavigation(object); + object.getCapability("action").perform("navigate"); } return object; }