Show/send claim pickup order #1106
This commit is contained in:
parent
18afce9b1b
commit
604f75c84b
|
@ -70,8 +70,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
vn-id="confirm-dialog"
|
vn-id="confirm-pickup-order"
|
||||||
on-response="$ctrl.returnDialog(response)"
|
on-response="$ctrl.sendPickupOrder(response)"
|
||||||
question="Pickup order"
|
question="Send Pickup order"
|
||||||
message="Do you want to send it directly?">
|
message="Are you sure you want to send it?">
|
||||||
</vn-confirm>
|
</vn-confirm>
|
|
@ -8,7 +8,8 @@ class Controller {
|
||||||
this.$translate = $translate;
|
this.$translate = $translate;
|
||||||
this.vnApp = vnApp;
|
this.vnApp = vnApp;
|
||||||
this.moreOptions = [
|
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);
|
callback.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
showConfirmDialog() {
|
showPickupOrder() {
|
||||||
this.$scope.confirmDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
returnDialog(response) {
|
|
||||||
if (response === 'CANCEL') {
|
|
||||||
let url = `/api/report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
|
let url = `/api/report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
|
||||||
window.open(url);
|
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.$http.post(`/api/email/claim-pickup-order`, {claimFk: this.claim.id}).then(
|
||||||
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
||||||
);
|
);
|
||||||
|
|
|
@ -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!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#Ordenar alfabeticamente
|
#Ordenar alfabeticamente
|
||||||
Add sale: Añadir linea
|
Add sale: Añadir linea
|
||||||
|
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
|
||||||
Client Id: Id cliente
|
Client Id: Id cliente
|
||||||
Claimed ticket: Ticket reclamado
|
Claimed ticket: Ticket reclamado
|
||||||
Observation: Observación
|
Observation: Observación
|
||||||
|
@ -7,5 +8,6 @@ Responsible: Responsable
|
||||||
Remove sale: Borrar linea
|
Remove sale: Borrar linea
|
||||||
Claim Id: Id reclamación
|
Claim Id: Id reclamación
|
||||||
Created: Creado
|
Created: Creado
|
||||||
Pickup order: Orden de recogida
|
Send Pickup order: Enviar orden de recogida
|
||||||
Do you want to send it directly?: ¿Quieres enviarlo directamente?
|
Show Pickup order: Ver orden de recogida
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue