[Persistence] Remove persistence usage from Remove action
This commit is contained in:
@@ -159,7 +159,6 @@ define([
|
|||||||
"name": "Remove",
|
"name": "Remove",
|
||||||
"description": "Remove this object from its containing object.",
|
"description": "Remove this object from its containing object.",
|
||||||
"depends": [
|
"depends": [
|
||||||
"$q",
|
|
||||||
"navigationService"
|
"navigationService"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,9 +41,8 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @implements {Action}
|
* @implements {Action}
|
||||||
*/
|
*/
|
||||||
function RemoveAction($q, navigationService, context) {
|
function RemoveAction(navigationService, context) {
|
||||||
this.domainObject = (context || {}).domainObject;
|
this.domainObject = (context || {}).domainObject;
|
||||||
this.$q = $q;
|
|
||||||
this.navigationService = navigationService;
|
this.navigationService = navigationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,8 +52,7 @@ define(
|
|||||||
* fulfilled when the action has completed.
|
* fulfilled when the action has completed.
|
||||||
*/
|
*/
|
||||||
RemoveAction.prototype.perform = function () {
|
RemoveAction.prototype.perform = function () {
|
||||||
var $q = this.$q,
|
var navigationService = this.navigationService,
|
||||||
navigationService = this.navigationService,
|
|
||||||
domainObject = this.domainObject;
|
domainObject = this.domainObject;
|
||||||
/*
|
/*
|
||||||
* Check whether an object ID matches the ID of the object being
|
* Check whether an object ID matches the ID of the object being
|
||||||
@@ -73,15 +71,6 @@ define(
|
|||||||
model.composition = model.composition.filter(isNotObject);
|
model.composition = model.composition.filter(isNotObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Invoke persistence on a domain object. This will be called upon
|
|
||||||
* the removed object's parent (as its composition will have changed.)
|
|
||||||
*/
|
|
||||||
function doPersist(domainObject) {
|
|
||||||
var persistence = domainObject.getCapability('persistence');
|
|
||||||
return persistence && persistence.persist();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks current object and ascendants of current
|
* Checks current object and ascendants of current
|
||||||
* object with object being removed, if the current
|
* object with object being removed, if the current
|
||||||
@@ -121,15 +110,10 @@ define(
|
|||||||
// navigates to existing object up tree
|
// navigates to existing object up tree
|
||||||
checkObjectNavigation(object, parent);
|
checkObjectNavigation(object, parent);
|
||||||
|
|
||||||
return $q.when(
|
return parent.useCapability('mutation', doMutate);
|
||||||
parent.useCapability('mutation', doMutate)
|
|
||||||
).then(function () {
|
|
||||||
return doPersist(parent);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $q.when(domainObject)
|
return removeFromContext(domainObject);
|
||||||
.then(removeFromContext);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Object needs to have a parent for Remove to be applicable
|
// Object needs to have a parent for Remove to be applicable
|
||||||
|
|||||||
Reference in New Issue
Block a user