salix/front/salix/components/user-popover/index.js

95 lines
2.1 KiB
JavaScript

import ngModule from '../../module';
import './style.scss';
import config from '../../config.json';
class Controller {
constructor($, $translate, vnConfig, vnAuth, vnToken) {
Object.assign(this, {
$,
$translate,
vnConfig,
vnAuth,
vnToken,
lang: $translate.use(),
langs: []
});
for (let code of $translate.getAvailableLanguageKeys()) {
this.langs.push({
code: code,
name: config.languages[code] ? config.languages[code] : code
});
}
}
set lang(value) {
this._lang = value;
this.$translate.use(value);
}
get lang() {
return this._lang;
}
set localBankFk(value) {
this.vnConfig.setLocal('bankFk', value);
}
get localBankFk() {
return this.vnConfig.local.bankFk;
}
set localWarehouseFk(value) {
this.vnConfig.setLocal('warehouseFk', value);
}
get localWarehouseFk() {
return this.vnConfig.local.warehouseFk;
}
set localCompanyFk(value) {
this.vnConfig.setLocal('companyFk', value);
}
get localCompanyFk() {
return this.vnConfig.local.companyFk;
}
set warehouseFk(value) {
this.vnConfig.setUser('warehouseFk', value);
}
get warehouseFk() {
return this.vnConfig.user.warehouseFk;
}
set companyFk(value) {
this.vnConfig.setUser('companyFk', value);
}
get companyFk() {
return this.vnConfig.user.companyFk;
}
show(event) {
this.$.warehouses.refresh();
this.$.companies.refresh();
this.$.popover.show(event.target);
}
bankSearchFunc($search) {
return /^\d+$/.test($search)
? {id: $search}
: {bank: {like: '%' + $search + '%'}};
}
async redirect(id) {
window.location.href = await this.vnConfig.vnApp.getUrl(`worker/${id}`);
}
}
Controller.$inject = ['$scope', '$translate', 'vnConfig', 'vnAuth', 'vnToken'];
ngModule.vnComponent('vnUserPopover', {
template: require('./index.html'),
controller: Controller
});