#655 [FALTA PLANIFICACION] claim.action añadir acciones Front Part

This commit is contained in:
Carlos Jimenez 2018-09-25 14:37:35 +02:00
parent d40597deef
commit e1131c2c93
4 changed files with 34 additions and 5 deletions

View File

@ -15,6 +15,16 @@
</vn-label-value>
</div>
</vn-horizontal>
<vn-horizontal>
<vn-tool-bar margin-medium-bottom>
<vn-button
vn-acl="salesAssistant"
label="Import sales"
ng-click="$ctrl.importToNewRefundTicket()"
vn-tooltip="Imports sales details">
</vn-button>
</vn-tool-bar>
</vn-horizontal>
<vn-table model="model">
<vn-thead>
<vn-tr>

View File

@ -59,6 +59,14 @@ class Controller {
});
}
importToNewRefundTicket() {
let query = `claim/api/ClaimBeginnings/${this.$state.params.id}/importToNewRefundTicket`;
this.$http.post(query).then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
focusLastInput() {
let inputs = document.querySelectorAll("#claimDestinationFk");
inputs[inputs.length - 1].querySelector("input").focus();

View File

@ -1,7 +1,7 @@
import './index.js';
describe('claim', () => {
describe('Component vnClaimDetail', () => {
describe('Component vnClaimAction', () => {
let $componentController;
let controller;
let $httpBackend;
@ -11,11 +11,10 @@ describe('claim', () => {
angular.mock.module('claim');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_, $rootScope) => {
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$httpBackend.when('GET', 'claim/api/Claims/ClaimBeginnings').respond({});
$state = _$state_;
$state.params.id = 1;
@ -104,5 +103,18 @@ describe('claim', () => {
expect(controller.claimedTotal).toEqual(50);
});
});
describe('importToNewRefundTicket()', () => {
it('should perform a post query', () => {
spyOn(controller.$.model, 'refresh');
spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expect('POST', `claim/api/ClaimBeginnings/1/importToNewRefundTicket`).respond({});
controller.importToNewRefundTicket();
$httpBackend.flush();
expect(controller.$.model.refresh).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
});
});
});
});

View File

@ -12,5 +12,4 @@ vn-claim-action {
}
}
}
}
}