Defers legacy mutation of object till after a creation happens. (#3379)
* Defers legacy mutation of object till after a creation happens. * Fixes display layout to defer actions until objects.save returns * Revert back to localStorage... big oops!
This commit is contained in:
@@ -192,6 +192,7 @@ define([
|
||||
*/
|
||||
ObjectAPI.prototype.save = function (domainObject) {
|
||||
let provider = this.getProvider(domainObject.identifier);
|
||||
let savedResolve;
|
||||
let result;
|
||||
|
||||
if (!this.isPersistable(domainObject)) {
|
||||
@@ -200,8 +201,14 @@ define([
|
||||
result = Promise.resolve(true);
|
||||
} else {
|
||||
if (domainObject.persisted === undefined) {
|
||||
this.mutate(domainObject, 'persisted', domainObject.modified);
|
||||
result = provider.create(domainObject);
|
||||
domainObject.persisted = domainObject.modified;
|
||||
result = new Promise((resolve) => {
|
||||
savedResolve = resolve;
|
||||
});
|
||||
provider.create(domainObject).then((response) => {
|
||||
this.mutate(domainObject, 'persisted', domainObject.modified);
|
||||
savedResolve(response);
|
||||
});
|
||||
} else {
|
||||
this.mutate(domainObject, 'persisted', domainObject.modified);
|
||||
result = provider.update(domainObject);
|
||||
|
||||
Reference in New Issue
Block a user