From b3ddeaf4a77a1e346af599fb46da5e1669075756 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 5 Jan 2018 08:06:21 +0100 Subject: [PATCH] credit refactor to build employee name and surname on client side --- client/client/src/credit-list/credit-list.html | 12 +++++------- services/client/common/models/client-credit.js | 13 +------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/client/client/src/credit-list/credit-list.html b/client/client/src/credit-list/credit-list.html index 02a13d1ff..e888bfacb 100644 --- a/client/client/src/credit-list/credit-list.html +++ b/client/client/src/credit-list/credit-list.html @@ -2,7 +2,6 @@ Credit - @@ -12,11 +11,10 @@ - {{::credit.amount | number:2}} € - {{::credit.created | date:'dd/MM/yyyy HH:mm' }} - {{::credit.employee.name}} + ng-repeat="credit in index.model.instances track by credit.id"> + {{::credit.amount | number:2}} € + {{::credit.created | date:'dd/MM/yyyy HH:mm' }} + {{::credit.employee.name}} {{::credit.employee.surname}} No results @@ -25,5 +23,5 @@ - + \ No newline at end of file diff --git a/services/client/common/models/client-credit.js b/services/client/common/models/client-credit.js index 7205be03e..ae7fbb466 100644 --- a/services/client/common/models/client-credit.js +++ b/services/client/common/models/client-credit.js @@ -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; - } };