8000 Fix bug in My Cards and Global Search by jrsupplee · Pull Request #3687 · wekan/wekan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix bug in My Cards and Global Search #3687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/components/main/globalSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -106,7 +106,7 @@ class GlobalSearchComponent extends CardSearchPagedComponent {
return;
}

this.runGlobalSearch(query.getParams());
this.runGlobalSearch(query.getQueryParams());
}

searchInstructions() {
Expand Down
5 changes: 3 additions & 2 deletions client/lib/cardSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down
11 changes: 7 additions & 4 deletions config/query-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -189,8 +192,8 @@ export class Query {
return this._errors.errorMessages();
}

getParams() {
return this.queryParams.getParams();
getQueryParams() {
return this.queryParams;
}

addPredicate(operator, predicate) {
Expand Down
24 changes: 12 additions & 12 deletions server/publications/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
});
}
Expand Down
0