mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Global search - add error messages for terms that are not found
This commit is contained in:
parent
4ab1a04814
commit
80b23e5cc1
7 changed files with 129 additions and 57 deletions
|
|
@ -19,6 +19,11 @@ template(name="globalSearch")
|
|||
h1
|
||||
= resultsCount.get
|
||||
| Results
|
||||
if queryErrors.get
|
||||
div
|
||||
each msg in errorMessages
|
||||
span.global-search-error-messages
|
||||
| {{_ msg.tag msg.value }}
|
||||
each card in results
|
||||
.global-search-card-wrapper
|
||||
a.minicard-wrapper.card-title(href=card.absoluteUrl)
|
||||
|
|
|
|||
|
|
@ -42,33 +42,50 @@ BlazeComponent.extendComponent({
|
|||
this.query = new ReactiveVar('');
|
||||
this.queryParams = null;
|
||||
this.resultsCount = new ReactiveVar(0);
|
||||
|
||||
// this.autorun(() => {
|
||||
// const handle = subManager.subscribe('globalSearch');
|
||||
// Tracker.nonreactive(() => {
|
||||
// Tracker.autorun(() => {
|
||||
// this.isPageReady.set(handle.ready());
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
this.queryErrors = new ReactiveVar(null);
|
||||
Meteor.subscribe('setting');
|
||||
},
|
||||
|
||||
results() {
|
||||
if (this.queryParams) {
|
||||
const cards = Cards.globalSearch(this.queryParams);
|
||||
this.resultsCount.set(cards.count());
|
||||
return cards;
|
||||
const results = Cards.globalSearch(this.queryParams);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('errors:', results.errors);
|
||||
this.resultsCount.set(results.cards.count());
|
||||
this.queryErrors.set(results.errors);
|
||||
return results.cards;
|
||||
}
|
||||
this.resultsCount.set(0);
|
||||
return [];
|
||||
},
|
||||
|
||||
errorMessages() {
|
||||
const errors = this.queryErrors.get();
|
||||
const messages = [];
|
||||
|
||||
errors.notFound.boards.forEach(board => {
|
||||
messages.push({ tag: 'board-title-not-found', value: board });
|
||||
});
|
||||
errors.notFound.swimlanes.forEach(swim => {
|
||||
messages.push({ tag: 'swimlane-title-not-found', value: swim });
|
||||
});
|
||||
errors.notFound.lists.forEach(list => {
|
||||
messages.push({ tag: 'list-title-not-found', value: list });
|
||||
});
|
||||
errors.notFound.users.forEach(user => {
|
||||
messages.push({ tag: 'user-username-not-found', value: user });
|
||||
});
|
||||
|
||||
return messages;
|
||||
},
|
||||
|
||||
events() {
|
||||
return [
|
||||
{
|
||||
'submit .js-search-query-form'(evt) {
|
||||
evt.preventDefault();
|
||||
this.query.set(evt.target.searchQuery.value);
|
||||
this.queryErrors.set(null);
|
||||
|
||||
if (!this.query.get()) {
|
||||
this.searching.set(false);
|
||||
|
|
|
|||
|
|
@ -67,3 +67,6 @@
|
|||
|
||||
.global-search-context-list
|
||||
margin-bottom: 0.7rem
|
||||
|
||||
.global-search-error-messages
|
||||
color: darkred
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue