[Add] Fix promise chaining in AddAction
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user