Pass found cards in sessionData cursor

This commit is contained in:
John R. Supplee 2021-01-24 02:32:37 +02:00
parent dd163b9923
commit 907bf4ffdc
7 changed files with 137 additions and 80 deletions

View file

@ -112,7 +112,7 @@ function commentCreation(userId, doc) {
CardComments.textSearch = (userId, textArray) => {
const selector = {
boardId: { $in: Boards.userBoardIds() },
boardId: { $in: Boards.userBoardIds(userId) },
$and: [],
};
@ -121,9 +121,12 @@ CardComments.textSearch = (userId, textArray) => {
}
// eslint-disable-next-line no-console
console.log(textArray);
console.log('cardComments selector:', selector);
return CardComments.find(selector);
const comments = CardComments.find(selector);
// eslint-disable-next-line no-console
console.log('count:', comments.count());
return comments;
};
if (Meteor.isServer) {

View file

@ -1882,6 +1882,12 @@ Cards.globalSearch = queryParams => {
assignees: [],
is: [],
};
this.colorMap = {};
for (const color of Boards.simpleSchema()._schema['labels.$.color']
.allowedValues) {
this.colorMap[TAPi18n.__(`color-${color}`)] = color;
}
}
hasErrors() {
@ -1892,6 +1898,41 @@ Cards.globalSearch = queryParams => {
}
return false;
}
errorMessages() {
const messages = [];
this.notFound.boards.forEach(board => {
messages.push(TAPi18n.__('board-title-not-found', board));
});
this.notFound.swimlanes.forEach(swim => {
messages.push(TAPi18n.__('swimlane-title-not-found', swim));
});
this.notFound.lists.forEach(list => {
messages.push(TAPi18n.__('list-title-not-found', list));
});
this.notFound.labels.forEach(label => {
const color = Object.entries(this.colorMap)
.filter(value => value[1] === label)
.map(value => value[0]);
if (color.length) {
messages.push(TAPi18n.__('label-color-not-found', color[0]));
} else {
messages.push(TAPi18n.__('label-not-found', label));
}
});
this.notFound.users.forEach(user => {
messages.push(TAPi18n.__('user-username-not-found', user));
});
this.notFound.members.forEach(user => {
messages.push(TAPi18n.__('user-username-not-found', user));
});
this.notFound.assignees.forEach(user => {
messages.push(TAPi18n.__('user-username-not-found', user));
});
return messages;
}
})();
const selector = {
@ -1956,6 +1997,14 @@ Cards.globalSearch = queryParams => {
selector.listId.$in = queryLists;
}
if (queryParams.comments.length) {
selector._id = {
$in: CardComments.textSearch(userId, queryParams.comments).map(com => {
return com.cardId;
}),
};
}
if (queryParams.dueAt !== null) {
selector.dueAt = { $lte: new Date(queryParams.dueAt) };
}
@ -2089,6 +2138,13 @@ Cards.globalSearch = queryParams => {
{ title: regex },
{ description: regex },
{ customFields: { $elemMatch: { value: regex } } },
{
_id: {
$in: CardComments.textSearch(userId, [queryParams.text]).map(
com => com.cardId,
),
},
},
];
}
@ -2153,7 +2209,7 @@ Cards.globalSearch = queryParams => {
const cards = Cards.find(selector, projection);
// eslint-disable-next-line no-console
//console.log('count:', cards.count());
console.log('count:', cards.count());
return { cards, errors };
};

View file

@ -39,6 +39,14 @@ SessionData.attachSchema(
type: Number,
optional: true,
},
cards: {
type: [String],
optional: true,
},
errorMessages: {
type: [String],
optional: true,
},
createdAt: {
/**
* creation date of the team