[Add] Fix promise chaining in AddAction

This commit is contained in:
Victor Woeltjen 2016-03-21 10:32:02 -07:00
parent 9c9db3c24f
commit d12111d9b8

View File

@ -93,21 +93,23 @@ define(
return wizard.populateObjectFromInput(formValue, newObject);
}
function addToParent (populatedObject) {
parentObject.getCapability('composition').add(populatedObject);
return parentObject.getCapability('persistence').persist().then(function(){
return parentObject;
});
function persistAndReturn(domainObject) {
return domainObject.getCapability('persistence')
.persist()
.then(function () {
return domainObject;
});
}
function persistNewObject(object) {
return object.getCapability('persistence').persist();
function addToParent (populatedObject) {
parentObject.getCapability('composition').add(populatedObject);
return persistAndReturn(parentObject);
}
return this.dialogService
.getUserInput(wizard.getFormStructure(false), wizard.getInitialFormValue())
.then(populateObjectFromInput)
.then(persistNewObject)
.then(persistAndReturn)
.then(addToParent);
};