navigate to next claim section for salesAssistant #1119
gitea/salix/dev This commit has test failures
Details
gitea/salix/dev This commit has test failures
Details
This commit is contained in:
parent
633ab28c41
commit
d0dc192fc4
|
@ -4,19 +4,25 @@ module.exports = {
|
||||||
order: {},
|
order: {},
|
||||||
|
|
||||||
insert: () => {
|
insert: () => {
|
||||||
return new Promise(accept => {
|
return {
|
||||||
accept();
|
then: callback => {
|
||||||
});
|
callback({data: {id: 1234}});
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
remove: () => {
|
remove: () => {
|
||||||
return new Promise(accept => {
|
return {
|
||||||
accept();
|
then: callback => {
|
||||||
});
|
callback({data: {id: 1234}});
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
save: () => {
|
save: () => {
|
||||||
return new Promise(accept => {
|
return {
|
||||||
accept();
|
then: callback => {
|
||||||
});
|
callback({data: {id: 1234}});
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
refresh: () => {},
|
refresh: () => {},
|
||||||
addFilter: () => {},
|
addFilter: () => {},
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
url="/api/Claims/{{$ctrl.$stateParams.id}}/updateClaim"
|
url="/api/Claims/{{$ctrl.$stateParams.id}}/updateClaim"
|
||||||
save="post">
|
save="post">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
<form name="form" ng-submit="watcher.submit()" compact>
|
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
|
|
@ -2,12 +2,23 @@ import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($stateParams) {
|
constructor($scope, $state, aclService) {
|
||||||
this.$stateParams = $stateParams;
|
this.$scope = $scope;
|
||||||
|
this.$state = $state;
|
||||||
|
this.$stateParams = $state.params;
|
||||||
|
this.aclService = aclService;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
if (this.aclService.hasAny(['salesAssistant'])) {
|
||||||
|
this.$scope.watcher.submit().then(() => {
|
||||||
|
this.$state.go('claim.card.detail');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$stateParams'];
|
Controller.$inject = ['$scope', '$state', 'aclService'];
|
||||||
|
|
||||||
ngModule.component('vnClaimBasicData', {
|
ngModule.component('vnClaimBasicData', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
import './index.js';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
|
||||||
|
describe('Claim', () => {
|
||||||
|
describe('Component vnClaimBasicData', () => {
|
||||||
|
let controller;
|
||||||
|
let $scope;
|
||||||
|
|
||||||
|
beforeEach(ngModule('claim'));
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.watcher = watcher;
|
||||||
|
let aclService = {hasAny: () => true};
|
||||||
|
controller = $componentController('vnClaimBasicData', {$scope, aclService});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it(`should redirect to 'claim.card.detail' state`, () => {
|
||||||
|
spyOn(controller.$state, 'go');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.detail');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -2,12 +2,13 @@ import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($state, $scope, $http, $translate, vnApp) {
|
constructor($state, $scope, $http, $translate, vnApp, aclService) {
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.$ = $scope;
|
this.$scope = $scope;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.$translate = $translate;
|
this.$translate = $translate;
|
||||||
this.vnApp = vnApp;
|
this.vnApp = vnApp;
|
||||||
|
this.aclService = aclService;
|
||||||
this.filter = {
|
this.filter = {
|
||||||
where: {claimFk: $state.params.id},
|
where: {claimFk: $state.params.id},
|
||||||
include: [
|
include: [
|
||||||
|
@ -37,7 +38,7 @@ class Controller {
|
||||||
|
|
||||||
openAddSalesDialog() {
|
openAddSalesDialog() {
|
||||||
this.getClaimableFromTicket();
|
this.getClaimableFromTicket();
|
||||||
this.$.addSales.show();
|
this.$scope.addSales.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
getClaimableFromTicket() {
|
getClaimableFromTicket() {
|
||||||
|
@ -54,9 +55,12 @@ class Controller {
|
||||||
let saleToAdd = {saleFk: sale.saleFk, claimFk: this.claim.id, quantity: sale.quantity};
|
let saleToAdd = {saleFk: sale.saleFk, claimFk: this.claim.id, quantity: sale.quantity};
|
||||||
let query = `claim/api/ClaimBeginnings/`;
|
let query = `claim/api/ClaimBeginnings/`;
|
||||||
this.$http.post(query, saleToAdd).then(() => {
|
this.$http.post(query, saleToAdd).then(() => {
|
||||||
this.$.addSales.hide();
|
this.$scope.addSales.hide();
|
||||||
this.$.model.refresh();
|
this.$scope.model.refresh();
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
|
||||||
|
if (this.aclService.hasAny(['salesAssistant']))
|
||||||
|
this.$state.go('claim.card.development');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +69,7 @@ class Controller {
|
||||||
let query = `claim/api/ClaimBeginnings/${sale.id}`;
|
let query = `claim/api/ClaimBeginnings/${sale.id}`;
|
||||||
this.$http.delete(query).then(() => {
|
this.$http.delete(query).then(() => {
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
this.$.model.remove(index);
|
this.$scope.model.remove(index);
|
||||||
this.calculateTotals();
|
this.calculateTotals();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -108,13 +112,13 @@ class Controller {
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.descriptor.itemFk = itemFk;
|
this.$scope.descriptor.itemFk = itemFk;
|
||||||
this.$.descriptor.parent = event.target;
|
this.$scope.descriptor.parent = event.target;
|
||||||
this.$.descriptor.show();
|
this.$scope.descriptor.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp', 'aclService'];
|
||||||
|
|
||||||
ngModule.component('vnClaimDetail', {
|
ngModule.component('vnClaimDetail', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -5,20 +5,22 @@ describe('claim', () => {
|
||||||
describe('Component vnClaimDetail', () => {
|
describe('Component vnClaimDetail', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
let $state;
|
||||||
|
let aclService;
|
||||||
|
|
||||||
beforeEach(ngModule('claim'));
|
beforeEach(ngModule('claim'));
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($componentController, $state, _$httpBackend_) => {
|
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpBackend.when('GET', 'claim/api/Claims/ClaimBeginnings').respond({});
|
$httpBackend.when('GET', 'claim/api/Claims/ClaimBeginnings').respond({});
|
||||||
$state.params.id = 1;
|
$state = _$state_;
|
||||||
|
aclService = {hasAny: () => true};
|
||||||
controller = $componentController('vnClaimDetail', {$state});
|
controller = $componentController('vnClaimDetail', {$state, aclService});
|
||||||
controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}];
|
controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}];
|
||||||
controller.salesClaimed = [{id: 1, sale: {}}];
|
controller.salesClaimed = [{id: 1, sale: {}}];
|
||||||
controller.claim = {ticketFk: 1};
|
controller.claim = {ticketFk: 1};
|
||||||
controller.$.model = crudModel;
|
controller.$scope.model = crudModel;
|
||||||
controller.$.addSales = {
|
controller.$scope.addSales = {
|
||||||
hide: () => {},
|
hide: () => {},
|
||||||
show: () => {}
|
show: () => {}
|
||||||
};
|
};
|
||||||
|
@ -28,11 +30,11 @@ describe('claim', () => {
|
||||||
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
||||||
controller.$ = {addSales: {show: () => {}}};
|
controller.$ = {addSales: {show: () => {}}};
|
||||||
spyOn(controller, 'getClaimableFromTicket');
|
spyOn(controller, 'getClaimableFromTicket');
|
||||||
spyOn(controller.$.addSales, 'show');
|
spyOn(controller.$scope.addSales, 'show');
|
||||||
controller.openAddSalesDialog();
|
controller.openAddSalesDialog();
|
||||||
|
|
||||||
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
||||||
expect(controller.$.addSales.show).toHaveBeenCalledWith();
|
expect(controller.$scope.addSales.show).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,23 +50,25 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('addClaimedSale(index)', () => {
|
describe('addClaimedSale(index)', () => {
|
||||||
it('should make a post and call refresh, hide and showSuccess', () => {
|
it('should make a post and call refresh, hide and showSuccess', () => {
|
||||||
spyOn(controller.$.addSales, 'hide');
|
spyOn(controller.$scope.addSales, 'hide');
|
||||||
|
spyOn(controller.$state, 'go');
|
||||||
$httpBackend.expectPOST(`claim/api/ClaimBeginnings/`).respond({});
|
$httpBackend.expectPOST(`claim/api/ClaimBeginnings/`).respond({});
|
||||||
controller.addClaimedSale(1);
|
controller.addClaimedSale(1);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.$.addSales.hide).toHaveBeenCalledWith();
|
expect(controller.$scope.addSales.hide).toHaveBeenCalledWith();
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.development');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteClaimedSale(index)', () => {
|
describe('deleteClaimedSale(index)', () => {
|
||||||
it('should make a delete and call refresh and showSuccess', () => {
|
it('should make a delete and call refresh and showSuccess', () => {
|
||||||
spyOn(controller.$.model, 'remove');
|
spyOn(controller.$scope.model, 'remove');
|
||||||
$httpBackend.expectDELETE(`claim/api/ClaimBeginnings/1`).respond({});
|
$httpBackend.expectDELETE(`claim/api/ClaimBeginnings/1`).respond({});
|
||||||
controller.deleteClaimedSale(0);
|
controller.deleteClaimedSale(0);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.$.model.remove).toHaveBeenCalledWith(0);
|
expect(controller.$scope.model.remove).toHaveBeenCalledWith(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,25 @@ import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($state, $scope) {
|
constructor($state, $scope, aclService) {
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.$ = $scope;
|
this.$scope = $scope;
|
||||||
|
this.aclService = aclService;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.$.watcher.check();
|
this.$scope.watcher.check();
|
||||||
this.$.model.save().then(() => {
|
this.$scope.model.save().then(() => {
|
||||||
this.$.watcher.notifySaved();
|
this.$scope.watcher.notifySaved();
|
||||||
this.$.model.refresh();
|
this.$scope.watcher.updateOriginalData();
|
||||||
|
|
||||||
|
if (this.aclService.hasAny(['salesAssistant']))
|
||||||
|
this.$state.go('claim.card.action');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$state', '$scope'];
|
Controller.$inject = ['$state', '$scope', 'aclService'];
|
||||||
|
|
||||||
ngModule.component('vnClaimDevelopment', {
|
ngModule.component('vnClaimDevelopment', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
import './index.js';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
|
describe('Claim', () => {
|
||||||
|
describe('Component vnClaimDevelopment', () => {
|
||||||
|
let controller;
|
||||||
|
let $scope;
|
||||||
|
let aclService;
|
||||||
|
|
||||||
|
beforeEach(ngModule('claim'));
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.watcher = watcher;
|
||||||
|
$scope.model = crudModel;
|
||||||
|
aclService = {hasAny: () => true};
|
||||||
|
controller = $componentController('vnClaimDevelopment', {$scope, aclService});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it(`should redirect to 'claim.card.action' state`, () => {
|
||||||
|
spyOn(controller.$state, 'go');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.action');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue