Merge pull request #3459 from jrsupplee/new-search

Search All Boards: Added list of board, list and color names.
This commit is contained in:
Lauri Ojansivu 2021-01-22 16:21:01 +02:00 committed by GitHub
commit 1df060b8f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 198 additions and 9 deletions

View file

@ -1343,6 +1343,26 @@ if (Meteor.isServer) {
},
});
},
myLabelNames() {
let names = [];
Boards.userBoards(Meteor.userId()).forEach(board => {
names = names.concat(
board.labels
.filter(label => !!label.name)
.map(label => {
return label.name;
}),
);
});
return _.uniq(names).sort();
},
myBoardNames() {
return _.uniq(
Boards.userBoards(Meteor.userId()).map(board => {
return board.title;
}),
).sort();
},
});
Meteor.methods({

View file

@ -1954,6 +1954,18 @@ Cards.globalSearch = queryParams => {
selector.listId.$in = queryLists;
}
if (queryParams.dueAt !== null) {
selector.dueAt = { $gte: new Date(queryParams.dueAt) };
}
if (queryParams.createdAt !== null) {
selector.createdAt = { $gte: new Date(queryParams.createdAt) };
}
if (queryParams.modifiedAt !== null) {
selector.modifiedAt = { $gte: new Date(queryParams.modifiedAt) };
}
const queryMembers = [];
const queryAssignees = [];
if (queryParams.users.length) {
@ -2079,7 +2091,7 @@ Cards.globalSearch = queryParams => {
}
// eslint-disable-next-line no-console
// console.log('selector:', selector);
console.log('selector:', selector);
const cards = Cards.find(selector, {
fields: {
_id: 1,
@ -2094,13 +2106,15 @@ Cards.globalSearch = queryParams => {
assignees: 1,
colors: 1,
dueAt: 1,
createdAt: 1,
modifiedAt: 1,
labelIds: 1,
},
limit: 50,
});
// eslint-disable-next-line no-console
// console.log('count:', cards.count());
console.log('count:', cards.count());
return { cards, errors };
};

View file

@ -362,6 +362,20 @@ Meteor.methods({
const list = Lists.findOne({ _id: listId });
list.toggleSoftLimit(!list.getWipLimit('soft'));
},
myLists() {
// my lists
return _.uniq(
Lists.find(
{ boardId: { $in: Boards.userBoardIds(this.userId) } },
{ fields: { title: 1 } },
)
.fetch()
.map(list => {
return list.title;
}),
).sort();
},
});
Lists.hookOptions.after.update = { fetchPrevious: false };