From 9cfe6b5b7a38145b5da116efbc11a57dc0af4730 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 14 Dec 2021 12:05:06 +0100 Subject: [PATCH 1/3] feat(ticket): filter by route --- modules/ticket/back/methods/ticket/filter.js | 12 +++- .../back/methods/ticket/specs/filter.spec.js | 57 +++++++++++++++++++ modules/ticket/front/search-panel/index.html | 6 ++ .../ticket/front/search-panel/locale/es.yml | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index a015d2165..e0b563fe2 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -83,6 +83,11 @@ module.exports = Self => { type: 'boolean', description: `Whether to show only tickets with problems` }, + { + arg: 'route', + type: 'boolean', + description: `Whether to show only tickets with route` + }, { arg: 'pending', type: 'boolean', @@ -186,6 +191,10 @@ module.exports = Self => { case 'alertLevel': return {'ts.alertLevel': value}; + case 'route': + if (value == true) + return {'t.routeFk': {neq: null}}; + return {'t.routeFk': null}; case 'pending': if (value) { return {and: [ @@ -264,7 +273,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({ diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 01a652b73..f99a80827 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -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: {route: 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: {route: false}}; + const filter = {}; + const result = await models.Ticket.filter(ctx, filter, options); + + expect(result.length).toEqual(2); + + 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: {route: null}}; + const filter = {}; + const result = await models.Ticket.filter(ctx, filter, options); + + expect(result.length).toEqual(24); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html index 445729952..78ae72734 100644 --- a/modules/ticket/front/search-panel/index.html +++ b/modules/ticket/front/search-panel/index.html @@ -135,6 +135,12 @@ ng-model="filter.pending" triple-state="true"> + + diff --git a/modules/ticket/front/search-panel/locale/es.yml b/modules/ticket/front/search-panel/locale/es.yml index d6d01d0aa..fcb7cc7e3 100644 --- a/modules/ticket/front/search-panel/locale/es.yml +++ b/modules/ticket/front/search-panel/locale/es.yml @@ -12,6 +12,7 @@ Order id: Id cesta Grouped States: Estado agrupado Days onward: Días adelante With problems: Con problemas +With route: Con ruta Pending: Pendiente FREE: Libre DELIVERED: Servido From df34debcc60a86ff635b46b7423276aee22a28e5 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 Dec 2021 08:05:22 +0100 Subject: [PATCH 2/3] test(ticket_descriptor): repair --- e2e/helpers/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 24b87b398..8675797e7 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -524,7 +524,7 @@ export default { saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)', acceptDialog: '.vn-dialog.shown button[response="accept"]', acceptChangeHourButton: '.vn-dialog.shown button[response="accept"]', - descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(3) > section > span', + descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(4) > section > span', acceptInvoiceOutButton: '.vn-confirm.shown button[response="accept"]', acceptDeleteStowawayButton: '.vn-dialog.shown button[response="accept"]' }, From 831bfb0352b9cefad5877c5e988a1891b58bc85a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 Dec 2021 08:52:39 +0100 Subject: [PATCH 3/3] change route for hasRoute --- modules/ticket/back/methods/ticket/filter.js | 4 ++-- .../ticket/back/methods/ticket/specs/filter.spec.js | 10 +++++----- modules/ticket/front/search-panel/index.html | 4 ++-- modules/ticket/front/search-panel/locale/es.yml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 9e51d3607..58c440e95 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -84,7 +84,7 @@ module.exports = Self => { description: `Whether to show only tickets with problems` }, { - arg: 'route', + arg: 'hasRoute', type: 'boolean', description: `Whether to show only tickets with route` }, @@ -193,7 +193,7 @@ module.exports = Self => { case 'alertLevel': return {'ts.alertLevel': value}; - case 'route': + case 'hasRoute': if (value == true) return {'t.routeFk': {neq: null}}; return {'t.routeFk': null}; diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index d1d44bb9c..b251d5335 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -228,7 +228,7 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {route: true}}; + const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: true}}; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -247,11 +247,11 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {route: false}}; + const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: false}}; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(2); + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { @@ -266,11 +266,11 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {route: null}}; + const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: null}}; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(24); + expect(result.length).toEqual(27); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html index 78ae72734..b0d4963bd 100644 --- a/modules/ticket/front/search-panel/index.html +++ b/modules/ticket/front/search-panel/index.html @@ -137,8 +137,8 @@ diff --git a/modules/ticket/front/search-panel/locale/es.yml b/modules/ticket/front/search-panel/locale/es.yml index fcb7cc7e3..52cc04d6e 100644 --- a/modules/ticket/front/search-panel/locale/es.yml +++ b/modules/ticket/front/search-panel/locale/es.yml @@ -12,7 +12,7 @@ Order id: Id cesta Grouped States: Estado agrupado Days onward: Días adelante With problems: Con problemas -With route: Con ruta +Has route: Con ruta Pending: Pendiente FREE: Libre DELIVERED: Servido