mirror of
https://github.com/wekan/wekan.git
synced 2025-04-20 12:07:11 -04:00
Merge pull request #3687 from jrsupplee/issue-1667
Fix bug in My Cards and Global Search
This commit is contained in:
commit
04a8d85836
4 changed files with 24 additions and 20 deletions
|
@ -96,7 +96,7 @@ class GlobalSearchComponent extends CardSearchPagedComponent {
|
|||
// eslint-disable-next-line no-console
|
||||
// console.log('params:', query.getParams());
|
||||
|
||||
this.queryParams = query.getParams();
|
||||
this.queryParams = query.getQueryParams().getParams();
|
||||
|
||||
if (query.hasErrors()) {
|
||||
this.searching.set(false);
|
||||
|
@ -106,7 +106,7 @@ class GlobalSearchComponent extends CardSearchPagedComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
this.runGlobalSearch(query.getParams());
|
||||
this.runGlobalSearch(query.getQueryParams());
|
||||
}
|
||||
|
||||
searchInstructions() {
|
||||
|
|
|
@ -99,13 +99,14 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
|||
}
|
||||
}
|
||||
|
||||
runGlobalSearch(params) {
|
||||
runGlobalSearch(queryParams) {
|
||||
this.searching.set(true);
|
||||
this.stopSubscription();
|
||||
this.subscriptionHandle = Meteor.subscribe(
|
||||
'globalSearch',
|
||||
this.sessionId,
|
||||
params,
|
||||
queryParams.params,
|
||||
queryParams.text,
|
||||
this.subscriptionCallbacks,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -45,12 +45,15 @@ import moment from 'moment';
|
|||
export class QueryParams {
|
||||
text = '';
|
||||
|
||||
constructor(params = {}) {
|
||||
constructor(params = {}, text = '') {
|
||||
this.params = params;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
hasOperator(operator) {
|
||||
return this.params[operator];
|
||||
return (
|
||||
this.params[operator] !== undefined && this.params[operator].length > 0
|
||||
);
|
||||
}
|
||||
|
||||
addPredicate(operator, predicate) {
|
||||
|
@ -189,8 +192,8 @@ export class Query {
|
|||
return this._errors.errorMessages();
|
||||
}
|
||||
|
||||
getParams() {
|
||||
return this.queryParams.getParams();
|
||||
getQueryParams() {
|
||||
return this.queryParams;
|
||||
}
|
||||
|
||||
addPredicate(operator, predicate) {
|
||||
|
|
|
@ -80,14 +80,15 @@ Meteor.publish('myCards', function(sessionId) {
|
|||
// return buildQuery(sessionId, queryParams);
|
||||
// });
|
||||
|
||||
Meteor.publish('globalSearch', function(sessionId, params) {
|
||||
Meteor.publish('globalSearch', function(sessionId, params, text) {
|
||||
check(sessionId, String);
|
||||
check(params, Object);
|
||||
check(text, String);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('queryParams:', params);
|
||||
|
||||
return findCards(sessionId, buildQuery(new QueryParams(params)));
|
||||
return findCards(sessionId, buildQuery(new QueryParams(params, text)));
|
||||
});
|
||||
|
||||
function buildSelector(queryParams) {
|
||||
|
@ -97,6 +98,9 @@ function buildSelector(queryParams) {
|
|||
|
||||
let selector = {};
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('queryParams:', queryParams);
|
||||
|
||||
if (queryParams.selector) {
|
||||
selector = queryParams.selector;
|
||||
} else {
|
||||
|
@ -249,17 +253,13 @@ function buildSelector(queryParams) {
|
|||
queryUsers[OPERATOR_MEMBER] = [];
|
||||
|
||||
if (queryParams.hasOperator(OPERATOR_USER)) {
|
||||
queryParams.getPredicates(OPERATOR_USER).forEach(query => {
|
||||
const users = Users.find({
|
||||
username: query,
|
||||
});
|
||||
if (users.count()) {
|
||||
users.forEach(user => {
|
||||
queryUsers[OPERATOR_MEMBER].push(user._id);
|
||||
queryUsers[OPERATOR_ASSIGNEE].push(user._id);
|
||||
});
|
||||
queryParams.getPredicates(OPERATOR_USER).forEach(username => {
|
||||
const user = Users.findOne({ username });
|
||||
if (user) {
|
||||
queryUsers[OPERATOR_MEMBER].push(user._id);
|
||||
queryUsers[OPERATOR_ASSIGNEE].push(user._id);
|
||||
} else {
|
||||
errors.addNotFound(OPERATOR_USER, query);
|
||||
errors.addNotFound(OPERATOR_USER, username);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue