2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-16 01:44:39 +00:00
|
|
|
const Module = require('./module');
|
|
|
|
const Tpl = require('./gui.xml').default;
|
2022-11-17 22:31:48 +00:00
|
|
|
const kebabToCamel = require('vn/string-util').kebabToCamel;
|
|
|
|
const routes = require('../../import').routes;
|
2022-05-21 21:31:56 +00:00
|
|
|
require('./gui.scss');
|
2018-05-11 09:25:10 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
module.exports = new Class({
|
2022-06-06 12:49:18 +00:00
|
|
|
Extends: Vn.Component,
|
2019-09-06 12:54:50 +00:00
|
|
|
Properties: {
|
|
|
|
conn: {
|
2016-09-24 14:32:31 +00:00
|
|
|
type: Db.Connection
|
2022-11-16 01:46:44 +00:00
|
|
|
,set(x) {
|
2019-09-06 12:54:50 +00:00
|
|
|
this.link({_conn: x}, {'loading-changed': this._onConnLoadChange });
|
2015-12-10 13:48:43 +00:00
|
|
|
}
|
2022-11-16 01:46:44 +00:00
|
|
|
,get() {
|
2015-09-11 09:37:16 +00:00
|
|
|
return this._conn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,forms: {}
|
|
|
|
,activeForm: null
|
|
|
|
,activeCss: null
|
|
|
|
,requestedForm: null
|
|
|
|
,menuShown: false
|
|
|
|
,menuOptions: {}
|
|
|
|
,choosedOption: null
|
2015-12-19 15:42:38 +00:00
|
|
|
,_shown: false
|
|
|
|
,_scrollTimeout: null
|
|
|
|
,_navbarVisible: true
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,initialize(props) {
|
2022-06-06 12:49:18 +00:00
|
|
|
this.loadTemplateFromString(Tpl);
|
2015-09-11 09:37:16 +00:00
|
|
|
this.loadingCount = 0;
|
|
|
|
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.background.onclick = function() {};
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.leftPanel.addEventListener('click', function(event) {
|
2019-09-06 12:54:50 +00:00
|
|
|
event.stopPropagation();
|
2015-09-11 09:37:16 +00:00
|
|
|
});
|
2015-12-02 17:26:58 +00:00
|
|
|
|
2022-06-06 16:02:17 +00:00
|
|
|
Vn.Component.prototype.initialize.call(this, props);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
,async show() {
|
|
|
|
if (this._shown) return;
|
2015-12-19 15:42:38 +00:00
|
|
|
this._shown = true;
|
2022-11-28 08:51:31 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.doc.body.appendChild(this.node);
|
2022-05-28 01:18:06 +00:00
|
|
|
Htk.Toast.pushTop(this.$.formHolder);
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
const resultSet = await this._conn.execQuery(
|
|
|
|
'SELECT id, name, nickname FROM account.myUser;'
|
|
|
|
+'SELECT defaultForm FROM config;'
|
|
|
|
+'SELECT url FROM imageConfig;'
|
|
|
|
+'SELECT dbproduccion FROM vn.config;'
|
|
|
|
+'SELECT productionDomain, testDomain FROM config;'
|
|
|
|
);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
// Retrieving the user name
|
|
|
|
|
2022-05-05 13:56:17 +00:00
|
|
|
this.user = resultSet.fetchObject();
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.setText(this.$.userName, this.user.nickname);
|
2016-10-04 15:27:49 +00:00
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2022-11-29 18:13:32 +00:00
|
|
|
Vn.Config.defaultForm = resultSet.fetchValue();
|
2019-09-06 12:54:50 +00:00
|
|
|
Vn.Config.imageUrl = resultSet.fetchValue();
|
2017-12-20 11:34:04 +00:00
|
|
|
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2022-11-29 18:13:32 +00:00
|
|
|
const isTesting = !resultSet.fetchValue();
|
2018-01-17 14:00:13 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (isTesting) {
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.devInfo.style.display = 'block';
|
|
|
|
this.$.version.textContent = Vn.Cookie.get('vnVersion');
|
2018-01-17 14:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2022-11-29 18:13:32 +00:00
|
|
|
const res = resultSet.fetchObject();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
if (res && res.testDomain) {
|
2022-11-29 18:13:32 +00:00
|
|
|
let linkText, linkField;
|
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
if (location.host != res.productionDomain) {
|
2022-11-29 18:13:32 +00:00
|
|
|
linkText = 'Old website';
|
|
|
|
linkField = 'productionDomain';
|
2019-09-06 12:54:50 +00:00
|
|
|
} else {
|
2022-11-29 18:13:32 +00:00
|
|
|
linkText = 'Test the new website';
|
|
|
|
linkField = 'testDomain';
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.setText(this.$.testLink, _(linkText));
|
|
|
|
this.$.testLink.href = '//'+ res.get(linkField);
|
|
|
|
this.$.testLink.style.display = 'block';
|
2019-09-06 12:54:50 +00:00
|
|
|
} else
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.testLink.style.display = 'none';
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
await this.loadMenu();
|
|
|
|
|
|
|
|
if (Vn.isMobile()) {
|
|
|
|
this._onScrollHandler = this._onScroll.bind(this);
|
|
|
|
window.addEventListener('scroll', this._onScrollHandler );
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.supplantInit();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
this.formParam = new Vn.Param({
|
|
|
|
lot: this.hash,
|
|
|
|
name: 'form',
|
|
|
|
});
|
|
|
|
this.formParam.on('changed', this._onFormChange, this);
|
|
|
|
await this._onFormChange();
|
|
|
|
|
|
|
|
if (!localStorage.getItem('hederaCookies')) {
|
|
|
|
localStorage.setItem('hederaCookies', true);
|
|
|
|
Htk.Toast.showWarning(_('By using this site you accept cookies'));
|
|
|
|
}
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
,async hide() {
|
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._shown = false;
|
|
|
|
|
|
|
|
if (Vn.isMobile())
|
|
|
|
window.removeEventListener('scroll', this._onScrollHandler);
|
|
|
|
|
|
|
|
Htk.Toast.popTop();
|
|
|
|
if (this.formParam) {
|
|
|
|
this.formParam.unref();
|
|
|
|
this.formParam = null;
|
|
|
|
}
|
|
|
|
await this.closeForm();
|
|
|
|
this.hideMenu();
|
|
|
|
Vn.Node.remove(this.node);
|
|
|
|
}
|
|
|
|
|
|
|
|
,async logout() {
|
|
|
|
await this.onLogoutClick();
|
|
|
|
}
|
|
|
|
|
|
|
|
,async onLogoutClick() {
|
|
|
|
try {
|
|
|
|
if (!localStorage.getItem('hederaGuest'))
|
|
|
|
this._conn.close();
|
|
|
|
} finally {
|
|
|
|
this.emit('logout');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_onConnLoadChange(conn, isLoading) {
|
|
|
|
if (isLoading)
|
|
|
|
this.loaderPush();
|
|
|
|
else
|
|
|
|
this.loaderPop();
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
2022-11-28 08:51:31 +00:00
|
|
|
|
|
|
|
,async loadMenu() {
|
|
|
|
const resultSet = await this._conn.execQuery('SELECT * FROM myMenu');
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
// Retrieving menu sections
|
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
var res = resultSet.fetchData();
|
2015-09-11 09:37:16 +00:00
|
|
|
var sectionMap = {};
|
2022-05-28 15:49:46 +00:00
|
|
|
let i = 0;
|
|
|
|
|
|
|
|
for (const row of res) {
|
|
|
|
var parent = row.parentFk;
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (!sectionMap[parent])
|
|
|
|
sectionMap[parent] = [];
|
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
sectionMap[parent].push(i++);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.removeChilds(this.$.mainMenu);
|
|
|
|
this.createMenu(res, sectionMap, null, this.$.mainMenu);
|
2015-12-19 15:42:38 +00:00
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,createMenu(res, sectionMap, parent, ul) {
|
2015-09-11 09:37:16 +00:00
|
|
|
var sections = sectionMap[parent];
|
2022-04-20 13:03:29 +00:00
|
|
|
if (!sections) return;
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
for (var i = 0; i < sections.length; i++) {
|
2015-09-11 09:37:16 +00:00
|
|
|
res.row = sections[i];
|
2022-05-28 15:49:46 +00:00
|
|
|
const row = res[sections[i]];
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var li = this.createElement('li');
|
|
|
|
ul.appendChild(li);
|
2016-10-18 21:54:52 +00:00
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
var text = this.createTextNode(_(row.description));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var a = this.createElement('a');
|
2016-10-18 21:54:52 +00:00
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
if (row.path) {
|
2022-05-30 01:30:33 +00:00
|
|
|
a.href = this.hash.make({form: row.path});
|
2022-05-28 15:49:46 +00:00
|
|
|
this.menuOptions[row.path] = a;
|
2016-10-18 21:54:52 +00:00
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
a.appendChild(text);
|
|
|
|
li.appendChild(a);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
var formId = row.id;
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (sectionMap[formId]) {
|
|
|
|
var submenu = this.createElement('ul');
|
2015-09-11 09:37:16 +00:00
|
|
|
submenu.className = 'submenu';
|
2019-09-06 12:54:50 +00:00
|
|
|
li.appendChild(submenu);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
li.addEventListener('mouseover',
|
|
|
|
this._onLiMouseHover.bind(this, submenu, a));
|
|
|
|
li.addEventListener('mouseout',
|
|
|
|
this._onLiMouseOut.bind(this));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.createMenu(res, sectionMap, formId, submenu);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,_onLiMouseHover(submenu, parent) {
|
2015-09-16 16:11:15 +00:00
|
|
|
if (this.menuShown)
|
2015-09-11 09:37:16 +00:00
|
|
|
return;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.hideSubmenu();
|
2015-09-11 09:37:16 +00:00
|
|
|
this.activeSubmenu = submenu;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var rect = parent.getBoundingClientRect();
|
|
|
|
Vn.Node.addClass(submenu, 'popup');
|
2015-09-11 09:37:16 +00:00
|
|
|
submenu.style.left = rect.right +'px';
|
|
|
|
submenu.style.top = rect.top +'px';
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,_onLiMouseOut() {
|
2019-09-06 12:54:50 +00:00
|
|
|
this.timeout = setTimeout(this.hideSubmenu.bind(this), 160);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,hideSubmenu() {
|
2015-09-11 09:37:16 +00:00
|
|
|
var submenu = this.activeSubmenu;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (submenu) {
|
|
|
|
Vn.Node.removeClass(submenu, 'popup');
|
2016-10-18 21:54:52 +00:00
|
|
|
submenu.style.left = '';
|
|
|
|
submenu.style.top = '';
|
2019-09-06 12:54:50 +00:00
|
|
|
clearTimeout(this.timeout);
|
2015-09-11 09:37:16 +00:00
|
|
|
this.activeSubmenu = null;
|
|
|
|
this.timeout = 0;
|
|
|
|
}
|
|
|
|
}
|
2016-10-04 15:27:49 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
,onMenuClick(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
this.showMenu();
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,showMenu() {
|
2019-09-06 12:54:50 +00:00
|
|
|
this.showBackground();
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.addClass(this.$.leftPanel, 'show');
|
2016-10-04 15:27:49 +00:00
|
|
|
this.menuShown = true;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.hideMenuCallback = this.hideMenu.bind(this);
|
|
|
|
this.doc.addEventListener('click', this.hideMenuCallback);
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,hideMenu() {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (!this.menuShown)
|
|
|
|
return;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.hideBackground();
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.removeClass(this.$.leftPanel, 'show');
|
2016-10-04 15:27:49 +00:00
|
|
|
this.menuShown = false;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.doc.removeEventListener('click', this.hideMenuCallback);
|
2016-10-04 15:27:49 +00:00
|
|
|
this.hideMenuCallback = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Navigation bar
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,_onScroll() {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (this._scrollTimeout === null)
|
2019-09-06 12:54:50 +00:00
|
|
|
this._scrollTimeout = setTimeout(
|
|
|
|
this._scrollTimeoutFunc.bind(this), 150);
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,_scrollTimeoutFunc() {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
2022-05-28 01:18:06 +00:00
|
|
|
var navbar = this.$.topBar;
|
2019-09-06 12:54:50 +00:00
|
|
|
var yOffset = Vn.Browser.getPageYOffset();
|
2016-10-04 15:27:49 +00:00
|
|
|
var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (showNavbar !== this._navbarVisible) {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (showNavbar)
|
|
|
|
var translateY = 0;
|
|
|
|
else
|
|
|
|
var translateY = -navbar.offsetHeight;
|
|
|
|
|
|
|
|
navbar.style.transform =
|
|
|
|
'translateZ(0) translateY('+ translateY +'px)';
|
|
|
|
}
|
|
|
|
|
|
|
|
this._navbarVisible = showNavbar;
|
|
|
|
this._lastYOffset = yOffset;
|
|
|
|
this._scrollTimeout = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Background
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,showBackground() {
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.addClass(this.$.background, 'show');
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,hideBackground() {
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.removeClass(this.$.background, 'show');
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,loaderPush() {
|
2016-10-04 15:27:49 +00:00
|
|
|
this.loadingCount++;
|
|
|
|
|
|
|
|
if (this.loadingCount == 1)
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.loader.start();
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,loaderPop() {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (this.loadingCount == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.loadingCount--;
|
|
|
|
|
|
|
|
if (this.loadingCount == 0)
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.loader.stop();
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms
|
|
|
|
|
2022-11-16 01:44:39 +00:00
|
|
|
,async _onFormChange() {
|
2015-12-19 15:42:38 +00:00
|
|
|
var formPath = this.formParam.value;
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
if (!formPath)
|
2018-05-11 09:25:10 +00:00
|
|
|
formPath = Vn.Config.defaultForm;
|
2015-11-17 10:34:33 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.hideMenu();
|
2022-11-28 08:51:31 +00:00
|
|
|
await this.closeForm();
|
2015-09-11 09:37:16 +00:00
|
|
|
this.requestedForm = formPath;
|
|
|
|
|
2022-11-29 18:13:32 +00:00
|
|
|
if (!formPath) return;
|
|
|
|
this.loaderPush();
|
|
|
|
const newChoosedOption = this.menuOptions[formPath];
|
2015-11-17 10:34:33 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (newChoosedOption) {
|
|
|
|
Vn.Node.addClass(newChoosedOption, 'selected');
|
2015-11-17 10:34:33 +00:00
|
|
|
this.choosedOption = newChoosedOption;
|
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-17 22:31:48 +00:00
|
|
|
await Vn.Locale.load(`forms/${formPath}`);
|
|
|
|
|
2022-11-16 01:44:39 +00:00
|
|
|
let FormKlass;
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-16 01:44:39 +00:00
|
|
|
try {
|
|
|
|
FormKlass = (await this.importForm(formPath)).default;
|
|
|
|
} catch (err) {
|
|
|
|
this.loaderPop();
|
2022-11-17 22:31:48 +00:00
|
|
|
console.log(err);
|
|
|
|
return Htk.Toast.showError(_('Error loading form') +`: ${err.message}`);
|
2022-11-16 01:44:39 +00:00
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.loaderPop();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (!this._shown)
|
2015-09-11 09:37:16 +00:00
|
|
|
return;
|
|
|
|
|
2022-11-16 01:44:39 +00:00
|
|
|
this.activeForm = new FormKlass(this);
|
2022-11-28 08:51:31 +00:00
|
|
|
await this.activeForm.open();
|
2015-12-15 15:22:46 +00:00
|
|
|
}
|
2022-11-16 01:44:39 +00:00
|
|
|
|
|
|
|
,async importForm(path) {
|
2022-11-17 22:31:48 +00:00
|
|
|
const states = path.split('/');
|
|
|
|
let importFn = routes;
|
|
|
|
for (let i = 0; i < states.length && importFn; i++)
|
|
|
|
importFn = importFn[kebabToCamel(states[i])];
|
|
|
|
if (!importFn)
|
|
|
|
throw new Error(`Route '${path}' does not exist`);
|
|
|
|
return importFn();
|
2022-11-16 01:44:39 +00:00
|
|
|
}
|
2015-12-15 15:22:46 +00:00
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,setForm(form) {
|
2022-11-15 21:26:48 +00:00
|
|
|
const holder = this.$.formHolder;
|
|
|
|
Vn.Node.removeChilds(holder);
|
2015-12-15 15:22:46 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (form) {
|
2022-11-15 21:26:48 +00:00
|
|
|
holder.appendChild(form);
|
|
|
|
holder.classList.add('move-start');
|
|
|
|
setTimeout(() => this._onSetFormTimeout(), 10);
|
2015-12-15 15:22:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,_onSetFormTimeout() {
|
2022-11-15 21:26:48 +00:00
|
|
|
const holder = this.$.formHolder;
|
|
|
|
holder.classList.remove('move-start');
|
|
|
|
holder.classList.add('move-end');
|
|
|
|
holder.addEventListener('transitionend',
|
|
|
|
() => holder.classList.remove('move-end'),
|
|
|
|
{once: true}
|
|
|
|
);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,setTitle(title) {
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.removeChilds(this.$.title);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (title)
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.title.appendChild(title);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,setActions(actions) {
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.removeChilds(this.$.actionBar);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (actions)
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.actionBar.appendChild(actions);
|
2015-09-16 16:11:15 +00:00
|
|
|
}
|
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
,async closeForm() {
|
2019-09-06 12:54:50 +00:00
|
|
|
if (this.activeForm) {
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.removeClass(this.$.formHolder, 'show');
|
2022-11-28 08:51:31 +00:00
|
|
|
await this.activeForm.close();
|
2022-11-19 00:28:24 +00:00
|
|
|
this.activeForm._destroy();
|
2015-09-16 16:11:15 +00:00
|
|
|
this.activeForm = null;
|
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (this.activeCss) {
|
|
|
|
Vn.excludeCss(this.activeCss);
|
2015-09-16 16:11:15 +00:00
|
|
|
this.activeCss = null;
|
|
|
|
}
|
2015-11-17 10:34:33 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (this.choosedOption) {
|
|
|
|
Vn.Node.removeClass(this.choosedOption, 'selected');
|
2015-11-17 10:34:33 +00:00
|
|
|
this.choosedOption = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Reports
|
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
,async openReport(reportName, lot) {
|
|
|
|
try {
|
|
|
|
this.loaderPush();
|
|
|
|
const module = new Module('reports', reportName);
|
|
|
|
await module.load();
|
|
|
|
|
|
|
|
const report = new module.klass(module, this);
|
|
|
|
report.open(lot);
|
|
|
|
} catch(err) {
|
2019-09-06 12:54:50 +00:00
|
|
|
Htk.Toast.showError(_('Error loading report'));
|
2022-11-28 08:51:31 +00:00
|
|
|
} finally {
|
|
|
|
this.loaderPop();
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
2015-11-30 16:46:24 +00:00
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Supplant
|
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
,async supplantInit() {
|
2019-09-06 12:54:50 +00:00
|
|
|
var user = sessionStorage.getItem('supplantUser');
|
2022-11-28 08:51:31 +00:00
|
|
|
if (user == null) return;
|
2018-01-15 08:24:15 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
await this._conn.supplantUser(user);
|
2019-09-06 12:54:50 +00:00
|
|
|
sessionStorage.setItem('supplantUser', user);
|
2022-11-28 08:51:31 +00:00
|
|
|
await this.loadMenu();
|
2016-10-04 15:27:49 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
const res = await this._conn.execQuery(
|
|
|
|
'SELECT nickname FROM account.myUser');
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
const userName = res.fetchValue();
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.setText(this.$.supplanted, userName);
|
|
|
|
this.$.supplant.classList.toggle('show', true);
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
,async onSupplantExitClick() {
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.supplant.classList.toggle('show', false);
|
2022-11-28 08:51:31 +00:00
|
|
|
await this._conn.supplantEnd();
|
|
|
|
sessionStorage.removeItem('supplantUser');
|
|
|
|
await this.loadMenu();
|
2019-09-06 12:54:50 +00:00
|
|
|
this._onFormChange();
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
2015-12-02 17:26:58 +00:00
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Destroy
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,_destroy() {
|
2019-09-06 12:54:50 +00:00
|
|
|
this.hide();
|
2022-06-06 16:02:17 +00:00
|
|
|
Vn.Component.prototype.initialize.call(this);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
});
|