From c31825331d73ff8d00678e6a7d38c72b6c4f6ebb Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 9 Jul 2020 11:45:38 +0200 Subject: [PATCH] refactor loggable --- loopback/common/models/loggable.js | 1 - modules/client/back/methods/client/getCard.js | 10 ++++++++-- modules/client/back/models/client.json | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js index 99a1ad39b..eaa44f9ba 100644 --- a/loopback/common/models/loggable.js +++ b/loopback/common/models/loggable.js @@ -249,7 +249,6 @@ module.exports = function(Self) { let newInstance = {}; if (ctx.hookState.newInstance) Object.assign(newInstance, ctx.hookState.newInstance); - let userFk; if (loopBackContext) userFk = loopBackContext.active.accessToken.userId; diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 6c69d32a8..121534b02 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -27,11 +27,11 @@ module.exports = function(Self) { { relation: 'salesPerson', scope: { - fields: ['userFk'], + fields: ['userFk', 'firstName'], include: { relation: 'user', scope: { - fields: ['nickname'] + fields: ['name', 'nickname'] } } } @@ -45,6 +45,12 @@ module.exports = function(Self) { scope: { fields: ['id', 'name'] } + }, { + }, { + relation: 'salesPersonUser', + scope: { + fields: ['id', 'name'] + } }, { relation: 'country', scope: { diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index c62ae3832..6f108d640 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -136,6 +136,11 @@ "model": "Worker", "foreignKey": "salesPersonFk" }, + "salesPersonUser": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "salesPersonFk" + }, "province": { "type": "belongsTo", "model": "Province",