mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01: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
|
// eslint-disable-next-line no-console
|
||||||
// console.log('params:', query.getParams());
|
// console.log('params:', query.getParams());
|
||||||
|
|
||||||
this.queryParams = query.getParams();
|
this.queryParams = query.getQueryParams().getParams();
|
||||||
|
|
||||||
if (query.hasErrors()) {
|
if (query.hasErrors()) {
|
||||||
this.searching.set(false);
|
this.searching.set(false);
|
||||||
|
|
@ -106,7 +106,7 @@ class GlobalSearchComponent extends CardSearchPagedComponent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.runGlobalSearch(query.getParams());
|
this.runGlobalSearch(query.getQueryParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
searchInstructions() {
|
searchInstructions() {
|
||||||
|
|
|
||||||
|
|
@ -99,13 +99,14 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runGlobalSearch(params) {
|
runGlobalSearch(queryParams) {
|
||||||
this.searching.set(true);
|
this.searching.set(true);
|
||||||
this.stopSubscription();
|
this.stopSubscription();
|
||||||
this.subscriptionHandle = Meteor.subscribe(
|
this.subscriptionHandle = Meteor.subscribe(
|
||||||
'globalSearch',
|
'globalSearch',
|
||||||
this.sessionId,
|
this.sessionId,
|
||||||
params,
|
queryParams.params,
|
||||||
|
queryParams.text,
|
||||||
this.subscriptionCallbacks,
|
this.subscriptionCallbacks,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,15 @@ import moment from 'moment';
|
||||||
export class QueryParams {
|
export class QueryParams {
|
||||||
text = '';
|
text = '';
|
||||||
|
|
||||||
constructor(params = {}) {
|
constructor(params = {}, text = '') {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasOperator(operator) {
|
hasOperator(operator) {
|
||||||
return this.params[operator];
|
return (
|
||||||
|
this.params[operator] !== undefined && this.params[operator].length > 0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPredicate(operator, predicate) {
|
addPredicate(operator, predicate) {
|
||||||
|
|
@ -189,8 +192,8 @@ export class Query {
|
||||||
return this._errors.errorMessages();
|
return this._errors.errorMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
getParams() {
|
getQueryParams() {
|
||||||
return this.queryParams.getParams();
|
return this.queryParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
addPredicate(operator, predicate) {
|
addPredicate(operator, predicate) {
|
||||||
|
|
|
||||||
|
|
@ -80,14 +80,15 @@ Meteor.publish('myCards', function(sessionId) {
|
||||||
// return buildQuery(sessionId, queryParams);
|
// return buildQuery(sessionId, queryParams);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
Meteor.publish('globalSearch', function(sessionId, params) {
|
Meteor.publish('globalSearch', function(sessionId, params, text) {
|
||||||
check(sessionId, String);
|
check(sessionId, String);
|
||||||
check(params, Object);
|
check(params, Object);
|
||||||
|
check(text, String);
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('queryParams:', params);
|
// console.log('queryParams:', params);
|
||||||
|
|
||||||
return findCards(sessionId, buildQuery(new QueryParams(params)));
|
return findCards(sessionId, buildQuery(new QueryParams(params, text)));
|
||||||
});
|
});
|
||||||
|
|
||||||
function buildSelector(queryParams) {
|
function buildSelector(queryParams) {
|
||||||
|
|
@ -97,6 +98,9 @@ function buildSelector(queryParams) {
|
||||||
|
|
||||||
let selector = {};
|
let selector = {};
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
// console.log('queryParams:', queryParams);
|
||||||
|
|
||||||
if (queryParams.selector) {
|
if (queryParams.selector) {
|
||||||
selector = queryParams.selector;
|
selector = queryParams.selector;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -249,17 +253,13 @@ function buildSelector(queryParams) {
|
||||||
queryUsers[OPERATOR_MEMBER] = [];
|
queryUsers[OPERATOR_MEMBER] = [];
|
||||||
|
|
||||||
if (queryParams.hasOperator(OPERATOR_USER)) {
|
if (queryParams.hasOperator(OPERATOR_USER)) {
|
||||||
queryParams.getPredicates(OPERATOR_USER).forEach(query => {
|
queryParams.getPredicates(OPERATOR_USER).forEach(username => {
|
||||||
const users = Users.find({
|
const user = Users.findOne({ username });
|
||||||
username: query,
|
if (user) {
|
||||||
});
|
queryUsers[OPERATOR_MEMBER].push(user._id);
|
||||||
if (users.count()) {
|
queryUsers[OPERATOR_ASSIGNEE].push(user._id);
|
||||||
users.forEach(user => {
|
|
||||||
queryUsers[OPERATOR_MEMBER].push(user._id);
|
|
||||||
queryUsers[OPERATOR_ASSIGNEE].push(user._id);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
errors.addNotFound(OPERATOR_USER, query);
|
errors.addNotFound(OPERATOR_USER, username);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue