Skip to content
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

Fix desks template filter #4376

Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export class MoreTemplates extends React.PureComponent<IProps, IState> {
deskCriteria.push({[templateDesks]: {$in: [currentDeskId]}});
}

const criteria = {$or: [{$or: deskCriteria}, {user: sdApi.user.getCurrentUserId()}]};
const criteria = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use ISuperdeskQuery as here?

the logic also seems off inside criteria. I'd expect it to be
$or: [deskCriteria, {user: sdApi.user.getCurrentUserId()}]
why double $ors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't use ISuperdeskQuery, since we're working on the where filter which we don't do anything for in the ISuperdeskQuery or toElasticQuery. About the or - is because deskCriteria is an array of options.

$or: [
{$or: deskCriteria},
{$and: [{user: sdApi.user.getCurrentUserId()}, {$or: deskCriteria}]},
],
};
const templateName = nameof<ITemplate>('template_name');
const where = {$and: [criteria]};

Expand Down
Loading