From e92ae60792453c494b5cb03645ce989f68106a17 Mon Sep 17 00:00:00 2001 From: gerard Date: Fri, 24 Aug 2018 13:16:11 +0200 Subject: [PATCH 1/3] Bug #590 estructura basica de claim --- client/claim/src/card/index.html | 11 ++++++ client/claim/src/card/index.js | 49 +++++++++++++++++++++++++ client/claim/src/card/index.spec.js | 36 ++++++++++++++++++ client/claim/src/descriptor/index.html | 51 ++++++++++++++++++++++++++ client/claim/src/descriptor/index.js | 32 ++++++++++++++++ client/claim/src/index.js | 3 +- 6 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 client/claim/src/card/index.html create mode 100644 client/claim/src/card/index.js create mode 100644 client/claim/src/card/index.spec.js create mode 100644 client/claim/src/descriptor/index.html create mode 100644 client/claim/src/descriptor/index.js 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..a851e7e1e --- /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'; From 5c60ba1336938d08aaa2f24d05b716f5ba100fc8 Mon Sep 17 00:00:00 2001 From: gerard Date: Mon, 27 Aug 2018 11:41:25 +0200 Subject: [PATCH 2/3] Bug #590 estructura basica de claim --- client/claim/routes.json | 12 ++++++++++++ client/claim/src/descriptor/index.html | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) 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/descriptor/index.html b/client/claim/src/descriptor/index.html index a851e7e1e..ff371fe23 100644 --- a/client/claim/src/descriptor/index.html +++ b/client/claim/src/descriptor/index.html @@ -1,4 +1,4 @@ - + From 740cc9f62637a4e1476c8e2655439a85ad26e930 Mon Sep 17 00:00:00 2001 From: gerard Date: Mon, 27 Aug 2018 11:48:37 +0200 Subject: [PATCH 3/3] Bug #590 estructura basica de claim --- client/claim/src/descriptor/index.html | 2 +- client/claim/src/index/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/claim/src/descriptor/index.html b/client/claim/src/descriptor/index.html index ff371fe23..4bf70e5fe 100644 --- a/client/claim/src/descriptor/index.html +++ b/client/claim/src/descriptor/index.html @@ -1,6 +1,6 @@ - + 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}}