Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Joan Sanchez 2018-08-27 15:12:04 +02:00
commit 2e8f8109e7
8 changed files with 193 additions and 3 deletions

View File

@ -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"
}
}
]
}

View File

@ -0,0 +1,11 @@
<vn-main-block>
<vn-horizontal>
<vn-auto class="left-block">
<vn-claim-descriptor claim="$ctrl.claim"></vn-claim-descriptor>
<vn-left-menu></vn-left-menu>
</vn-auto>
<vn-one>
<vn-vertical margin-medium ui-view></vn-vertical>
</vn-one>
</vn-horizontal>
</vn-main-block>

View File

@ -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
});

View File

@ -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});
});
});
});
});

View File

@ -0,0 +1,51 @@
<vn-card margin-medium-v class="vn-descriptor">
<vn-horizontal class="header">
<a translate-attr="{title: 'Return to module index'}" ui-sref="claim.index">
<vn-icon icon="chevron_left"></vn-icon>
</a>
<vn-icon icon=""></vn-icon>
<a translate-attr="{title: 'Preview'}" ui-sref="claim.card.summary({id: $ctrl.claim.id})">
<vn-icon icon="desktop_windows"></vn-icon>
</a>
</vn-horizontal>
<vn-vertical>
<vn-auto pad-medium>
<h5>{{$ctrl.claim.id}}</h5>
<vn-label-value label="Client"
value="{{::$ctrl.claim.client.name}}">
</vn-label-value>
<vn-label-value label="State"
value="{{::$ctrl.claim.claimState.description}}">
</vn-label-value>
<vn-label-value label="Created"
value="{{$ctrl.claim.created | dateTime: 'dd/MM/yyyy'}}">
</vn-label-value>
<vn-label-value label="Buyer"
value="{{$ctrl.claim.client.salesPerson.firstName}} {{$ctrl.claim.client.salesPerson.name}}">
</vn-label-value>
<vn-label-value label="Attended"
value="{{$ctrl.claim.worker.firstName}} {{$ctrl.claim.worker.name}}">
</vn-label-value>
</vn-auto>
</vn-vertical>
<vn-horizontal pad-small class="quicklinks">
<vn-button ng-if="$ctrl.quicklinks.btnOne" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnOne.tooltip}}"
icon="{{::$ctrl.quicklinks.btnOne.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnOne.state, $ctrl.quicklinks.btnOne.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnTwo" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnTwo.tooltip}}"
icon="{{::$ctrl.quicklinks.btnTwo.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnTwo.state, $ctrl.quicklinks.btnTwo.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnThree" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnThree.tooltip}}"
icon="{{::$ctrl.quicklinks.btnThree.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnThree.state, $ctrl.quicklinks.btnThree.params)">
</vn-button>
</vn-horizontal>
</vn-card>

View File

@ -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: '<'
}
});

View File

@ -1,7 +1,6 @@
export * from './module';
import './index/';
/*
import './card';
import './descriptor';
import './summary'; */
// import './summary';

View File

@ -32,7 +32,7 @@
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="claim in claims">
<vn-tr ng-repeat="claim in claims" ui-sref="claim.card.detail({id: claim.id})" class=clickable>
<vn-td number>{{::claim.id}}</vn-td>
<vn-td number>{{::claim.client.id}}</vn-td>
<vn-td>{{::claim.client.name}}</vn-td>