Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
d19809c318
|
@ -13,9 +13,8 @@ module.exports = function(Self) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getUserConfig = async ctx => {
|
Self.getUserConfig = async ctx => {
|
||||||
let token = ctx.req.accessToken;
|
return await Self.app.models.UserConfig.findOne({
|
||||||
let currentUserId = token && token.userId;
|
where: {userFk: ctx.req.accessToken.userId}
|
||||||
|
});
|
||||||
return await Self.findOne({userFk: currentUserId});
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,5 +24,5 @@ module.exports = function(Self) {
|
||||||
params.userFk = currentUserId;
|
params.userFk = currentUserId;
|
||||||
|
|
||||||
return await Self.app.models.UserConfig.upsertWithWhere({userFk: currentUserId}, params);
|
return await Self.app.models.UserConfig.upsertWithWhere({userFk: currentUserId}, params);
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,7 +50,5 @@
|
||||||
ng-click="$ctrl.onLogoutClick()">
|
ng-click="$ctrl.onLogoutClick()">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
</div>
|
</div>
|
||||||
<vn-popover vn-id="popover">
|
<vn-user-configuration-popover vn-id="popover">
|
||||||
<vn-user-configuration-popover>
|
</vn-user-configuration-popover>
|
||||||
</vn-user-configuration-popover>
|
|
||||||
</vn-popover>
|
|
|
@ -37,8 +37,7 @@ export default class MainMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
openUserConfiguration(event) {
|
openUserConfiguration(event) {
|
||||||
this.$.popover.parent = event.target;
|
this.$.popover.show(event);
|
||||||
this.$.popover.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onLogoutClick() {
|
onLogoutClick() {
|
||||||
|
|
|
@ -1,79 +1,85 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
url="/api/Banks"
|
url="/api/Banks"
|
||||||
data="banks"
|
vn-id="banks"
|
||||||
|
data="banksData"
|
||||||
order="bank">
|
order="bank">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
url="/api/Warehouses"
|
url="/api/Warehouses"
|
||||||
data="warehouses"
|
vn-id="warehouses"
|
||||||
|
data="warehousesData"
|
||||||
order="name">
|
order="name">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
url="/api/Companies"
|
url="/api/Companies"
|
||||||
data="companies"
|
vn-id="companies"
|
||||||
|
data="companiesData"
|
||||||
order="code">
|
order="code">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-vertical class="body">
|
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()">
|
<vn-popover vn-id="popover">
|
||||||
<vn-horizontal>
|
<vn-vertical class="body">
|
||||||
<vn-autocomplete
|
<form name="form" ng-submit="$ctrl.onSubmit()">
|
||||||
vn-one
|
<vn-horizontal>
|
||||||
label="Local warehouse"
|
<vn-autocomplete
|
||||||
id="localWarehouse"
|
vn-one
|
||||||
field="$ctrl.localWarehouseFk"
|
label="Local warehouse"
|
||||||
data="warehouses"
|
id="localWarehouse"
|
||||||
select-fields="['id','name']"
|
field="$ctrl.localWarehouseFk"
|
||||||
show-field="name"
|
data="warehousesData"
|
||||||
value-field="id">
|
select-fields="['id','name']"
|
||||||
</vn-autocomplete>
|
show-field="name"
|
||||||
</vn-horizontal>
|
value-field="id">
|
||||||
<vn-horizontal>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
</vn-horizontal>
|
||||||
vn-one
|
<vn-horizontal>
|
||||||
label="Local bank"
|
<vn-autocomplete
|
||||||
id="localBank"
|
vn-one
|
||||||
field="$ctrl.localBankFk"
|
label="Local bank"
|
||||||
data="banks"
|
id="localBank"
|
||||||
select-fields="['id','bank']"
|
field="$ctrl.localBankFk"
|
||||||
show-field="bank"
|
data="banksData"
|
||||||
value-field="id">
|
select-fields="['id','bank']"
|
||||||
</vn-autocomplete>
|
show-field="bank"
|
||||||
</vn-horizontal>
|
value-field="id">
|
||||||
<vn-horizontal>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
</vn-horizontal>
|
||||||
vn-one
|
<vn-horizontal>
|
||||||
label="Local company"
|
<vn-autocomplete
|
||||||
id="localCompany"
|
vn-one
|
||||||
field="$ctrl.localCompanyFk"
|
label="Local company"
|
||||||
data="companies"
|
id="localCompany"
|
||||||
select-fields="['id','code']"
|
field="$ctrl.localCompanyFk"
|
||||||
show-field="code"
|
data="companiesData"
|
||||||
value-field="id">
|
select-fields="['id','code']"
|
||||||
</vn-autocomplete>
|
show-field="code"
|
||||||
</vn-horizontal>
|
value-field="id">
|
||||||
<vn-horizontal>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
</vn-horizontal>
|
||||||
vn-one
|
<vn-horizontal>
|
||||||
label="User warehouse"
|
<vn-autocomplete
|
||||||
id="userWarehouse"
|
vn-one
|
||||||
field="$ctrl.warehouseFk"
|
label="User warehouse"
|
||||||
data="warehouses"
|
id="userWarehouse"
|
||||||
select-fields="['id', 'name']"
|
field="$ctrl.warehouseFk"
|
||||||
show-field="name"
|
data="warehousesData"
|
||||||
value-field="id">
|
select-fields="['id', 'name']"
|
||||||
</vn-autocomplete>
|
show-field="name"
|
||||||
</vn-horizontal>
|
value-field="id">
|
||||||
<vn-horizontal>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
</vn-horizontal>
|
||||||
vn-one
|
<vn-horizontal>
|
||||||
label="User company"
|
<vn-autocomplete
|
||||||
id="userCompany"
|
vn-one
|
||||||
field="$ctrl.companyFk"
|
label="User company"
|
||||||
data="companies"
|
id="userCompany"
|
||||||
select-fields="['id', 'code']"
|
field="$ctrl.companyFk"
|
||||||
show-field="code"
|
data="companiesData"
|
||||||
value-field="id">
|
select-fields="['id', 'code']"
|
||||||
</vn-autocomplete>
|
show-field="code"
|
||||||
</vn-horizontal>
|
value-field="id">
|
||||||
</form>
|
</vn-autocomplete>
|
||||||
</vn-vertical>
|
</vn-horizontal>
|
||||||
|
</form>
|
||||||
|
</vn-vertical>
|
||||||
|
</vn-popover>
|
|
@ -43,7 +43,7 @@ class Controller {
|
||||||
|
|
||||||
set warehouseFk(value) {
|
set warehouseFk(value) {
|
||||||
this.warehouse = value;
|
this.warehouse = value;
|
||||||
this.setUserConfig('warehouseFk');
|
this.setUserConfig('warehouseFk', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get warehouseFk() {
|
get warehouseFk() {
|
||||||
|
@ -52,7 +52,7 @@ class Controller {
|
||||||
|
|
||||||
set companyFk(value) {
|
set companyFk(value) {
|
||||||
this.company = value;
|
this.company = value;
|
||||||
this.setUserConfig('companyFk');
|
this.setUserConfig('companyFk', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get companyFk() {
|
get companyFk() {
|
||||||
|
@ -63,31 +63,39 @@ class Controller {
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserConfig() {
|
show(event) {
|
||||||
this.$http.get('/api/UserConfigs/getUserConfig')
|
this.$scope.banks.refresh();
|
||||||
.then(res => {
|
this.$scope.warehouses.refresh();
|
||||||
if (res.data && res.data.warehouseFk) {
|
this.$scope.companies.refresh();
|
||||||
this.warehouse = res.data.warehouseFk;
|
this.$scope.popover.parent = event.target;
|
||||||
if (!localStorage.getItem('localWarehouseFk'))
|
this.$scope.popover.show();
|
||||||
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) {
|
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 = {};
|
let params = {};
|
||||||
params[property] = this[property];
|
params[property] = value;
|
||||||
|
|
||||||
this.$http.post('/api/UserConfigs/setUserConfig', params)
|
this.$http.post('/api/UserConfigs/setUserConfig', params)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.showOk();
|
this.showOk();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$onInit() {
|
$onInit() {
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe('Salix', () => {
|
||||||
controller.warehouseFk = 4;
|
controller.warehouseFk = 4;
|
||||||
|
|
||||||
expect(controller.warehouse).toBe(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;
|
controller.companyFk = 4;
|
||||||
|
|
||||||
expect(controller.company).toBe(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.when('GET', `/api/UserConfigs/getUserConfig`).respond({companyFk: 2});
|
||||||
$httpBackend.expect('GET', `/api/UserConfigs/getUserConfig`);
|
$httpBackend.expect('GET', `/api/UserConfigs/getUserConfig`);
|
||||||
$httpBackend.when('POST', `/api/UserConfigs/setUserConfig`, {companyFk: 1}).respond(200);
|
$httpBackend.when('POST', `/api/UserConfigs/setUserConfig`, {companyFk: 1}).respond(200);
|
||||||
$httpBackend.expect('POST', `/api/UserConfigs/setUserConfig`, {companyFk: 1});
|
$httpBackend.expect('POST', `/api/UserConfigs/setUserConfig`);
|
||||||
controller.setUserConfig('companyFk');
|
controller.setUserConfig('companyFk', 1);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.showOk).toHaveBeenCalledWith();
|
expect(controller.showOk).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -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
|
|
@ -1,12 +1,13 @@
|
||||||
@import 'colors';
|
@import 'colors';
|
||||||
|
|
||||||
vn-user-configuration-popover {
|
vn-user-configuration-popover {
|
||||||
color: $main-font-color;
|
vn-popover {
|
||||||
& > vn-vertical {
|
color: $main-font-color;
|
||||||
min-width: 250px;
|
vn-vertical {
|
||||||
|
min-width: 250px;
|
||||||
|
}
|
||||||
|
.body {
|
||||||
|
padding: 16px 16px 6px 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.body {
|
|
||||||
padding: 16px 16px 6px 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1050,7 +1050,10 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
|
||||||
(21, 21);
|
(21, 21);
|
||||||
|
|
||||||
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
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`)
|
INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `amountUnpaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
Loading…
Reference in New Issue