mirror of
https://github.com/wekan/wekan.git
synced 2025-12-20 01:10:12 +01:00
Global search development
* Add text query ability * limit results to 50 * display results count
This commit is contained in:
parent
34000ad159
commit
2e17f2b4b9
3 changed files with 18 additions and 2 deletions
|
|
@ -16,7 +16,9 @@ template(name="globalSearch")
|
||||||
+spinner
|
+spinner
|
||||||
else if hasResults.get
|
else if hasResults.get
|
||||||
.global-search-dueat-list-wrapper
|
.global-search-dueat-list-wrapper
|
||||||
h1 Results
|
h1
|
||||||
|
= resultsCount.get
|
||||||
|
| Results
|
||||||
each card in results
|
each card in results
|
||||||
.global-search-card-wrapper
|
.global-search-card-wrapper
|
||||||
a.minicard-wrapper.card-title(href=card.absoluteUrl)
|
a.minicard-wrapper.card-title(href=card.absoluteUrl)
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ BlazeComponent.extendComponent({
|
||||||
this.hasResults = new ReactiveVar(false);
|
this.hasResults = new ReactiveVar(false);
|
||||||
this.query = new ReactiveVar('');
|
this.query = new ReactiveVar('');
|
||||||
this.queryParams = null;
|
this.queryParams = null;
|
||||||
|
this.resultsCount = new ReactiveVar(0);
|
||||||
|
|
||||||
// this.autorun(() => {
|
// this.autorun(() => {
|
||||||
// const handle = subManager.subscribe('globalSearch');
|
// const handle = subManager.subscribe('globalSearch');
|
||||||
|
|
@ -55,7 +56,9 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
results() {
|
results() {
|
||||||
if (this.queryParams) {
|
if (this.queryParams) {
|
||||||
return Cards.globalSearch(this.queryParams);
|
const cards = Cards.globalSearch(this.queryParams);
|
||||||
|
this.resultsCount.set(cards.count());
|
||||||
|
return cards;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1798,6 +1798,16 @@ Cards.globalSearch = queryParams => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (queryParams.text) {
|
||||||
|
const regex = new RegExp(queryParams.text, 'i');
|
||||||
|
|
||||||
|
selector.$or = [
|
||||||
|
{ title: regex },
|
||||||
|
{ description: regex },
|
||||||
|
{ customFields: { $elemMatch: { value: regex } } },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('selector:', selector);
|
console.log('selector:', selector);
|
||||||
return Cards.find(selector, {
|
return Cards.find(selector, {
|
||||||
|
|
@ -1815,6 +1825,7 @@ Cards.globalSearch = queryParams => {
|
||||||
colors: 1,
|
colors: 1,
|
||||||
dueAt: 1,
|
dueAt: 1,
|
||||||
},
|
},
|
||||||
|
limit: 50,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue