credit refactor to build employee name and surname on client side

This commit is contained in:
Carlos Jimenez 2018-01-05 08:06:21 +01:00
parent 8e25216c3b
commit b3ddeaf4a7
2 changed files with 6 additions and 19 deletions

View File

@ -2,7 +2,6 @@
<vn-card pad-medium>
<vn-vertical pad-large>
<vn-title vn-one margin-large-bottom>Credit</vn-title>
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
<vn-column-header vn-one pad-medium-h field="amount" text="Credit"></vn-column-header>
<vn-column-header vn-two pad-medium-h field="created" text="Since" default-order="ASC"></vn-column-header>
@ -12,11 +11,10 @@
<vn-horizontal
vn-one class="list list-element text-center"
pad-small-bottom
ng-repeat="credit in index.model.instances track by credit.id"
>
<vn-one pad-medium-h>{{::credit.amount | number:2}} €</vn-one>
<vn-two pad-medium-h>{{::credit.created | date:'dd/MM/yyyy HH:mm' }}</vn-two>
<vn-two pad-medium-h>{{::credit.employee.name}}</vn-two>
ng-repeat="credit in index.model.instances track by credit.id">
<vn-one pad-medium-h>{{::credit.amount | number:2}} €</vn-one>
<vn-two pad-medium-h>{{::credit.created | date:'dd/MM/yyyy HH:mm' }}</vn-two>
<vn-two pad-medium-h>{{::credit.employee.name}} {{::credit.employee.surname}}</vn-two>
</vn-horizontal>
</vn-one>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
@ -25,5 +23,5 @@
</vn-vertical>
</vn-card>
<a ui-sref="clientCard.credit.create" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -1,5 +1,5 @@
module.exports = function(Self) {
Self.installMethod('filter', filterParams, filterResults);
Self.installMethod('filter', filterParams);
function filterParams(params) {
return {
@ -17,15 +17,4 @@ module.exports = function(Self) {
}
};
}
function filterResults(instances) {
let result = JSON.parse(JSON.stringify(instances));
if (result && result.instances && result.instances.length) {
result.instances.forEach((element, i) => {
result.instances[i].employee.name = `${element.employee.name} ${element.employee.surname}`;
delete result.instances[i].employee.surname;
});
}
return result;
}
};