[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); return wizard.populateObjectFromInput(formValue, newObject);
} }
function addToParent (populatedObject) { function persistAndReturn(domainObject) {
parentObject.getCapability('composition').add(populatedObject); return domainObject.getCapability('persistence')
return parentObject.getCapability('persistence').persist().then(function(){ .persist()
return parentObject; .then(function () {
return domainObject;
}); });
} }
function persistNewObject(object) { function addToParent (populatedObject) {
return object.getCapability('persistence').persist(); parentObject.getCapability('composition').add(populatedObject);
return persistAndReturn(parentObject);
} }
return this.dialogService return this.dialogService
.getUserInput(wizard.getFormStructure(false), wizard.getInitialFormValue()) .getUserInput(wizard.getFormStructure(false), wizard.getInitialFormValue())
.then(populateObjectFromInput) .then(populateObjectFromInput)
.then(persistNewObject) .then(persistAndReturn)
.then(addToParent); .then(addToParent);
}; };