From 445a0b0e1fa7feec96d9de1fc8b1015a19592422 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 7 Mar 2023 10:20:10 +0100 Subject: [PATCH 1/3] Claim fixes --- modules/claim/back/models/claim-beginning.js | 26 ++++++++++---------- modules/claim/front/detail/index.js | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/claim/back/models/claim-beginning.js b/modules/claim/back/models/claim-beginning.js index 4283e37e2..ba70c0bbc 100644 --- a/modules/claim/back/models/claim-beginning.js +++ b/modules/claim/back/models/claim-beginning.js @@ -29,21 +29,21 @@ module.exports = Self => { myOptions.transaction = ctx.options.transaction; const claimBeginning = await Self.findById(ctx.where.id); - + const filter = { - where: {id: claimBeginning.claimFk}, - include: [ - { - relation: 'claimState', - scope: { - fields: ['id', 'code', 'description'] - } - } - ] - }; - + where: {id: claimBeginning.claimFk}, + include: [ + { + relation: 'claimState', + scope: { + fields: ['id', 'code', 'description'] + } + } + ] + }; + const [claim] = await models.Claim.find(filter, myOptions); - const isEditable = await models.ClaimState.isEditable(httpCtx, claim.ClaimState()); + const isEditable = await models.ClaimState.isEditable(httpCtx, claim.claimState().id); if (!isEditable) throw new UserError(`The current claim can't be modified`); diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index 33ce1a581..833519579 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -100,8 +100,8 @@ class Controller extends Section { } setClaimedQuantity(id, claimedQuantity) { - let params = {id: id, quantity: claimedQuantity}; - let query = `ClaimBeginnings/`; + let params = {quantity: claimedQuantity}; + let query = `ClaimBeginnings/${id}`; this.$http.patch(query, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); this.calculateTotals(); From 3ad96b6ad73dad7697cdbe50fe6db62411a08c42 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 7 Mar 2023 11:55:13 +0100 Subject: [PATCH 2/3] Endpoint fixes --- modules/worker/back/methods/worker/filter.js | 44 +++++++++++--------- modules/worker/front/search-panel/index.html | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js index d08b27a18..71a8da96f 100644 --- a/modules/worker/back/methods/worker/filter.js +++ b/modules/worker/back/methods/worker/filter.js @@ -13,55 +13,59 @@ module.exports = Self => { type: 'Object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} - }, { - arg: 'tags', - type: ['Object'], - description: 'List of tags to filter with', - http: {source: 'query'} - }, { + }, + { arg: 'search', type: 'String', description: `If it's and integer searchs by id, otherwise it searchs by name`, http: {source: 'query'} - }, { + }, + { arg: 'id', type: 'Integer', description: 'The worker id', http: {source: 'query'} - }, { + }, + { arg: 'userFk', type: 'Integer', description: 'The user id', http: {source: 'query'} - }, { + }, + { arg: 'fi', type: 'String', description: 'The worker fi', http: {source: 'query'} - }, { + }, + { arg: 'departmentFk', type: 'Integer', description: 'The worker department id', http: {source: 'query'} - }, { + }, + { arg: 'extension', type: 'Integer', description: 'The worker extension id', http: {source: 'query'} - }, { + }, + { arg: 'firstName', type: 'String', description: 'The worker firstName', http: {source: 'query'} - }, { - arg: 'name', + }, + { + arg: 'lastName', type: 'String', - description: 'The worker name', + description: 'The worker lastName', http: {source: 'query'} - }, { - arg: 'nickname', + }, + { + arg: 'userName', type: 'String', - description: 'The worker nickname', + description: 'The worker user name', http: {source: 'query'} } ], @@ -93,10 +97,10 @@ module.exports = Self => { return {'w.id': value}; case 'userFk': return {'w.userFk': value}; - case 'name': - return {'w.lastName': {like: `%${value}%`}}; case 'firstName': return {'w.firstName': {like: `%${value}%`}}; + case 'lastName': + return {'w.lastName': {like: `%${value}%`}}; case 'extension': return {'p.extension': value}; case 'fi': diff --git a/modules/worker/front/search-panel/index.html b/modules/worker/front/search-panel/index.html index ca57722c8..2adb56587 100644 --- a/modules/worker/front/search-panel/index.html +++ b/modules/worker/front/search-panel/index.html @@ -30,7 +30,7 @@ + ng-model="filter.lastName"> From 9050c069943d5a9c2e101db992dbb447335b0d26 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 8 Mar 2023 07:44:56 +0100 Subject: [PATCH 3/3] Updated unit test --- modules/worker/back/methods/worker/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker/specs/filter.spec.js b/modules/worker/back/methods/worker/specs/filter.spec.js index c1bc05ae8..2eb353576 100644 --- a/modules/worker/back/methods/worker/specs/filter.spec.js +++ b/modules/worker/back/methods/worker/specs/filter.spec.js @@ -16,7 +16,7 @@ describe('worker filter()', () => { }); it('should return 2 results filtering by name', async() => { - let result = await app.models.Worker.filter({args: {filter: {}, name: 'agency'}}); + let result = await app.models.Worker.filter({args: {filter: {}, firstName: 'agency'}}); expect(result.length).toEqual(2); expect(result[0].nickname).toEqual('agencyNick');