[Composition] Use composition.add during creation

This commit is contained in:
Victor Woeltjen 2015-09-01 17:11:09 -07:00
parent 194bc41322
commit 8e995eba8f

View File

@ -86,18 +86,9 @@ define(
// composition, so that it will subsequently appear
// as a child contained by that parent.
function addToComposition(id, parent, parentPersistence) {
var mutatationResult = parent.useCapability("mutation", function (model) {
if (Array.isArray(model.composition)) {
// Don't add if the id is already there
if (model.composition.indexOf(id) === -1) {
model.composition.push(id);
}
} else {
// This is abnormal; composition should be an array
self.$log.warn(NO_COMPOSITION_WARNING + parent.getId());
return false; // Cancel mutation
}
});
var compositionCapability = parent.getCapability('composition'),
mutationResult = compositionCapability &&
compositionCapability.add(id);
return self.$q.when(mutatationResult).then(function (result) {
if (!result) {