#1022 ticket.create
This commit is contained in:
parent
31dc2bd5e2
commit
5fce69cd5c
|
@ -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}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
@ -24,5 +24,5 @@ module.exports = function(Self) {
|
|||
params.userFk = currentUserId;
|
||||
|
||||
return await Self.app.models.UserConfig.upsertWithWhere({userFk: currentUserId}, params);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -50,7 +50,5 @@
|
|||
ng-click="$ctrl.onLogoutClick()">
|
||||
</vn-icon>
|
||||
</div>
|
||||
<vn-popover vn-id="popover">
|
||||
<vn-user-configuration-popover>
|
||||
</vn-user-configuration-popover>
|
||||
</vn-popover>
|
||||
<vn-user-configuration-popover vn-id="popover">
|
||||
</vn-user-configuration-popover>
|
|
@ -37,8 +37,7 @@ export default class MainMenu {
|
|||
}
|
||||
|
||||
openUserConfiguration(event) {
|
||||
this.$.popover.parent = event.target;
|
||||
this.$.popover.show();
|
||||
this.$.popover.show(event);
|
||||
}
|
||||
|
||||
onLogoutClick() {
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
<vn-crud-model
|
||||
url="/api/Banks"
|
||||
data="banks"
|
||||
vn-id="banks"
|
||||
data="banksData"
|
||||
order="bank">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
url="/api/Warehouses"
|
||||
data="warehouses"
|
||||
vn-id="warehouses"
|
||||
data="warehousesData"
|
||||
order="name">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
url="/api/Companies"
|
||||
data="companies"
|
||||
vn-id="companies"
|
||||
data="companiesData"
|
||||
order="code">
|
||||
</vn-crud-model>
|
||||
<vn-vertical class="body">
|
||||
|
||||
<vn-popover vn-id="popover">
|
||||
<vn-vertical class="body">
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()">
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
|
@ -21,7 +26,7 @@
|
|||
label="Local warehouse"
|
||||
id="localWarehouse"
|
||||
field="$ctrl.localWarehouseFk"
|
||||
data="warehouses"
|
||||
data="warehousesData"
|
||||
select-fields="['id','name']"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
|
@ -33,7 +38,7 @@
|
|||
label="Local bank"
|
||||
id="localBank"
|
||||
field="$ctrl.localBankFk"
|
||||
data="banks"
|
||||
data="banksData"
|
||||
select-fields="['id','bank']"
|
||||
show-field="bank"
|
||||
value-field="id">
|
||||
|
@ -45,7 +50,7 @@
|
|||
label="Local company"
|
||||
id="localCompany"
|
||||
field="$ctrl.localCompanyFk"
|
||||
data="companies"
|
||||
data="companiesData"
|
||||
select-fields="['id','code']"
|
||||
show-field="code"
|
||||
value-field="id">
|
||||
|
@ -57,7 +62,7 @@
|
|||
label="User warehouse"
|
||||
id="userWarehouse"
|
||||
field="$ctrl.warehouseFk"
|
||||
data="warehouses"
|
||||
data="warehousesData"
|
||||
select-fields="['id', 'name']"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
|
@ -69,11 +74,12 @@
|
|||
label="User company"
|
||||
id="userCompany"
|
||||
field="$ctrl.companyFk"
|
||||
data="companies"
|
||||
data="companiesData"
|
||||
select-fields="['id', 'code']"
|
||||
show-field="code"
|
||||
value-field="id">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</vn-vertical>
|
||||
</vn-vertical>
|
||||
</vn-popover>
|
|
@ -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,6 +63,14 @@ class Controller {
|
|||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
}
|
||||
|
||||
show(event) {
|
||||
this.$scope.banks.refresh();
|
||||
this.$scope.warehouses.refresh();
|
||||
this.$scope.companies.refresh();
|
||||
this.$scope.popover.parent = event.target;
|
||||
this.$scope.popover.show();
|
||||
}
|
||||
|
||||
getUserConfig() {
|
||||
this.$http.get('/api/UserConfigs/getUserConfig')
|
||||
.then(res => {
|
||||
|
@ -80,9 +88,10 @@ class Controller {
|
|||
});
|
||||
}
|
||||
|
||||
setUserConfig(property) {
|
||||
setUserConfig(property, value) {
|
||||
let params = {};
|
||||
params[property] = this[property];
|
||||
params[property] = value;
|
||||
console.log(value);
|
||||
|
||||
this.$http.post('/api/UserConfigs/setUserConfig', params)
|
||||
.then(() => {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue