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

@ -28,9 +28,9 @@ template(name="globalSearch")
.global-search-results-list-wrapper
if hasQueryErrors.get
div
each msg in errorMessages
each msg in queryErrors
span.global-search-error-messages
| {{_ msg.tag msg.value }}
= msg
else
h1
= resultsHeading.get

View file

@ -98,21 +98,26 @@ BlazeComponent.extendComponent({
// eslint-disable-next-line no-console
// console.log('getting results');
if (this.queryParams) {
const results = Cards.globalSearch(this.queryParams);
this.queryErrors = results.errors;
const sessionData = SessionData.findOne({ userId: Meteor.userId() });
const cards = Cards.find({ _id: { $in: sessionData.cards } });
this.queryErrors = sessionData.errorMessages;
// eslint-disable-next-line no-console
// console.log('errors:', this.queryErrors);
if (this.errorMessages().length) {
if (this.parsingErrors.length) {
this.queryErrors = this.errorMessages();
this.hasQueryErrors.set(true);
return null;
}
if (this.queryErrors.length) {
this.hasQueryErrors.set(true);
return null;
}
if (results.cards) {
const sessionData = SessionData.findOne({ userId: Meteor.userId() });
if (cards) {
this.totalHits = sessionData.totalHits;
this.resultsCount = results.cards.count();
this.resultsCount = cards.count();
this.resultsHeading.set(this.getResultsHeading());
return results.cards;
return cards;
}
}
this.resultsCount = 0;
@ -122,43 +127,9 @@ BlazeComponent.extendComponent({
errorMessages() {
const messages = [];
if (this.queryErrors) {
this.queryErrors.notFound.boards.forEach(board => {
messages.push({ tag: 'board-title-not-found', value: board });
});
this.queryErrors.notFound.swimlanes.forEach(swim => {
messages.push({ tag: 'swimlane-title-not-found', value: swim });
});
this.queryErrors.notFound.lists.forEach(list => {
messages.push({ tag: 'list-title-not-found', value: list });
});
this.queryErrors.notFound.labels.forEach(label => {
const color = Object.entries(this.colorMap)
.filter(value => value[1] === label)
.map(value => value[0]);
if (color.length) {
messages.push({
tag: 'label-color-not-found',
value: color[0],
});
} else {
messages.push({ tag: 'label-not-found', value: label });
}
});
this.queryErrors.notFound.users.forEach(user => {
messages.push({ tag: 'user-username-not-found', value: user });
});
this.queryErrors.notFound.members.forEach(user => {
messages.push({ tag: 'user-username-not-found', value: user });
});
this.queryErrors.notFound.assignees.forEach(user => {
messages.push({ tag: 'user-username-not-found', value: user });
});
}
if (this.parsingErrors.length) {
this.parsingErrors.forEach(err => {
messages.push(err);
messages.push(TAPi18n.__(err.tag, err.value));
});
}