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: {},
|
||||
|
||||
insert: () => {
|
||||
return new Promise(accept => {
|
||||
accept();
|
||||
});
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: 1234}});
|
||||
}
|
||||
};
|
||||
},
|
||||
remove: () => {
|
||||
return new Promise(accept => {
|
||||
accept();
|
||||
});
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: 1234}});
|
||||
}
|
||||
};
|
||||
},
|
||||
save: () => {
|
||||
return new Promise(accept => {
|
||||
accept();
|
||||
});
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: 1234}});
|
||||
}
|
||||
};
|
||||
},
|
||||
refresh: () => {},
|
||||
addFilter: () => {},
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
url="/api/Claims/{{$ctrl.$stateParams.id}}/updateClaim"
|
||||
save="post">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submit()" compact>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
||||
<vn-card pad-large>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
|
|
|
@ -2,12 +2,23 @@ import ngModule from '../module';
|
|||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($stateParams) {
|
||||
this.$stateParams = $stateParams;
|
||||
constructor($scope, $state, aclService) {
|
||||
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', {
|
||||
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';
|
||||
|
||||
class Controller {
|
||||
constructor($state, $scope, $http, $translate, vnApp) {
|
||||
constructor($state, $scope, $http, $translate, vnApp, aclService) {
|
||||
this.$state = $state;
|
||||
this.$ = $scope;
|
||||
this.$scope = $scope;
|
||||
this.$http = $http;
|
||||
this.$translate = $translate;
|
||||
this.vnApp = vnApp;
|
||||
this.aclService = aclService;
|
||||
this.filter = {
|
||||
where: {claimFk: $state.params.id},
|
||||
include: [
|
||||
|
@ -37,7 +38,7 @@ class Controller {
|
|||
|
||||
openAddSalesDialog() {
|
||||
this.getClaimableFromTicket();
|
||||
this.$.addSales.show();
|
||||
this.$scope.addSales.show();
|
||||
}
|
||||
|
||||
getClaimableFromTicket() {
|
||||
|
@ -54,9 +55,12 @@ class Controller {
|
|||
let saleToAdd = {saleFk: sale.saleFk, claimFk: this.claim.id, quantity: sale.quantity};
|
||||
let query = `claim/api/ClaimBeginnings/`;
|
||||
this.$http.post(query, saleToAdd).then(() => {
|
||||
this.$.addSales.hide();
|
||||
this.$.model.refresh();
|
||||
this.$scope.addSales.hide();
|
||||
this.$scope.model.refresh();
|
||||
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}`;
|
||||
this.$http.delete(query).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.$.model.remove(index);
|
||||
this.$scope.model.remove(index);
|
||||
this.calculateTotals();
|
||||
});
|
||||
}
|
||||
|
@ -108,13 +112,13 @@ class Controller {
|
|||
tooltip: 'Item diary'
|
||||
}
|
||||
};
|
||||
this.$.descriptor.itemFk = itemFk;
|
||||
this.$.descriptor.parent = event.target;
|
||||
this.$.descriptor.show();
|
||||
this.$scope.descriptor.itemFk = itemFk;
|
||||
this.$scope.descriptor.parent = event.target;
|
||||
this.$scope.descriptor.show();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
||||
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp', 'aclService'];
|
||||
|
||||
ngModule.component('vnClaimDetail', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -5,20 +5,22 @@ describe('claim', () => {
|
|||
describe('Component vnClaimDetail', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $state;
|
||||
let aclService;
|
||||
|
||||
beforeEach(ngModule('claim'));
|
||||
|
||||
beforeEach(angular.mock.inject(($componentController, $state, _$httpBackend_) => {
|
||||
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$httpBackend.when('GET', 'claim/api/Claims/ClaimBeginnings').respond({});
|
||||
$state.params.id = 1;
|
||||
|
||||
controller = $componentController('vnClaimDetail', {$state});
|
||||
$state = _$state_;
|
||||
aclService = {hasAny: () => true};
|
||||
controller = $componentController('vnClaimDetail', {$state, aclService});
|
||||
controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}];
|
||||
controller.salesClaimed = [{id: 1, sale: {}}];
|
||||
controller.claim = {ticketFk: 1};
|
||||
controller.$.model = crudModel;
|
||||
controller.$.addSales = {
|
||||
controller.$scope.model = crudModel;
|
||||
controller.$scope.addSales = {
|
||||
hide: () => {},
|
||||
show: () => {}
|
||||
};
|
||||
|
@ -28,11 +30,11 @@ describe('claim', () => {
|
|||
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
||||
controller.$ = {addSales: {show: () => {}}};
|
||||
spyOn(controller, 'getClaimableFromTicket');
|
||||
spyOn(controller.$.addSales, 'show');
|
||||
spyOn(controller.$scope.addSales, 'show');
|
||||
controller.openAddSalesDialog();
|
||||
|
||||
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
||||
expect(controller.$.addSales.show).toHaveBeenCalledWith();
|
||||
expect(controller.$scope.addSales.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -48,23 +50,25 @@ describe('claim', () => {
|
|||
|
||||
describe('addClaimedSale(index)', () => {
|
||||
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({});
|
||||
controller.addClaimedSale(1);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$.addSales.hide).toHaveBeenCalledWith();
|
||||
expect(controller.$scope.addSales.hide).toHaveBeenCalledWith();
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.development');
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteClaimedSale(index)', () => {
|
||||
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({});
|
||||
controller.deleteClaimedSale(0);
|
||||
$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';
|
||||
|
||||
class Controller {
|
||||
constructor($state, $scope) {
|
||||
constructor($state, $scope, aclService) {
|
||||
this.$state = $state;
|
||||
this.$ = $scope;
|
||||
this.$scope = $scope;
|
||||
this.aclService = aclService;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
this.$.model.save().then(() => {
|
||||
this.$.watcher.notifySaved();
|
||||
this.$.model.refresh();
|
||||
this.$scope.watcher.check();
|
||||
this.$scope.model.save().then(() => {
|
||||
this.$scope.watcher.notifySaved();
|
||||
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', {
|
||||
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