[Persistence] Remove persistence usage from Remove action

This commit is contained in:
Victor Woeltjen
2016-04-26 16:53:12 -07:00
parent c99ffcb1f4
commit 433d26e703
2 changed files with 4 additions and 21 deletions

View File

@@ -159,7 +159,6 @@ define([
"name": "Remove",
"description": "Remove this object from its containing object.",
"depends": [
"$q",
"navigationService"
]
},

View File

@@ -41,9 +41,8 @@ define(
* @constructor
* @implements {Action}
*/
function RemoveAction($q, navigationService, context) {
function RemoveAction(navigationService, context) {
this.domainObject = (context || {}).domainObject;
this.$q = $q;
this.navigationService = navigationService;
}
@@ -53,8 +52,7 @@ define(
* fulfilled when the action has completed.
*/
RemoveAction.prototype.perform = function () {
var $q = this.$q,
navigationService = this.navigationService,
var navigationService = this.navigationService,
domainObject = this.domainObject;
/*
* Check whether an object ID matches the ID of the object being
@@ -73,15 +71,6 @@ define(
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
* object with object being removed, if the current
@@ -121,15 +110,10 @@ define(
// navigates to existing object up tree
checkObjectNavigation(object, parent);
return $q.when(
parent.useCapability('mutation', doMutate)
).then(function () {
return doPersist(parent);
});
return parent.useCapability('mutation', doMutate);
}
return $q.when(domainObject)
.then(removeFromContext);
return removeFromContext(domainObject);
};
// Object needs to have a parent for Remove to be applicable