Add methods to models for archived entities

This commit is contained in:
John R. Supplee 2021-01-11 18:18:26 +02:00
parent 01bd94d2b3
commit bbcb236a46
5 changed files with 115 additions and 44 deletions

View file

@ -1208,6 +1208,26 @@ function boardRemover(userId, doc) {
);
}
Boards.userBoards = (userId, includeArchived = false, selector = {}) => {
if (!includeArchived) {
selector = {
archived: false,
};
}
selector.$or = [
{ permission: 'public' },
{ members: { $elemMatch: { userId, isActive: true } } },
];
return Boards.find(selector);
};
Boards.userBoardIds = (userId, includeArchived = false, selector = {}) => {
return Boards.userBoards(userId, includeArchived, selector).map(board => {
return board._id;
});
};
if (Meteor.isServer) {
Boards.allow({
insert: Meteor.userId,

View file

@ -328,6 +328,16 @@ Lists.mutations({
},
});
Lists.archivedLists = () => {
return Lists.find({ archived: true });
};
Lists.archivedListIds = () => {
return Lists.archivedLists().map(list => {
return list._id;
});
};
Meteor.methods({
applyWipLimit(listId, limit) {
check(listId, String);

View file

@ -283,6 +283,16 @@ Swimlanes.mutations({
},
});
Swimlanes.archivedSwimlanes = () => {
return Swimlanes.find({ archived: true });
};
Swimlanes.archivedSwimlaneIds = () => {
return Swimlanes.archivedSwimlanes().map(swim => {
return swim._id;
});
};
Swimlanes.hookOptions.after.update = { fetchPrevious: false };
if (Meteor.isServer) {