mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01: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
|
.global-search-dueat-list-wrapper
|
||||||
h1
|
h1
|
||||||
if $eq resultsCount.get 0
|
if $eq resultsCount.get 0
|
||||||
| {{_ 'no-results' }}
|
| {{_ 'no-cards-found' }}
|
||||||
else if $eq resultsCount.get 1
|
else if $eq resultsCount.get 1
|
||||||
| {{_ 'one-result' }}
|
| {{_ 'one-card-found' }}
|
||||||
else if $eq resultsCount.get totalHits.get
|
else if $eq resultsCount.get totalHits.get
|
||||||
| {{_ 'n-results' resultsCount.get }}
|
| {{_ 'n-cards-found' resultsCount.get }}
|
||||||
else
|
else
|
||||||
| {{_ 'n-of-n-results' resultsCount.get totalHits.get }}
|
| {{_ 'n-n-of-n-cards-found' 1 resultsCount.get totalHits.get }}
|
||||||
if queryErrors.get
|
if queryErrors.get
|
||||||
div
|
div
|
||||||
each msg in errorMessages
|
each msg in errorMessages
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ BlazeComponent.extendComponent({
|
||||||
if (this.queryParams) {
|
if (this.queryParams) {
|
||||||
const results = Cards.globalSearch(this.queryParams);
|
const results = Cards.globalSearch(this.queryParams);
|
||||||
// eslint-disable-next-line no-console
|
// 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);
|
// console.log('errors:', results.errors);
|
||||||
this.totalHits.set(Meteor.user().sessionData.totalHits);
|
this.totalHits.set(Meteor.user().sessionData.totalHits);
|
||||||
this.resultsCount.set(results.cards.count());
|
this.resultsCount.set(results.cards.count());
|
||||||
|
|
@ -103,10 +105,8 @@ BlazeComponent.extendComponent({
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('query:', query);
|
// console.log('query:', query);
|
||||||
|
|
||||||
const reUser = /^@(?<user>[\w.:]+)(\s+|$)/;
|
const reOperator1 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<value>\w+)(\s+|$)/;
|
||||||
const reLabel = /^#(?<label>[\w:-]+)(\s+|$)/;
|
const reOperator2 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/;
|
||||||
const reOperator1 = /^(?<operator>\w+):(?<value>\w+)(\s+|$)/;
|
|
||||||
const reOperator2 = /^(?<operator>\w+):(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/;
|
|
||||||
const reText = /^(?<text>\S+)(\s+|$)/;
|
const reText = /^(?<text>\S+)(\s+|$)/;
|
||||||
const reQuotedText = /^(?<quote>["'])(?<text>\w+)\k<quote>(\s+|$)/;
|
const reQuotedText = /^(?<quote>["'])(?<text>\w+)\k<quote>(\s+|$)/;
|
||||||
|
|
||||||
|
|
@ -123,6 +123,8 @@ BlazeComponent.extendComponent({
|
||||||
operatorMap[TAPi18n.__('operator-user-abbrev')] = 'users';
|
operatorMap[TAPi18n.__('operator-user-abbrev')] = 'users';
|
||||||
operatorMap[TAPi18n.__('operator-is')] = 'is';
|
operatorMap[TAPi18n.__('operator-is')] = 'is';
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
// console.log('operatorMap:', operatorMap);
|
||||||
const params = {
|
const params = {
|
||||||
boards: [],
|
boards: [],
|
||||||
swimlanes: [],
|
swimlanes: [],
|
||||||
|
|
@ -134,22 +136,6 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
let text = '';
|
let text = '';
|
||||||
while (query) {
|
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);
|
m = query.match(reOperator1);
|
||||||
if (!m) {
|
if (!m) {
|
||||||
m = query.match(reOperator2);
|
m = query.match(reOperator2);
|
||||||
|
|
@ -160,7 +146,12 @@ BlazeComponent.extendComponent({
|
||||||
query = query.replace(reOperator1, '');
|
query = query.replace(reOperator1, '');
|
||||||
}
|
}
|
||||||
if (m) {
|
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) {
|
if (op in operatorMap) {
|
||||||
params[operatorMap[op]].push(m.groups.value);
|
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
|
// eslint-disable-next-line no-console
|
||||||
// console.log('text:', text);
|
// console.log('text:', text);
|
||||||
params.text = text;
|
params.text = text;
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('selector:', selector);
|
// console.log('params:', params);
|
||||||
|
|
||||||
this.queryParams = params;
|
this.queryParams = params;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -870,9 +870,10 @@
|
||||||
"list-title-not-found": "List '%s' not found.",
|
"list-title-not-found": "List '%s' not found.",
|
||||||
"user-username-not-found": "Username '%s' not found.",
|
"user-username-not-found": "Username '%s' not found.",
|
||||||
"globalSearch-title": "Search All Boards",
|
"globalSearch-title": "Search All Boards",
|
||||||
"one-results": "One Result",
|
"no-cards-found": "No Cards Found",
|
||||||
"n-results": "%s Results",
|
"one-card-found": "One Card Found",
|
||||||
"n-of-n-results": "%s of %s Results",
|
"n-cards-found": "%s Cards Found",
|
||||||
|
"n-n-of-n-cards-found": "%s-%s of %s Cards Found",
|
||||||
"operator-board": "board",
|
"operator-board": "board",
|
||||||
"operator-board-abbrev": "b",
|
"operator-board-abbrev": "b",
|
||||||
"operator-swimlane": "swimlane",
|
"operator-swimlane": "swimlane",
|
||||||
|
|
@ -880,8 +881,8 @@
|
||||||
"operator-list": "list",
|
"operator-list": "list",
|
||||||
"operator-list-abbrev": "l",
|
"operator-list-abbrev": "l",
|
||||||
"operator-label": "label",
|
"operator-label": "label",
|
||||||
"operator-label-abbrev": "lbl",
|
"operator-label-abbrev": "#",
|
||||||
"operator-user": "user",
|
"operator-user": "user",
|
||||||
"operator-user-abbrev": "u",
|
"operator-user-abbrev": "@",
|
||||||
"operator-is": "is"
|
"operator-is": "is"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1740,7 +1740,9 @@ Cards.globalSearch = queryParams => {
|
||||||
boards: [],
|
boards: [],
|
||||||
swimlanes: [],
|
swimlanes: [],
|
||||||
lists: [],
|
lists: [],
|
||||||
|
labels: [],
|
||||||
users: [],
|
users: [],
|
||||||
|
is: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1850,7 +1852,11 @@ Cards.globalSearch = queryParams => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
// console.log('label:', label);
|
||||||
const reLabel = new RegExp(label, 'i');
|
const reLabel = new RegExp(label, 'i');
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
// console.log('reLabel:', reLabel);
|
||||||
boards = Boards.userSearch(userId, {
|
boards = Boards.userSearch(userId, {
|
||||||
labels: { $elemMatch: { name: reLabel } },
|
labels: { $elemMatch: { name: reLabel } },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -179,14 +179,14 @@ Meteor.publish('globalSearch', function(queryParams) {
|
||||||
check(queryParams, Object);
|
check(queryParams, Object);
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('queryParams:', queryParams);
|
// console.log('queryParams:', queryParams);
|
||||||
|
|
||||||
const cards = Cards.globalSearch(queryParams).cards;
|
const cards = Cards.globalSearch(queryParams).cards;
|
||||||
|
|
||||||
const boards = [];
|
const boards = [];
|
||||||
const swimlanes = [];
|
const swimlanes = [];
|
||||||
const lists = [];
|
const lists = [];
|
||||||
const users = [];
|
const users = [this.userId];
|
||||||
|
|
||||||
cards.forEach(card => {
|
cards.forEach(card => {
|
||||||
if (card.boardId) boards.push(card.boardId);
|
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 [
|
return [
|
||||||
cards,
|
cards,
|
||||||
Boards.find({ _id: { $in: boards } }),
|
Boards.find({ _id: { $in: boards } }),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue