diff --git a/back/methods/user-config/getUserConfig.js b/back/methods/user-config/getUserConfig.js
index 665d00966..e5ade8ada 100644
--- a/back/methods/user-config/getUserConfig.js
+++ b/back/methods/user-config/getUserConfig.js
@@ -13,9 +13,8 @@ module.exports = function(Self) {
});
Self.getUserConfig = async ctx => {
- let token = ctx.req.accessToken;
- let currentUserId = token && token.userId;
-
- return await Self.findOne({userFk: currentUserId});
+ return await Self.app.models.UserConfig.findOne({
+ where: {userFk: ctx.req.accessToken.userId}
+ });
};
};
diff --git a/back/methods/user-config/setUserConfig.js b/back/methods/user-config/setUserConfig.js
index bd258b832..098ba9866 100644
--- a/back/methods/user-config/setUserConfig.js
+++ b/back/methods/user-config/setUserConfig.js
@@ -24,5 +24,5 @@ module.exports = function(Self) {
params.userFk = currentUserId;
return await Self.app.models.UserConfig.upsertWithWhere({userFk: currentUserId}, params);
- }
+ };
};
diff --git a/front/salix/components/main-menu/main-menu.html b/front/salix/components/main-menu/main-menu.html
index cebe1e0ce..d03ca33c0 100644
--- a/front/salix/components/main-menu/main-menu.html
+++ b/front/salix/components/main-menu/main-menu.html
@@ -50,7 +50,5 @@
ng-click="$ctrl.onLogoutClick()">
-
-
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/front/salix/components/main-menu/main-menu.js b/front/salix/components/main-menu/main-menu.js
index bd6b53678..880d959d6 100644
--- a/front/salix/components/main-menu/main-menu.js
+++ b/front/salix/components/main-menu/main-menu.js
@@ -37,8 +37,7 @@ export default class MainMenu {
}
openUserConfiguration(event) {
- this.$.popover.parent = event.target;
- this.$.popover.show();
+ this.$.popover.show(event);
}
onLogoutClick() {
diff --git a/front/salix/components/user-configuration-popover/index.html b/front/salix/components/user-configuration-popover/index.html
index 898700609..1c771c713 100644
--- a/front/salix/components/user-configuration-popover/index.html
+++ b/front/salix/components/user-configuration-popover/index.html
@@ -1,79 +1,85 @@
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/front/salix/components/user-configuration-popover/index.js b/front/salix/components/user-configuration-popover/index.js
index a6bda1ad1..2b8d2d243 100644
--- a/front/salix/components/user-configuration-popover/index.js
+++ b/front/salix/components/user-configuration-popover/index.js
@@ -43,7 +43,7 @@ class Controller {
set warehouseFk(value) {
this.warehouse = value;
- this.setUserConfig('warehouseFk');
+ this.setUserConfig('warehouseFk', value);
}
get warehouseFk() {
@@ -52,7 +52,7 @@ class Controller {
set companyFk(value) {
this.company = value;
- this.setUserConfig('companyFk');
+ this.setUserConfig('companyFk', value);
}
get companyFk() {
@@ -63,31 +63,39 @@ class Controller {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}
- getUserConfig() {
- this.$http.get('/api/UserConfigs/getUserConfig')
- .then(res => {
- if (res.data && res.data.warehouseFk) {
- this.warehouse = res.data.warehouseFk;
- if (!localStorage.getItem('localWarehouseFk'))
- localStorage.setItem('defaultWarehouseFk', res.data.warehouseFk);
- }
-
- if (res.data && res.data.companyFk) {
- this.company = res.data.companyFk;
- if (!localStorage.getItem('localCompanyFk'))
- localStorage.setItem('defaultCompanyFk', res.data.companyFk);
- }
- });
+ show(event) {
+ this.$scope.banks.refresh();
+ this.$scope.warehouses.refresh();
+ this.$scope.companies.refresh();
+ this.$scope.popover.parent = event.target;
+ this.$scope.popover.show();
}
- setUserConfig(property) {
+ getUserConfig() {
+ this.$http.get('/api/UserConfigs/getUserConfig')
+ .then(res => {
+ if (res.data && res.data.warehouseFk) {
+ this.warehouse = res.data.warehouseFk;
+ if (!localStorage.getItem('localWarehouseFk'))
+ localStorage.setItem('defaultWarehouseFk', res.data.warehouseFk);
+ }
+
+ if (res.data && res.data.companyFk) {
+ this.company = res.data.companyFk;
+ if (!localStorage.getItem('localCompanyFk'))
+ localStorage.setItem('defaultCompanyFk', res.data.companyFk);
+ }
+ });
+ }
+
+ setUserConfig(property, value) {
let params = {};
- params[property] = this[property];
+ params[property] = value;
this.$http.post('/api/UserConfigs/setUserConfig', params)
- .then(() => {
- this.showOk();
- });
+ .then(() => {
+ this.showOk();
+ });
}
$onInit() {
diff --git a/front/salix/components/user-configuration-popover/index.spec.js b/front/salix/components/user-configuration-popover/index.spec.js
index d6c61de29..829ff674a 100644
--- a/front/salix/components/user-configuration-popover/index.spec.js
+++ b/front/salix/components/user-configuration-popover/index.spec.js
@@ -50,7 +50,7 @@ describe('Salix', () => {
controller.warehouseFk = 4;
expect(controller.warehouse).toBe(4);
- expect(controller.setUserConfig).toHaveBeenCalledWith('warehouseFk');
+ expect(controller.setUserConfig).toHaveBeenCalledWith('warehouseFk', 4);
});
});
@@ -60,7 +60,7 @@ describe('Salix', () => {
controller.companyFk = 4;
expect(controller.company).toBe(4);
- expect(controller.setUserConfig).toHaveBeenCalledWith('companyFk');
+ expect(controller.setUserConfig).toHaveBeenCalledWith('companyFk', 4);
});
});
@@ -83,8 +83,8 @@ describe('Salix', () => {
$httpBackend.when('GET', `/api/UserConfigs/getUserConfig`).respond({companyFk: 2});
$httpBackend.expect('GET', `/api/UserConfigs/getUserConfig`);
$httpBackend.when('POST', `/api/UserConfigs/setUserConfig`, {companyFk: 1}).respond(200);
- $httpBackend.expect('POST', `/api/UserConfigs/setUserConfig`, {companyFk: 1});
- controller.setUserConfig('companyFk');
+ $httpBackend.expect('POST', `/api/UserConfigs/setUserConfig`);
+ controller.setUserConfig('companyFk', 1);
$httpBackend.flush();
expect(controller.showOk).toHaveBeenCalledWith();
diff --git a/front/salix/components/user-configuration-popover/locale/es.yml b/front/salix/components/user-configuration-popover/locale/es.yml
new file mode 100644
index 000000000..3961f69ad
--- /dev/null
+++ b/front/salix/components/user-configuration-popover/locale/es.yml
@@ -0,0 +1,5 @@
+Local warehouse: Almacén local
+Local bank: Banco local
+Local company: Compañia local
+User warehouse: Almacén del usuario
+User company: Compañia del usuario
\ No newline at end of file
diff --git a/front/salix/components/user-configuration-popover/style.scss b/front/salix/components/user-configuration-popover/style.scss
index d370cc279..acd0495e6 100644
--- a/front/salix/components/user-configuration-popover/style.scss
+++ b/front/salix/components/user-configuration-popover/style.scss
@@ -1,12 +1,13 @@
@import 'colors';
vn-user-configuration-popover {
- color: $main-font-color;
- & > vn-vertical {
- min-width: 250px;
+ vn-popover {
+ color: $main-font-color;
+ vn-vertical {
+ min-width: 250px;
+ }
+ .body {
+ padding: 16px 16px 6px 16px;
+ }
}
- .body {
- padding: 16px 16px 6px 16px;
- }
-
}
\ No newline at end of file
diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql
index c811db8e3..e72ab35b7 100644
--- a/services/db/install/dump/fixtures.sql
+++ b/services/db/install/dump/fixtures.sql
@@ -1050,7 +1050,10 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
(21, 21);
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
- VALUES (9, 1, 442);
+ VALUES
+ (1, 2, 69),
+ (9, 1, 442),
+ (18, 3, 791);
INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `amountUnpaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`)
VALUES