|
|
|
@ -24,10 +24,10 @@ import { |
|
|
|
|
OPERATOR_LIMIT, |
|
|
|
|
OPERATOR_LIST, |
|
|
|
|
OPERATOR_MEMBER, |
|
|
|
|
OPERATOR_MODIFIED_AT, |
|
|
|
|
OPERATOR_MODIFIED_AT, OPERATOR_ORG, |
|
|
|
|
OPERATOR_SORT, |
|
|
|
|
OPERATOR_STATUS, |
|
|
|
|
OPERATOR_SWIMLANE, |
|
|
|
|
OPERATOR_SWIMLANE, OPERATOR_TEAM, |
|
|
|
|
OPERATOR_USER, |
|
|
|
|
ORDER_ASCENDING, |
|
|
|
|
PREDICATE_ALL, |
|
|
|
@ -49,6 +49,8 @@ import { |
|
|
|
|
} from '/config/search-const'; |
|
|
|
|
import { QueryErrors, QueryParams, Query } from '/config/query-classes'; |
|
|
|
|
import { CARD_TYPES } from '../../config/const'; |
|
|
|
|
import Org from "../../models/org"; |
|
|
|
|
import Team from "../../models/team"; |
|
|
|
|
|
|
|
|
|
const escapeForRegex = require('escape-string-regexp'); |
|
|
|
|
|
|
|
|
@ -151,6 +153,51 @@ function buildSelector(queryParams) { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (queryParams.hasOperator(OPERATOR_ORG)) { |
|
|
|
|
const orgs = []; |
|
|
|
|
queryParams.getPredicates(OPERATOR_ORG).forEach(name => { |
|
|
|
|
const org = Org.findOne({ |
|
|
|
|
$or: [ |
|
|
|
|
{ orgDisplayName: name }, |
|
|
|
|
{ orgShortName: name } |
|
|
|
|
] |
|
|
|
|
}); |
|
|
|
|
if (org) { |
|
|
|
|
orgs.push(org._id); |
|
|
|
|
} else { |
|
|
|
|
errors.addNotFound(OPERATOR_ORG, name); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (orgs.length) { |
|
|
|
|
boardsSelector.orgs = { |
|
|
|
|
$elemMatch: { orgId: { $in: orgs }, isActive: true } |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (queryParams.hasOperator(OPERATOR_TEAM)) { |
|
|
|
|
const teams = []; |
|
|
|
|
queryParams.getPredicates(OPERATOR_TEAM).forEach(name => { |
|
|
|
|
const team = Team.findOne({ |
|
|
|
|
$or: [ |
|
|
|
|
{ teamDisplayName: name }, |
|
|
|
|
{ teamShortName: name } |
|
|
|
|
] |
|
|
|
|
}); |
|
|
|
|
if (team) { |
|
|
|
|
teams.push(team._id); |
|
|
|
|
} else { |
|
|
|
|
errors.addNotFound(OPERATOR_TEAM, name); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (teams.length) { |
|
|
|
|
boardsSelector.teams = { |
|
|
|
|
$elemMatch: { teamId: { $in: teams }, isActive: true } |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
selector = { |
|
|
|
|
type: 'cardType-card', |
|
|
|
|
// boardId: { $in: Boards.userBoardIds(userId) },
|
|
|
|
@ -169,8 +216,8 @@ function buildSelector(queryParams) { |
|
|
|
|
$in: Boards.userBoardIds(userId, archived, boardsSelector), |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ swimlaneId: { $in: Swimlanes.archivedSwimlaneIds() } }, |
|
|
|
|
{ listId: { $in: Lists.archivedListIds() } }, |
|
|
|
|
{ swimlaneId: { $in: Swimlanes.userArchivedSwimlaneIds(userId) } }, |
|
|
|
|
{ listId: { $in: Lists.userArchivedListIds(userId) } }, |
|
|
|
|
{ archived: true }, |
|
|
|
|
], |
|
|
|
|
}); |
|
|
|
|