Please, ensure you put the correct data!
diff --git a/modules/client/front/postcode/index.js b/modules/client/front/postcode/index.js index bbf0b1953..836ea9a81 100644 --- a/modules/client/front/postcode/index.js +++ b/modules/client/front/postcode/index.js @@ -35,25 +35,20 @@ class Controller extends Component { this.$.postcode.focus(); } - onResponse(response) { - if (response == 'accept') { - try { - if (!this.data.code) - throw new Error(`The postcode can't be empty`); - if (!this.data.townFk) - throw new Error(`The town can't be empty`); + onAccept() { + try { + if (!this.data.code) + throw new Error(`The postcode can't be empty`); + if (!this.data.townFk) + throw new Error(`The town can't be empty`); - this.$http.patch(`postcodes`, this.data).then(response => { - if (response.data) { - this.vnApp.showMessage(this.$translate.instant('The postcode has been saved')); - - this.emit('response', {response: response.data}); - } - }); - } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); - return false; - } + this.$http.patch(`postcodes`, this.data).then(res => { + this.vnApp.showMessage(this.$translate.instant('The postcode has been saved')); + this.emit('response', {$response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$translate.instant(e.message)); + return false; } return true; } diff --git a/modules/client/front/postcode/index.spec.js b/modules/client/front/postcode/index.spec.js index 04f1a8924..a5e5db9d5 100644 --- a/modules/client/front/postcode/index.spec.js +++ b/modules/client/front/postcode/index.spec.js @@ -15,7 +15,7 @@ describe('Client', () => { controller.client = {id: 101}; })); - describe('onResponse()', () => { + describe('onAccept()', () => { it('should perform a POST query and show a success snackbar', () => { let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; @@ -24,7 +24,7 @@ describe('Client', () => { $httpBackend.when('PATCH', `postcodes`, params).respond(200, params); $httpBackend.expect('PATCH', `postcodes`, params).respond(params); - controller.onResponse('accept'); + controller.onAccept(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been saved'); diff --git a/modules/travel/back/methods/travel/createThermograph.js b/modules/travel/back/methods/travel/createThermograph.js index d5388295a..974b67923 100644 --- a/modules/travel/back/methods/travel/createThermograph.js +++ b/modules/travel/back/methods/travel/createThermograph.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('createThermograph', { - description: 'Upload and attach a document', + description: 'Creates a new travel thermograph', accessType: 'WRITE', accepts: [{ arg: 'id', diff --git a/modules/travel/back/methods/travel/updateThermograph.js b/modules/travel/back/methods/travel/updateThermograph.js index efad606eb..d89725920 100644 --- a/modules/travel/back/methods/travel/updateThermograph.js +++ b/modules/travel/back/methods/travel/updateThermograph.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('updateThermograph', { - description: 'updates a file properties or file', + description: 'Updates a travel thermograph', accessType: 'WRITE', accepts: [{ arg: 'id',