This commit is contained in:
Juan Ferrer 2019-02-12 09:24:30 +01:00
commit 8aa0497524
4 changed files with 71 additions and 14 deletions

View File

@ -70,8 +70,8 @@
</div>
</div>
<vn-confirm
vn-id="confirm-dialog"
on-response="$ctrl.returnDialog(response)"
question="Pickup order"
message="Do you want to send it directly?">
vn-id="confirm-pickup-order"
on-response="$ctrl.sendPickupOrder(response)"
question="Send Pickup order"
message="Are you sure you want to send it?">
</vn-confirm>

View File

@ -8,7 +8,8 @@ class Controller {
this.$translate = $translate;
this.vnApp = vnApp;
this.moreOptions = [
{callback: this.showConfirmDialog, name: 'Pickup order'}
{callback: this.showPickupOrder, name: 'Show Pickup order'},
{callback: this.confirmPickupOrder, name: 'Send Pickup order'}
];
}
@ -47,15 +48,17 @@ class Controller {
callback.call(this);
}
showConfirmDialog() {
this.$scope.confirmDialog.show();
showPickupOrder() {
let url = `/api/report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
window.open(url);
}
returnDialog(response) {
if (response === 'CANCEL') {
let url = `/api/report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
window.open(url);
} else if (response === 'ACCEPT') {
confirmPickupOrder() {
this.$scope.confirmPickupOrder.show();
}
sendPickupOrder(response) {
if (response === 'ACCEPT') {
this.$http.post(`/api/email/claim-pickup-order`, {claimFk: this.claim.id}).then(
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
);

View File

@ -0,0 +1,52 @@
import './index.js';
describe('Item Component vnClaimDescriptor', () => {
let $httpBackend;
let controller;
beforeEach(() => {
ngModule('claim');
});
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnClaimDescriptor');
controller.claim = {id: 2};
}));
describe('showPickupOrder()', () => {
it('should open a new window showing a pickup order PDF document', () => {
let expectedPath = '/api/report/rpt-claim-pickup-order?claimFk=2';
spyOn(window, 'open');
controller.showPickupOrder();
expect(window.open).toHaveBeenCalledWith(expectedPath);
});
});
describe('confirmPickupOrder()', () => {
it('should call confirmPickupOrder.show()', () => {
controller.$scope.confirmPickupOrder = {
show: jasmine.createSpy('show')
};
controller.claim = {id: 2};
controller.confirmPickupOrder();
expect(controller.$scope.confirmPickupOrder.show).toHaveBeenCalledWith();
});
});
describe('sendPickupOrder(response)', () => {
it('should make a query and call vnApp.showMessage() if the response is ACCEPT', () => {
spyOn(controller.vnApp, 'showMessage');
$httpBackend.when('POST', `/api/email/claim-pickup-order`, {claimFk: 2}).respond();
$httpBackend.expect('POST', `/api/email/claim-pickup-order`, {claimFk: 2}).respond();
controller.sendPickupOrder('ACCEPT');
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Notification sent!');
});
});
});

View File

@ -1,5 +1,6 @@
#Ordenar alfabeticamente
Add sale: Añadir linea
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
Client Id: Id cliente
Claimed ticket: Ticket reclamado
Observation: Observación
@ -7,5 +8,6 @@ Responsible: Responsable
Remove sale: Borrar linea
Claim Id: Id reclamación
Created: Creado
Pickup order: Orden de recogida
Do you want to send it directly?: ¿Quieres enviarlo directamente?
Send Pickup order: Enviar orden de recogida
Show Pickup order: Ver orden de recogida