diff --git a/client/claim/routes.json b/client/claim/routes.json index 153d192bc..3d0af1acf 100644 --- a/client/claim/routes.json +++ b/client/claim/routes.json @@ -32,6 +32,18 @@ "params": { "claim": "$ctrl.claim" } + }, + { + "url": "/detail", + "state": "claim.card.detail", + "component": "vn-claim-detail", + "description": "Detail", + "params": { + "claim": "$ctrl.claim" + }, + "menu": { + "icon": "settings" + } } ] } \ No newline at end of file diff --git a/client/claim/src/card/index.html b/client/claim/src/card/index.html new file mode 100644 index 000000000..9772b2b72 --- /dev/null +++ b/client/claim/src/card/index.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/client/claim/src/card/index.js b/client/claim/src/card/index.js new file mode 100644 index 000000000..f77834148 --- /dev/null +++ b/client/claim/src/card/index.js @@ -0,0 +1,49 @@ +import ngModule from '../module'; + +class Controller { + constructor($http, $state) { + this.$http = $http; + this.$state = $state; + this.order = {}; + this.filter = { + include: [ + {relation: 'claimResponsible', scope: {fields: ['description', 'responsability']}}, + {relation: 'worker', scope: {fields: ['name', 'firstName']}}, + {relation: 'claimState', scope: {fields: ['id', 'description']}}, + { + relation: 'client', + scope: { + fields: ['salesPersonFk', 'name'], + include: { + relation: 'salesPerson', + fields: ['firstName', 'name'] + } + } + } + ] + }; + } + + getClaim() { + let json = encodeURIComponent(JSON.stringify(this.filter)); + let query = `/claim/api/Claims/${this.$state.params.id}?filter=${json}`; + this.$http.get(query).then(res => { + if (res.data) { + this.claim = res.data; + } + }); + } + $onInit() { + this.getClaim(); + } + reload() { + this.getClaim(); + } +} + +Controller.$inject = ['$http', '$state']; + +ngModule.component('vnClaimCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/client/claim/src/card/index.spec.js b/client/claim/src/card/index.spec.js new file mode 100644 index 000000000..580711fe4 --- /dev/null +++ b/client/claim/src/card/index.spec.js @@ -0,0 +1,36 @@ +import './index.js'; + +describe('Claim', () => { + describe('Component vnClaimCard', () => { + let $componentController; + let $scope; + let controller; + let $httpBackend; + let $state; + + beforeEach(() => { + angular.mock.module('claim'); + }); + + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { + $componentController = _$componentController_; + $httpBackend = _$httpBackend_; + $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); + $scope = $rootScope.$new(); + $state = {params: {id: 1}}; + controller = $componentController('vnClaimCard', {$scope: $scope, $state: $state}); + })); + + describe('getClaim()', () => { + it(`should make a query and save the data in claim`, () => { + let json = encodeURIComponent(JSON.stringify(controller.filter)); + $httpBackend.expectGET(`/claim/api/Claims/${controller.$state.params.id}?filter=${json}`).respond({id: 1}); + controller.getClaim(); + $httpBackend.flush(); + + expect(controller.claim).toEqual({id: 1}); + }); + }); + }); +}); + diff --git a/client/claim/src/descriptor/index.html b/client/claim/src/descriptor/index.html new file mode 100644 index 000000000..4bf70e5fe --- /dev/null +++ b/client/claim/src/descriptor/index.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + +
{{$ctrl.claim.id}}
+ + + + + + + + + + + +
+
+ + + + + + + + + + +
diff --git a/client/claim/src/descriptor/index.js b/client/claim/src/descriptor/index.js new file mode 100644 index 000000000..844ca6b82 --- /dev/null +++ b/client/claim/src/descriptor/index.js @@ -0,0 +1,32 @@ +import ngModule from '../module'; + +class Controller { + constructor($state) { + this.$state = $state; + this._quicklinks = {}; + } + + set quicklinks(value = {}) { + this._quicklinks = Object.assign(value, this._quicklinks); + } + + get quicklinks() { + return this._quicklinks; + } + + quicklinkGo(state, params) { + this.$state.go(state, params); + } +} + +Controller.$inject = ['$state']; + +ngModule.component('vnClaimDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + claim: '<', + tags: '<', + quicklinks: '<' + } +}); diff --git a/client/claim/src/index.js b/client/claim/src/index.js index c7608c145..e3775c5d3 100644 --- a/client/claim/src/index.js +++ b/client/claim/src/index.js @@ -1,7 +1,6 @@ export * from './module'; import './index/'; -/* import './card'; import './descriptor'; -import './summary'; */ +// import './summary'; diff --git a/client/claim/src/index/index.html b/client/claim/src/index/index.html index 3fdc3169c..281c38b88 100644 --- a/client/claim/src/index/index.html +++ b/client/claim/src/index/index.html @@ -32,7 +32,7 @@ - + {{::claim.id}} {{::claim.client.id}} {{::claim.client.name}}