From e2481366a24f66cefd663610cc9fef707876b812 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 29 Jul 2020 10:47:48 +0200 Subject: [PATCH] removed on response if just accept --- .../front/credit-insurance/index/index.html | 2 +- .../front/credit-insurance/index/index.js | 12 ++--- .../credit-insurance/index/index.spec.js | 2 +- modules/client/front/sms/index.html | 2 +- modules/client/front/sms/index.js | 32 ++++++------ modules/client/front/sms/index.spec.js | 2 +- modules/client/front/web-access/index.html | 2 +- modules/client/front/web-access/index.js | 32 ++++++------ modules/client/front/web-access/index.spec.js | 6 +-- modules/route/front/tickets/index.html | 4 +- modules/route/front/tickets/index.js | 39 +++++++-------- modules/route/front/tickets/index.spec.js | 8 +-- modules/ticket/front/sale/index.html | 4 +- modules/ticket/front/sms/index.html | 2 +- modules/ticket/front/sms/index.js | 32 ++++++------ modules/ticket/front/sms/index.spec.js | 6 +-- modules/worker/front/department/index.html | 4 +- modules/worker/front/department/index.js | 50 +++++++++---------- modules/worker/front/department/locale/es.yml | 3 +- modules/worker/front/time-control/index.html | 2 +- modules/worker/front/time-control/index.js | 3 +- modules/zone/back/models/zone-warehouse.json | 4 ++ modules/zone/front/warehouses/index.html | 2 +- modules/zone/front/warehouses/index.js | 4 +- modules/zone/front/warehouses/index.spec.js | 2 +- 25 files changed, 121 insertions(+), 140 deletions(-) diff --git a/modules/client/front/credit-insurance/index/index.html b/modules/client/front/credit-insurance/index/index.html index d2bf1fef6..b3ebb070d 100644 --- a/modules/client/front/credit-insurance/index/index.html +++ b/modules/client/front/credit-insurance/index/index.html @@ -60,7 +60,7 @@ \ No newline at end of file diff --git a/modules/client/front/credit-insurance/index/index.js b/modules/client/front/credit-insurance/index/index.js index f215fc2a9..5f59c918a 100644 --- a/modules/client/front/credit-insurance/index/index.js +++ b/modules/client/front/credit-insurance/index/index.js @@ -51,13 +51,11 @@ class Controller extends Section { this.$.closeContract.show(); } - returnDialog(response) { - if (response === 'accept') { - let params = {finished: Date.now()}; - this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => { - this._getClassifications(this.client.id); - }); - } + returnDialog() { + let params = {finished: Date.now()}; + this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => { + this._getClassifications(this.client.id); + }); } } diff --git a/modules/client/front/credit-insurance/index/index.spec.js b/modules/client/front/credit-insurance/index/index.spec.js index 8546297fc..678301f28 100644 --- a/modules/client/front/credit-insurance/index/index.spec.js +++ b/modules/client/front/credit-insurance/index/index.spec.js @@ -78,7 +78,7 @@ describe('Client', () => { jest.spyOn(controller, '_getClassifications').mockReturnThis(); controller.classificationId = 1; $httpBackend.expect('PATCH', `CreditClassifications/1`).respond(200); - controller.returnDialog('accept'); + controller.returnDialog(); $httpBackend.flush(); expect(controller._getClassifications).toHaveBeenCalledWith(101); diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index fb2f1dfff..6915942c2 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -1,6 +1,6 @@ + on-accept="$ctrl.onResponse()">
Send SMS
diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js index 8ca9ab56a..701ee39af 100644 --- a/modules/client/front/sms/index.js +++ b/modules/client/front/sms/index.js @@ -16,25 +16,23 @@ class Controller extends Section { return maxLength - textAreaLength; } - onResponse(response) { - if (response === 'accept') { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); + onResponse() { + try { + if (!this.sms.destination) + throw new Error(`The destination can't be empty`); + if (!this.sms.message) + throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); - this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent!')); + this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { + this.vnApp.showMessage(this.$t('SMS sent!')); - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } + if (res.data) this.emit('send', {response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; } return true; } diff --git a/modules/client/front/sms/index.spec.js b/modules/client/front/sms/index.spec.js index 1aad21c06..3462bf681 100644 --- a/modules/client/front/sms/index.spec.js +++ b/modules/client/front/sms/index.spec.js @@ -30,7 +30,7 @@ describe('Client', () => { jest.spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('POST', `Clients/101/sendSms`, params).respond(200, params); - controller.onResponse('accept'); + controller.onResponse(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); diff --git a/modules/client/front/web-access/index.html b/modules/client/front/web-access/index.html index 590e823d3..f7488dbdf 100644 --- a/modules/client/front/web-access/index.html +++ b/modules/client/front/web-access/index.html @@ -34,7 +34,7 @@ + on-accept="$ctrl.onPassChange()"> { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); + this.$http.patch(`Accounts/${this.client.id}`, account).then(res => { + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); - return false; - } + return false; } return true; diff --git a/modules/client/front/web-access/index.spec.js b/modules/client/front/web-access/index.spec.js index b1118eeba..73c4f1043 100644 --- a/modules/client/front/web-access/index.spec.js +++ b/modules/client/front/web-access/index.spec.js @@ -83,7 +83,7 @@ describe('Component VnClientWebAccess', () => { controller.repeatPassword = 'm24x8'; controller.canChangePassword = true; $httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'}).respond('done'); - controller.onPassChange('accept'); + controller.onPassChange(); $httpBackend.flush(); }); @@ -92,7 +92,7 @@ describe('Component VnClientWebAccess', () => { controller.client = {id: '1234'}; controller.newPassword = ''; controller.canChangePassword = true; - controller.onPassChange('accept'); + controller.onPassChange(); expect(vnApp.showError).toHaveBeenCalledWith(`You must enter a new password`); }); @@ -104,7 +104,7 @@ describe('Component VnClientWebAccess', () => { controller.newPassword = 'm24x8'; controller.canChangePassword = true; controller.repeatPassword = 'notMatchingPassword'; - controller.onPassChange('accept'); + controller.onPassChange(); expect(vnApp.showError).toHaveBeenCalledWith(`Passwords don't match`); }); diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index fee60dcca..9e48d50ed 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -108,7 +108,7 @@ + on-accept="$ctrl.removeTicketFromRoute()"> diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js index dd1a5985d..a811d6d88 100644 --- a/modules/route/front/tickets/index.js +++ b/modules/route/front/tickets/index.js @@ -101,15 +101,13 @@ class Controller extends Section { this.$.confirm.show(); } - removeTicketFromRoute(response) { - if (response === 'accept') { - let params = {routeFk: null}; - let query = `Tickets/${this.selectedTicket}/`; - this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Ticket removed from route')); - this.updateVolume(); - }); - } + removeTicketFromRoute() { + let params = {routeFk: null}; + let query = `Tickets/${this.selectedTicket}/`; + this.$http.patch(query, params).then(() => { + this.vnApp.showSuccess(this.$t('Ticket removed from route')); + this.updateVolume(); + }); } updateVolume() { @@ -133,20 +131,17 @@ class Controller extends Section { this.$.possibleTicketsDialog.show(); } - setTicketsRoute(response) { - if (response === 'accept') { - let tickets = this.getSelectedItems(this.possibleTickets); - - for (let i = 0; i < tickets.length; i++) { - delete tickets[i].checked; - tickets[i].routeFk = this.route.id; - } - - return this.$.possibleTicketsModel.save().then(() => { - this.$.model.data = this.$.model.data.concat(tickets); - }); + setTicketsRoute() { + let tickets = this.getSelectedItems(this.possibleTickets); + if (tickets.length === 0) return; + for (let i = 0; i < tickets.length; i++) { + delete tickets[i].checked; + tickets[i].routeFk = this.route.id; } - return Promise.resolve(); + + return this.$.possibleTicketsModel.save().then(() => { + this.$.model.data = this.$.model.data.concat(tickets); + }); } onDrop($event) { diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js index 2f4ad6cfd..a32b368ba 100644 --- a/modules/route/front/tickets/index.spec.js +++ b/modules/route/front/tickets/index.spec.js @@ -170,7 +170,7 @@ describe('Route', () => { controller.selectedTicket = ticketId; $httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok'); - controller.removeTicketFromRoute('accept'); + controller.removeTicketFromRoute(); $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket removed from route'); @@ -250,15 +250,11 @@ describe('Route', () => { {id: 5, routeFk: 111} ]; - controller.setTicketsRoute('accept').then(() => { + controller.setTicketsRoute().then(() => { expect(controller.$.model.data).toEqual(expectedResult); done(); }).catch(done.fail); }); - - it('should just return a promise', () => { - expect(controller.setTicketsRoute('cancel')).toEqual(jasmine.any(Promise)); - }); }); describe('onDrop()', () => { diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 4b96b6326..7cae5529f 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -384,14 +384,14 @@ vn-id="delete-lines" question="You are going to delete lines of the ticket" message="Continue anyway?" - on-response="$ctrl.removeSales()"> + on-accept="$ctrl.removeSales()"> + on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)"> diff --git a/modules/ticket/front/sms/index.html b/modules/ticket/front/sms/index.html index eeb98cbcb..97bdfef14 100644 --- a/modules/ticket/front/sms/index.html +++ b/modules/ticket/front/sms/index.html @@ -1,6 +1,6 @@
diff --git a/modules/ticket/front/sms/index.js b/modules/ticket/front/sms/index.js index 8a39be6c4..33369acae 100644 --- a/modules/ticket/front/sms/index.js +++ b/modules/ticket/front/sms/index.js @@ -16,25 +16,23 @@ class Controller extends Component { return maxLength - textAreaLength; } - onResponse(response) { - if (response === 'accept') { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); + onResponse() { + try { + if (!this.sms.destination) + throw new Error(`The destination can't be empty`); + if (!this.sms.message) + throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); - this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent!')); + this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { + this.vnApp.showMessage(this.$t('SMS sent!')); - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } + if (res.data) this.emit('send', {response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; } return true; } diff --git a/modules/ticket/front/sms/index.spec.js b/modules/ticket/front/sms/index.spec.js index a6ac286ec..e918ffb54 100644 --- a/modules/ticket/front/sms/index.spec.js +++ b/modules/ticket/front/sms/index.spec.js @@ -28,7 +28,7 @@ describe('Ticket', () => { jest.spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params); - controller.onResponse('accept'); + controller.onResponse(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); @@ -39,7 +39,7 @@ describe('Ticket', () => { jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse('accept'); + controller.onResponse(); expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); }); @@ -49,7 +49,7 @@ describe('Ticket', () => { jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse('accept'); + controller.onResponse(); expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); }); diff --git a/modules/worker/front/department/index.html b/modules/worker/front/department/index.html index 92102c7d3..df8630104 100644 --- a/modules/worker/front/department/index.html +++ b/modules/worker/front/department/index.html @@ -19,7 +19,7 @@ @@ -27,7 +27,7 @@ { - const item = res.data; - item.parent = parent; + const query = `departments/createChild`; + this.$http.post(query, params).then(res => { + const item = res.data; + item.parent = parent; - this.$.treeview.create(item); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } + this.$.treeview.create(item); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; } return true; } @@ -70,14 +68,12 @@ class Controller extends Section { this.$.deleteNode.show(); } - onRemoveResponse(response) { - if (response === 'accept') { - const childId = this.removedChild.id; - const path = `departments/${childId}/removeChild`; - this.$http.post(path).then(() => { - this.$.treeview.remove(this.removedChild); - }); - } + onRemoveResponse() { + const childId = this.removedChild.id; + const path = `departments/${childId}/removeChild`; + this.$http.post(path).then(() => { + this.$.treeview.remove(this.removedChild); + }); } } diff --git a/modules/worker/front/department/locale/es.yml b/modules/worker/front/department/locale/es.yml index c481bf4a9..74dec0c45 100644 --- a/modules/worker/front/department/locale/es.yml +++ b/modules/worker/front/department/locale/es.yml @@ -1,3 +1,4 @@ New department: Nuevo departamento Delete department: Eliminar departamento -Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo? \ No newline at end of file +Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo? +Name can't be empty: El nombre esta vacio \ No newline at end of file diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index d2c91bf94..a333b8585 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -92,7 +92,7 @@ + on-accept="$ctrl.onSave()"> { this.selected = null; diff --git a/modules/zone/front/warehouses/index.spec.js b/modules/zone/front/warehouses/index.spec.js index b191f885b..0e71d541c 100644 --- a/modules/zone/front/warehouses/index.spec.js +++ b/modules/zone/front/warehouses/index.spec.js @@ -36,7 +36,7 @@ describe('Zone warehouses', () => { jest.spyOn(controller, 'refresh').mockReturnThis(); $httpBackend.expect('POST', `Zones/1/warehouses`).respond(200); - controller.onSave('accept'); + controller.onSave(); $httpBackend.flush(); expect(controller.selected).toBeNull();