mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 21:17:18 -04:00
Global search fixes
* use @ and # as the abbrevs for the user and list operators * comment out debug code * Modify display of card result counts * Fix bug with publication not returning current user document
This commit is contained in:
parent
3214800741
commit
a56d47c768
5 changed files with 34 additions and 36 deletions
|
@ -18,13 +18,13 @@ template(name="globalSearch")
|
|||
.global-search-dueat-list-wrapper
|
||||
h1
|
||||
if $eq resultsCount.get 0
|
||||
| {{_ 'no-results' }}
|
||||
| {{_ 'no-cards-found' }}
|
||||
else if $eq resultsCount.get 1
|
||||
| {{_ 'one-result' }}
|
||||
| {{_ 'one-card-found' }}
|
||||
else if $eq resultsCount.get totalHits.get
|
||||
| {{_ 'n-results' resultsCount.get }}
|
||||
| {{_ 'n-cards-found' resultsCount.get }}
|
||||
else
|
||||
| {{_ 'n-of-n-results' resultsCount.get totalHits.get }}
|
||||
| {{_ 'n-n-of-n-cards-found' 1 resultsCount.get totalHits.get }}
|
||||
if queryErrors.get
|
||||
div
|
||||
each msg in errorMessages
|
||||
|
|
|
@ -51,7 +51,9 @@ BlazeComponent.extendComponent({
|
|||
if (this.queryParams) {
|
||||
const results = Cards.globalSearch(this.queryParams);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('count:', results.count);
|
||||
// console.log('user:', Meteor.user());
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('user:', Meteor.user().sessionData);
|
||||
// console.log('errors:', results.errors);
|
||||
this.totalHits.set(Meteor.user().sessionData.totalHits);
|
||||
this.resultsCount.set(results.cards.count());
|
||||
|
@ -103,10 +105,8 @@ BlazeComponent.extendComponent({
|
|||
// eslint-disable-next-line no-console
|
||||
// console.log('query:', query);
|
||||
|
||||
const reUser = /^@(?<user>[\w.:]+)(\s+|$)/;
|
||||
const reLabel = /^#(?<label>[\w:-]+)(\s+|$)/;
|
||||
const reOperator1 = /^(?<operator>\w+):(?<value>\w+)(\s+|$)/;
|
||||
const reOperator2 = /^(?<operator>\w+):(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/;
|
||||
const reOperator1 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<value>\w+)(\s+|$)/;
|
||||
const reOperator2 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/;
|
||||
const reText = /^(?<text>\S+)(\s+|$)/;
|
||||
const reQuotedText = /^(?<quote>["'])(?<text>\w+)\k<quote>(\s+|$)/;
|
||||
|
||||
|
@ -123,6 +123,8 @@ BlazeComponent.extendComponent({
|
|||
operatorMap[TAPi18n.__('operator-user-abbrev')] = 'users';
|
||||
operatorMap[TAPi18n.__('operator-is')] = 'is';
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('operatorMap:', operatorMap);
|
||||
const params = {
|
||||
boards: [],
|
||||
swimlanes: [],
|
||||
|
@ -134,22 +136,6 @@ BlazeComponent.extendComponent({
|
|||
|
||||
let text = '';
|
||||
while (query) {
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('query:', query);
|
||||
let m = query.match(reUser);
|
||||
if (m) {
|
||||
query = query.replace(reUser, '');
|
||||
params.users.push(m.groups.user);
|
||||
continue;
|
||||
}
|
||||
|
||||
m = query.match(reLabel);
|
||||
if (m) {
|
||||
query = query.replace(reLabel, '');
|
||||
params.labels.push(m.groups.label);
|
||||
continue;
|
||||
}
|
||||
|
||||
m = query.match(reOperator1);
|
||||
if (!m) {
|
||||
m = query.match(reOperator2);
|
||||
|
@ -160,7 +146,12 @@ BlazeComponent.extendComponent({
|
|||
query = query.replace(reOperator1, '');
|
||||
}
|
||||
if (m) {
|
||||
const op = m.groups.operator.toLowerCase();
|
||||
let op;
|
||||
if (m.groups.operator) {
|
||||
op = m.groups.operator.toLowerCase();
|
||||
} else {
|
||||
op = m.groups.abbrev;
|
||||
}
|
||||
if (op in operatorMap) {
|
||||
params[operatorMap[op]].push(m.groups.value);
|
||||
}
|
||||
|
@ -181,14 +172,12 @@ BlazeComponent.extendComponent({
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('selector:', selector);
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('text:', text);
|
||||
params.text = text;
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('selector:', selector);
|
||||
// console.log('params:', params);
|
||||
|
||||
this.queryParams = params;
|
||||
|
||||
|
|
|
@ -870,9 +870,10 @@
|
|||
"list-title-not-found": "List '%s' not found.",
|
||||
"user-username-not-found": "Username '%s' not found.",
|
||||
"globalSearch-title": "Search All Boards",
|
||||
"one-results": "One Result",
|
||||
"n-results": "%s Results",
|
||||
"n-of-n-results": "%s of %s Results",
|
||||
"no-cards-found": "No Cards Found",
|
||||
"one-card-found": "One Card Found",
|
||||
"n-cards-found": "%s Cards Found",
|
||||
"n-n-of-n-cards-found": "%s-%s of %s Cards Found",
|
||||
"operator-board": "board",
|
||||
"operator-board-abbrev": "b",
|
||||
"operator-swimlane": "swimlane",
|
||||
|
@ -880,8 +881,8 @@
|
|||
"operator-list": "list",
|
||||
"operator-list-abbrev": "l",
|
||||
"operator-label": "label",
|
||||
"operator-label-abbrev": "lbl",
|
||||
"operator-label-abbrev": "#",
|
||||
"operator-user": "user",
|
||||
"operator-user-abbrev": "u",
|
||||
"operator-user-abbrev": "@",
|
||||
"operator-is": "is"
|
||||
}
|
||||
|
|
|
@ -1740,7 +1740,9 @@ Cards.globalSearch = queryParams => {
|
|||
boards: [],
|
||||
swimlanes: [],
|
||||
lists: [],
|
||||
labels: [],
|
||||
users: [],
|
||||
is: [],
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1850,7 +1852,11 @@ Cards.globalSearch = queryParams => {
|
|||
});
|
||||
});
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('label:', label);
|
||||
const reLabel = new RegExp(label, 'i');
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('reLabel:', reLabel);
|
||||
boards = Boards.userSearch(userId, {
|
||||
labels: { $elemMatch: { name: reLabel } },
|
||||
});
|
||||
|
|
|
@ -179,14 +179,14 @@ Meteor.publish('globalSearch', function(queryParams) {
|
|||
check(queryParams, Object);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('queryParams:', queryParams);
|
||||
// console.log('queryParams:', queryParams);
|
||||
|
||||
const cards = Cards.globalSearch(queryParams).cards;
|
||||
|
||||
const boards = [];
|
||||
const swimlanes = [];
|
||||
const lists = [];
|
||||
const users = [];
|
||||
const users = [this.userId];
|
||||
|
||||
cards.forEach(card => {
|
||||
if (card.boardId) boards.push(card.boardId);
|
||||
|
@ -204,6 +204,8 @@ Meteor.publish('globalSearch', function(queryParams) {
|
|||
}
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('users:', users);
|
||||
return [
|
||||
cards,
|
||||
Boards.find({ _id: { $in: boards } }),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue