Merge pull request '3426-ticket_search_panel filter by route' (#821) from 3426-ticket_index into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #821
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2021-12-21 11:08:16 +00:00
commit 35a24cecfa
4 changed files with 75 additions and 1 deletions

View File

@ -83,6 +83,11 @@ module.exports = Self => {
type: 'boolean',
description: `Whether to show only tickets with problems`
},
{
arg: 'hasRoute',
type: 'boolean',
description: `Whether to show only tickets with route`
},
{
arg: 'pending',
type: 'boolean',
@ -188,6 +193,10 @@ module.exports = Self => {
case 'alertLevel':
return {'ts.alertLevel': value};
case 'hasRoute':
if (value == true)
return {'t.routeFk': {neq: null}};
return {'t.routeFk': null};
case 'pending':
if (value) {
return {and: [
@ -266,7 +275,8 @@ module.exports = Self => {
LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
LEFT JOIN account.user u ON u.id = wk.userFk`);
LEFT JOIN account.user u ON u.id = wk.userFk
LEFT JOIN route r ON r.id = t.routeFk`);
if (args.orderFk) {
stmt.merge({

View File

@ -221,4 +221,61 @@ describe('ticket filter()', () => {
throw e;
}
});
it('should return the tickets matching the route on true', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: true}};
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(22);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the route on false', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: false}};
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the route on null', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: null}};
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(27);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -135,6 +135,12 @@
ng-model="filter.pending"
triple-state="true">
</vn-check>
<vn-check
vn-one
label="Has route"
ng-model="filter.hasRoute"
triple-state="true">
</vn-check>
</vn-horizontal>
<vn-horizontal class="vn-px-lg vn-pb-lg vn-mt-lg">
<vn-submit label="Search"></vn-submit>

View File

@ -12,6 +12,7 @@ Order id: Id cesta
Grouped States: Estado agrupado
Days onward: Días adelante
With problems: Con problemas
Has route: Con ruta
Pending: Pendiente
FREE: Libre
DELIVERED: Servido