From 300c7a3cfea13d4d5eb1019d05e6f6dc5255c876 Mon Sep 17 00:00:00 2001 From: Joan Date: Mon, 8 Oct 2018 08:14:25 +0200 Subject: [PATCH] userConfig fix --- .../user-configuration-popover/index.js | 16 ++++++++-------- .../common/methods/userConfig/getUserConfig.js | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/salix/src/components/user-configuration-popover/index.js b/client/salix/src/components/user-configuration-popover/index.js index 8b084c11d5..559425f84d 100644 --- a/client/salix/src/components/user-configuration-popover/index.js +++ b/client/salix/src/components/user-configuration-popover/index.js @@ -1,5 +1,5 @@ import ngModule from '../../module'; -import './style.scss' +import './style.scss'; class Controller { constructor($scope, $http, $state, vnApp, $translate) { @@ -8,7 +8,7 @@ class Controller { this.$state = $state; this.vnApp = vnApp; this.$translate = $translate; - this.getUserConfig() + this.getUserConfig(); } set localBank(value) { @@ -43,7 +43,7 @@ class Controller { this.setUserConfig('warehouseFk'); } - get warehouseFk () { + get warehouseFk() { return this.warehouse; } @@ -52,7 +52,7 @@ class Controller { this.setUserConfig('companyFk'); } - get companyFk () { + get companyFk() { return this.company; } @@ -63,11 +63,11 @@ class Controller { getUserConfig() { this.$http.get('/api/UserConfigs/getUserConfig') .then(res => { - if (res.data.response.warehouseFk) - this.warehouse = res.data.response.warehouseFk; + if (res.data && res.data.warehouseFk) + this.warehouse = res.data.warehouseFk; - if (res.data.response.companyFk) - this.company = res.data.response.companyFk; + if (res.data && res.data.companyFk) + this.company = res.data.companyFk; }); } diff --git a/services/loopback/common/methods/userConfig/getUserConfig.js b/services/loopback/common/methods/userConfig/getUserConfig.js index e3c9b59e13..665d00966d 100644 --- a/services/loopback/common/methods/userConfig/getUserConfig.js +++ b/services/loopback/common/methods/userConfig/getUserConfig.js @@ -3,8 +3,8 @@ module.exports = function(Self) { description: 'returns the information from UserConfig model for the active user', accepts: [], returns: { - arg: 'response', - type: 'object' + type: 'object', + root: true }, http: { path: `/getUserConfig`, @@ -12,10 +12,10 @@ module.exports = function(Self) { } }); - Self.getUserConfig = async(ctx) => { + Self.getUserConfig = async ctx => { let token = ctx.req.accessToken; let currentUserId = token && token.userId; - return await Self.app.models.UserConfig.findOne({userFk: currentUserId}); - } + return await Self.findOne({userFk: currentUserId}); + }; };