Bug #1463 Las reclamaciones no se eliminan por completo
gitea/salix/dev This commit looks good Details

This commit is contained in:
Bernat 2019-06-14 09:29:23 +02:00
parent 0d3efd2549
commit 5203c33483
4 changed files with 53 additions and 3 deletions

View File

@ -74,4 +74,10 @@
on-response="$ctrl.sendPickupOrder(response)"
question="Send Pickup order"
message="Are you sure you want to send it?">
</vn-confirm>
<vn-confirm
vn-id="confirm-delete-claim"
on-response="$ctrl.deleteClaim(response)"
question="Delete claim"
message="Are you sure you want to delete it?">
</vn-confirm>

View File

@ -1,15 +1,17 @@
import ngModule from '../module';
class Controller {
constructor($scope, $state, $http, $translate, vnApp) {
constructor($scope, $state, $http, $translate, vnApp, aclService) {
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
this.$translate = $translate;
this.vnApp = vnApp;
this.aclService = aclService;
this.moreOptions = [
{callback: this.showPickupOrder, name: 'Show Pickup order'},
{callback: this.confirmPickupOrder, name: 'Send Pickup order'}
{callback: this.confirmPickupOrder, name: 'Send Pickup order'},
{callback: this.confirmDeleteClaim, name: 'Delete claim', acl: 'salesAssistant'}
];
}
@ -57,6 +59,9 @@ class Controller {
this.$scope.confirmPickupOrder.show();
}
confirmDeleteClaim() {
this.$scope.confirmDeleteClaim.show();
}
sendPickupOrder(response) {
if (response === 'ACCEPT') {
this.$http.post(`/api/email/claim-pickup-order`, {claimFk: this.claim.id}).then(
@ -64,9 +69,17 @@ class Controller {
);
}
}
deleteClaim(response) {
if (response === 'ACCEPT') {
this.$http.delete(`/claim/api/Claims/${this.claim.id}`).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Claim deleted!'));
this.$state.go('claim.index');
});
}
}
}
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp'];
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService'];
ngModule.component('vnClaimDescriptor', {
template: require('./index.html'),

View File

@ -48,5 +48,34 @@ describe('Item Component vnClaimDescriptor', () => {
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Notification sent!');
});
});
describe('confirmDeleteClaim()', () => {
it('should call confirmDeleteClaim.show()', () => {
controller.$scope.confirmDeleteClaim = {
show: jasmine.createSpy('show')
};
controller.claim = {id: 2};
controller.confirmDeleteClaim();
expect(controller.$scope.confirmDeleteClaim.show).toHaveBeenCalledWith();
});
});
describe('deleteClaime(response)', () => {
it('should perform a query and call showSuccess if the response is ACCEPT', () => {
let response = 'ACCEPT';
controller.claim = {id: 2};
spyOn(controller.vnApp, 'showSuccess');
spyOn(controller.$state, 'go');
$httpBackend.when('DELETE', `/claim/api/Claims/2`).respond(200);
$httpBackend.expect('DELETE', `/claim/api/Claims/2`);
controller.deleteClaim(response);
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Claim deleted!');
expect(controller.$state.go).toHaveBeenCalledWith('claim.index');
});
});
});

View File

@ -3,6 +3,7 @@ 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
Delete claim: Eliminar reclamación
Observation: Observación
Responsible: Responsable
Remove sale: Borrar linea
@ -11,4 +12,5 @@ Created: Creado
Send Pickup order: Enviar orden de recogida
Show Pickup order: Ver orden de recogida
Search claim by id or client name: Buscar reclamaciones por identificador o nombre de cliente
Claim deleted!: Reclamación eliminada!