Skip to content

Commit

Permalink
Merge pull request #99 from pangara/MEM-527
Browse files Browse the repository at this point in the history
MEM-527 check for main document while removing collections
  • Loading branch information
marklise authored Sep 25, 2017
2 parents f424a89 + b65f38c commit 4a11253
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,15 @@ angular.module('documents')
var removed = _.filter(original, function(o) {
return !_.find(collections, function(c) { return o._id === c._id; });
});

// Updating collections:
// Addition - only other documents
// Removal - check main and other documents
promises = _.union(_.map(added, function(c) {
return CollectionModel.addOtherDocument(c._id, documents._id);
}), _.map(removed, function(c) {
return CollectionModel.removeOtherDocument(c._id, documents._id);
}), _.map(removed, function(c) {
return CollectionModel.removeMainDocument(c._id, documents._id);
}));

return Promise.all(promises).then(function() {
Expand Down

0 comments on commit 4a11253

Please sign in to comment.