feat: add support for active only service
resolves https://github.com/Frappet/jws-frontend/issues/148
This commit is contained in:
parent
a62d729ce6
commit
b05d2fe9d4
1 changed files with 15 additions and 3 deletions
|
|
@ -154,6 +154,7 @@ export class ServiceController extends Controller {
|
|||
@Query() status?: Status,
|
||||
@Query() productGroupId?: string,
|
||||
@Query() fullDetail?: boolean,
|
||||
@Query() activeOnly?: boolean,
|
||||
) {
|
||||
const where = {
|
||||
OR: queryOrNot<Prisma.ServiceWhereInput[]>(query, [
|
||||
|
|
@ -162,20 +163,31 @@ export class ServiceController extends Controller {
|
|||
{ code: { contains: query, mode: "insensitive" } },
|
||||
]),
|
||||
AND: {
|
||||
...filterStatus(status),
|
||||
...filterStatus(activeOnly ? Status.ACTIVE : status),
|
||||
productGroupId,
|
||||
productGroup: {
|
||||
status: activeOnly ? { not: Status.INACTIVE } : undefined,
|
||||
registeredBranch: activeOnly
|
||||
? {
|
||||
OR: [
|
||||
{ headOffice: { status: { not: Status.INACTIVE } } },
|
||||
{ headOffice: null, status: { not: Status.INACTIVE } },
|
||||
],
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
OR: isSystem(req.user)
|
||||
? undefined
|
||||
: [
|
||||
{
|
||||
productGroup: {
|
||||
registeredBranch: { OR: permissionCond(req.user) },
|
||||
registeredBranch: { OR: permissionCond(req.user, { activeOnly }) },
|
||||
},
|
||||
},
|
||||
{
|
||||
shared: true,
|
||||
productGroup: {
|
||||
registeredBranch: { OR: permissionCondShared(req.user) },
|
||||
registeredBranch: { OR: permissionCondShared(req.user, { activeOnly }) },
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue