2073 - Filter by pending tickets
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
33158b05f6
commit
7e694c3e80
|
@ -67,6 +67,10 @@ module.exports = Self => {
|
|||
arg: 'problems',
|
||||
type: 'Boolean',
|
||||
description: `Whether to show only tickets with problems`
|
||||
}, {
|
||||
arg: 'pending',
|
||||
type: 'Boolean',
|
||||
description: `Whether to show only tickets with state 'Pending'`
|
||||
}, {
|
||||
arg: 'mine',
|
||||
type: 'Boolean',
|
||||
|
@ -130,7 +134,7 @@ module.exports = Self => {
|
|||
dateTo.setHours(23, 59, 0, 0);
|
||||
}
|
||||
|
||||
let where = buildFilter(ctx.args, (param, value) => {
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
|
@ -155,6 +159,17 @@ module.exports = Self => {
|
|||
return {'c.salesPersonFk': {inq: teamIds}};
|
||||
case 'alertLevel':
|
||||
return {'ts.alertLevel': value};
|
||||
case 'pending':
|
||||
if (value) {
|
||||
return {and: [
|
||||
{'st.alertLevel': 0},
|
||||
{'st.code': {neq: 'OK'}}
|
||||
]};
|
||||
} else {
|
||||
return {and: [
|
||||
{'st.alertLevel': {gt: 0}}
|
||||
]};
|
||||
}
|
||||
case 'id':
|
||||
case 'clientFk':
|
||||
case 'agencyModeFk':
|
||||
|
@ -244,7 +259,6 @@ module.exports = Self => {
|
|||
LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id
|
||||
LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`);
|
||||
|
||||
|
||||
let condition;
|
||||
let hasProblem;
|
||||
let range;
|
||||
|
|
|
@ -41,6 +41,34 @@ describe('ticket filter()', () => {
|
|||
const firstRow = result[0];
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(firstRow.ticketFk).toEqual(11);
|
||||
expect(firstRow.id).toEqual(11);
|
||||
});
|
||||
|
||||
it('should return the tickets with grouped state "Pending" and not "Ok"', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}};
|
||||
const filter = {};
|
||||
const result = await app.models.Ticket.filter(ctx, filter);
|
||||
const firstRow = result[0];
|
||||
const secondRow = result[1];
|
||||
const thirdRow = result[2];
|
||||
|
||||
expect(result.length).toEqual(3);
|
||||
expect(firstRow.state).toEqual('Arreglar');
|
||||
expect(secondRow.state).toEqual('Arreglar');
|
||||
expect(thirdRow.state).toEqual('Arreglar');
|
||||
});
|
||||
|
||||
it('should return the tickets that are not pending', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}};
|
||||
const filter = {};
|
||||
const result = await app.models.Ticket.filter(ctx, filter);
|
||||
const firstRow = result[0];
|
||||
const secondRow = result[1];
|
||||
const thirdRow = result[2];
|
||||
|
||||
expect(result.length).toEqual(13);
|
||||
expect(firstRow.state).toEqual('Entregado');
|
||||
expect(secondRow.state).toEqual('Entregado');
|
||||
expect(thirdRow.state).toEqual('Entregado');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -113,10 +113,16 @@
|
|||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Problems"
|
||||
label="With problems"
|
||||
ng-model="filter.problems"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Pending"
|
||||
ng-model="filter.pending"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
|
|
|
@ -10,4 +10,6 @@ Province: Provincia
|
|||
My team: Mi equipo
|
||||
Order id: Id pedido
|
||||
Grouped States: Estado agrupado
|
||||
Days onward: Días adelante
|
||||
Days onward: Días adelante
|
||||
With problems: Con problemas
|
||||
Pending: Pendientes
|
Loading…
Reference in New Issue