mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Make results a reactive var
This commit is contained in:
parent
9b6288e49c
commit
91ef8ca1ae
2 changed files with 22 additions and 9 deletions
|
|
@ -35,7 +35,7 @@ template(name="globalSearch")
|
||||||
h1
|
h1
|
||||||
= resultsHeading.get
|
= resultsHeading.get
|
||||||
a.fa.fa-link(title="{{_ 'link-to-search' }}" href="{{ getSearchHref }}")
|
a.fa.fa-link(title="{{_ 'link-to-search' }}" href="{{ getSearchHref }}")
|
||||||
each card in results
|
each card in results.get
|
||||||
+resultCard(card)
|
+resultCard(card)
|
||||||
else
|
else
|
||||||
.global-search-instructions
|
.global-search-instructions
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ BlazeComponent.extendComponent({
|
||||||
this.myLists = new ReactiveVar([]);
|
this.myLists = new ReactiveVar([]);
|
||||||
this.myLabelNames = new ReactiveVar([]);
|
this.myLabelNames = new ReactiveVar([]);
|
||||||
this.myBoardNames = new ReactiveVar([]);
|
this.myBoardNames = new ReactiveVar([]);
|
||||||
|
this.results = new ReactiveVar([]);
|
||||||
this.queryParams = null;
|
this.queryParams = null;
|
||||||
this.parsingErrors = [];
|
this.parsingErrors = [];
|
||||||
this.resultsCount = 0;
|
this.resultsCount = 0;
|
||||||
|
|
@ -85,6 +86,7 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
resetSearch() {
|
resetSearch() {
|
||||||
this.searching.set(false);
|
this.searching.set(false);
|
||||||
|
this.results.set([]);
|
||||||
this.hasResults.set(false);
|
this.hasResults.set(false);
|
||||||
this.hasQueryErrors.set(false);
|
this.hasQueryErrors.set(false);
|
||||||
this.resultsHeading.set('');
|
this.resultsHeading.set('');
|
||||||
|
|
@ -94,7 +96,7 @@ BlazeComponent.extendComponent({
|
||||||
this.queryErrors = null;
|
this.queryErrors = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
results() {
|
getResults() {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('getting results');
|
// console.log('getting results');
|
||||||
if (this.queryParams) {
|
if (this.queryParams) {
|
||||||
|
|
@ -102,6 +104,9 @@ BlazeComponent.extendComponent({
|
||||||
userId: Meteor.userId(),
|
userId: Meteor.userId(),
|
||||||
sessionId: SessionData.getSessionId(),
|
sessionId: SessionData.getSessionId(),
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('session data:', sessionData);
|
||||||
|
|
||||||
const cards = Cards.find({ _id: { $in: sessionData.cards } });
|
const cards = Cards.find({ _id: { $in: sessionData.cards } });
|
||||||
this.queryErrors = sessionData.errorMessages;
|
this.queryErrors = sessionData.errorMessages;
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
@ -120,11 +125,11 @@ BlazeComponent.extendComponent({
|
||||||
this.totalHits = sessionData.totalHits;
|
this.totalHits = sessionData.totalHits;
|
||||||
this.resultsCount = cards.count();
|
this.resultsCount = cards.count();
|
||||||
this.resultsHeading.set(this.getResultsHeading());
|
this.resultsHeading.set(this.getResultsHeading());
|
||||||
return cards;
|
this.results.set(cards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.resultsCount = 0;
|
this.resultsCount = 0;
|
||||||
return [];
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
errorMessages() {
|
errorMessages() {
|
||||||
|
|
@ -141,6 +146,9 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
searchAllBoards(query) {
|
searchAllBoards(query) {
|
||||||
query = query.trim();
|
query = query.trim();
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('query:', query);
|
||||||
|
|
||||||
this.query.set(query);
|
this.query.set(query);
|
||||||
|
|
||||||
this.resetSearch();
|
this.resetSearch();
|
||||||
|
|
@ -149,9 +157,6 @@ BlazeComponent.extendComponent({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
// console.log('query:', query);
|
|
||||||
|
|
||||||
this.searching.set(true);
|
this.searching.set(true);
|
||||||
|
|
||||||
if (!this.colorMap) {
|
if (!this.colorMap) {
|
||||||
|
|
@ -195,7 +200,7 @@ BlazeComponent.extendComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('operatorMap:', operatorMap);
|
// console.log('operatorMap:', operatorMap);
|
||||||
const params = {
|
const params = {
|
||||||
boards: [],
|
boards: [],
|
||||||
swimlanes: [],
|
swimlanes: [],
|
||||||
|
|
@ -308,10 +313,17 @@ BlazeComponent.extendComponent({
|
||||||
params.text = text;
|
params.text = text;
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('params:', params);
|
console.log('params:', params);
|
||||||
|
|
||||||
this.queryParams = params;
|
this.queryParams = params;
|
||||||
|
|
||||||
|
if (this.parsingErrors.length) {
|
||||||
|
this.searching.set(false);
|
||||||
|
this.queryErrors = this.errorMessages();
|
||||||
|
this.hasQueryErrors.set(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.autorun(() => {
|
this.autorun(() => {
|
||||||
const handle = subManager.subscribe(
|
const handle = subManager.subscribe(
|
||||||
'globalSearch',
|
'globalSearch',
|
||||||
|
|
@ -323,6 +335,7 @@ BlazeComponent.extendComponent({
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('ready:', handle.ready());
|
// console.log('ready:', handle.ready());
|
||||||
if (handle.ready()) {
|
if (handle.ready()) {
|
||||||
|
this.getResults();
|
||||||
this.searching.set(false);
|
this.searching.set(false);
|
||||||
this.hasResults.set(true);
|
this.hasResults.set(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue