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() status?: Status,
|
||||||
@Query() productGroupId?: string,
|
@Query() productGroupId?: string,
|
||||||
@Query() fullDetail?: boolean,
|
@Query() fullDetail?: boolean,
|
||||||
|
@Query() activeOnly?: boolean,
|
||||||
) {
|
) {
|
||||||
const where = {
|
const where = {
|
||||||
OR: queryOrNot<Prisma.ServiceWhereInput[]>(query, [
|
OR: queryOrNot<Prisma.ServiceWhereInput[]>(query, [
|
||||||
|
|
@ -162,20 +163,31 @@ export class ServiceController extends Controller {
|
||||||
{ code: { contains: query, mode: "insensitive" } },
|
{ code: { contains: query, mode: "insensitive" } },
|
||||||
]),
|
]),
|
||||||
AND: {
|
AND: {
|
||||||
...filterStatus(status),
|
...filterStatus(activeOnly ? Status.ACTIVE : status),
|
||||||
productGroupId,
|
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)
|
OR: isSystem(req.user)
|
||||||
? undefined
|
? undefined
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
productGroup: {
|
productGroup: {
|
||||||
registeredBranch: { OR: permissionCond(req.user) },
|
registeredBranch: { OR: permissionCond(req.user, { activeOnly }) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
shared: true,
|
shared: true,
|
||||||
productGroup: {
|
productGroup: {
|
||||||
registeredBranch: { OR: permissionCondShared(req.user) },
|
registeredBranch: { OR: permissionCondShared(req.user, { activeOnly }) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue