From 5bc6f5107e2d587f382bf3e2aa88efec63e5da05 Mon Sep 17 00:00:00 2001 From: Bernat Date: Mon, 29 Apr 2019 07:48:59 +0200 Subject: [PATCH] #1370 ticket.descriptor change shipped hour --- modules/ticket/front/descriptor/index.html | 2 +- modules/ticket/front/descriptor/index.js | 4 ++-- modules/ticket/front/descriptor/index.spec.js | 17 +++++++++++++++++ modules/ticket/front/descriptor/locale/es.yml | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index 6e77365c1..6d3d74d7f 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -169,7 +169,7 @@
Change shipped hour
- + diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index 9578b7128..307c88833 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -45,14 +45,14 @@ class Controller { this.vnApp.showError(this.$translate.instant('This ticket can\'t be modified')); return; } - this.newShipped = new Date(this.ticket.shipped); + this.newShipped = this.ticket.shipped; this.$scope.changeShippedDialog.show(); } changeShipped(response) { if (response === 'ACCEPT') { let params = {shipped: this.newShipped}; - this.$http.patch(`/ticket/api/Tickets/${this.ticket.id}/`, params).then(() => { + this.$http.patch(`/ticket/api/Tickets/${this.ticket.id}`, params).then(() => { this.vnApp.showSuccess(this.$translate.instant('Shipped hour updated')); this.cardReload(); }); diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index c799b16ec..92939c246 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -10,6 +10,9 @@ describe('Ticket Component vnTicketDescriptor', () => { $httpBackend = _$httpBackend_; controller = $componentController('vnTicketDescriptor'); controller.ticket = {id: 2, invoiceOut: {id: 1}}; + controller.cardReload = ()=> { + return true; + }; })); describe('showAddTurnDialog()', () => { @@ -105,5 +108,19 @@ describe('Ticket Component vnTicketDescriptor', () => { expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Invoice sent for a regeneration, will be available in a few minutes'); }); }); + + describe('changeShipped(response)', () => { + it('should make a query and change the shipped hour if the response is ACCEPT', () => { + spyOn(controller.vnApp, 'showSuccess'); + spyOn(controller, 'cardReload'); + $httpBackend.when('PATCH', `/ticket/api/Tickets/2`,).respond(); + $httpBackend.expect('PATCH', `/ticket/api/Tickets/2`).respond(); + controller.changeShipped('ACCEPT'); + $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Shipped hour updated'); + expect(controller.cardReload).toHaveBeenCalledWith(); + }); + }); }); diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index 1b6baed2a..e12c95f64 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -21,4 +21,5 @@ You are going to invoice this ticket: Vas a facturar este ticket Are you sure you want to invoice this ticket?: ¿Seguro que quieres facturar este ticket? You are going to regenerate the invoice: Vas a regenerar la factura Are you sure you want to regenerate the invoice?: ¿Seguro que quieres regenerar la factura? -Invoice sent for a regeneration, will be available in a few minutes: La factura ha sido enviada para ser regenerada, estará disponible en unos minutos \ No newline at end of file +Invoice sent for a regeneration, will be available in a few minutes: La factura ha sido enviada para ser regenerada, estará disponible en unos minutos +Shipped hour updated: Hora de envio modificada \ No newline at end of file