userConfig fix
This commit is contained in:
parent
ec3a448396
commit
300c7a3cfe
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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});
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue