From 0a8153d44ce3a65020bd0f2660779c76fb139703 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 26 Jan 2022 10:09:47 +0100 Subject: [PATCH 1/2] feat(travel_search-panel): add continent filter --- modules/travel/back/methods/travel/filter.js | 37 ++++++++++++------- .../back/methods/travel/specs/filter.spec.js | 12 ++++++ modules/travel/front/search-panel/index.html | 9 +++++ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 024448bfe..586b4e5aa 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -10,64 +10,68 @@ module.exports = Self => { accepts: [ { arg: 'filter', - type: 'Object', + type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} }, { arg: 'search', - type: 'String', + type: 'string', description: 'Searchs the travel by id', http: {source: 'query'} }, { arg: 'id', - type: 'Integer', + type: 'integer', description: 'The travel id', http: {source: 'query'} }, { arg: 'shippedFrom', - type: 'Date', + type: 'date', description: 'The shipped from date filter', http: {source: 'query'} }, { arg: 'shippedTo', - type: 'Date', + type: 'date', description: 'The shipped to date filter', http: {source: 'query'} }, { arg: 'landedFrom', - type: 'Date', + type: 'date', description: 'The landed from date filter', http: {source: 'query'} }, { arg: 'landedTo', - type: 'Date', + type: 'date', description: 'The landed to date filter', http: {source: 'query'} }, { arg: 'agencyFk', - type: 'Number', + type: 'number', description: 'The agencyModeFk id', http: {source: 'query'} }, { arg: 'warehouseOutFk', - type: 'Number', + type: 'number', description: 'The warehouseOutFk filter', http: {source: 'query'} }, { arg: 'warehouseInFk', - type: 'Number', + type: 'number', description: 'The warehouseInFk filter', http: {source: 'query'} }, { arg: 'totalEntries', - type: 'Number', + type: 'number', description: 'The totalEntries filter', http: {source: 'query'} }, { arg: 'ref', type: 'string', description: 'The reference' - } + }, { + arg: 'continent', + type: 'string', + description: 'The continent code' + }, ], returns: { type: ['Object'], @@ -102,6 +106,7 @@ module.exports = Self => { case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': + case 'continent': param = `t.${param}`; return {[param]: value}; } @@ -129,11 +134,15 @@ module.exports = Self => { t.totalEntries, am.name agencyModeName, win.name warehouseInName, - wout.name warehouseOutName + wout.name warehouseOutName, + cnt.code continent FROM vn.travel t JOIN vn.agencyMode am ON am.id = t.agencyFk JOIN vn.warehouse win ON win.id = t.warehouseInFk - JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk) AS t` + JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk + JOIN warehouse wo ON wo.id = t.warehouseOutFk + JOIN country c ON c.id = wo.countryFk + LEFT JOIN continent cnt ON cnt.id = c.continentFk) AS t` ); stmt.merge(conn.makeSuffix(filter)); diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index ababe961e..c739866a0 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -70,4 +70,16 @@ describe('Travel filter()', () => { expect(result.length).toEqual(1); }); + + it('should return the travel matching "continent"', async() => { + const ctx = { + args: { + continent: 'EU', + } + }; + + const result = await app.models.Travel.filter(ctx); + + expect(result.length).toEqual(5); + }); }); diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html index 8e7f4140d..8d4edec1a 100644 --- a/modules/travel/front/search-panel/index.html +++ b/modules/travel/front/search-panel/index.html @@ -93,6 +93,15 @@ value-field="id"> + + + + From 65c32c9ed324da95ccad09da481c84d99b893205 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 26 Jan 2022 11:40:44 +0100 Subject: [PATCH 2/2] fix(travel_summary): vn-check change value to ng-model --- modules/travel/front/summary/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html index 90a2ea27f..e74682fb9 100644 --- a/modules/travel/front/summary/index.html +++ b/modules/travel/front/summary/index.html @@ -22,7 +22,7 @@ @@ -37,7 +37,7 @@