2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var Module = require('./module');
|
|
|
|
var Tpl = require('./gui.xml');
|
2015-09-25 00:53:59 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
require('./gui.css');
|
2018-05-11 09:25:10 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
module.exports = new Class({
|
2016-10-16 14:16:08 +00:00
|
|
|
Extends: Htk.Component,
|
2019-09-06 12:54:50 +00:00
|
|
|
Properties: {
|
|
|
|
conn: {
|
2016-09-24 14:32:31 +00:00
|
|
|
type: Db.Connection
|
2019-09-06 12:54:50 +00:00
|
|
|
,set: function(x) {
|
|
|
|
this.link({_conn: x}, {'loading-changed': this._onConnLoadChange });
|
2015-12-10 13:48:43 +00:00
|
|
|
}
|
2019-09-06 12:54:50 +00:00
|
|
|
,get: function() {
|
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
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,initialize: function(props) {
|
|
|
|
this.builderInitString(Tpl);
|
2015-09-11 09:37:16 +00:00
|
|
|
this.loadingCount = 0;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.$('background').onclick = function() {};
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.$('menu-button').addEventListener('click', function(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
this.showMenu();
|
|
|
|
}.bind(this));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.$('left-panel').addEventListener('click', function(event) {
|
|
|
|
event.stopPropagation();
|
2015-09-11 09:37:16 +00:00
|
|
|
});
|
2015-12-02 17:26:58 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.parent(props);
|
2016-10-14 10:58:35 +00:00
|
|
|
|
|
|
|
this.$('social-bar').conn = this._conn;
|
|
|
|
|
2018-05-11 09:25:10 +00:00
|
|
|
var sql = 'SELECT nickname FROM account.myUser;'
|
|
|
|
+'SELECT defaultForm FROM config;'
|
2017-12-20 11:34:04 +00:00
|
|
|
+'SELECT url FROM imageConfig;'
|
2018-01-17 14:00:13 +00:00
|
|
|
+'SELECT dbproduccion FROM vn2008.tblContadores;'
|
2018-05-11 09:25:10 +00:00
|
|
|
+'SELECT productionDomain, testDomain FROM config;';
|
2019-09-06 12:54:50 +00:00
|
|
|
this._conn.execQuery(sql, this.onMainQueryDone.bind(this));
|
2016-10-14 10:58:35 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.loadMenu();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,show: function() {
|
2015-12-19 15:42:38 +00:00
|
|
|
if (this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._shown = true;
|
2019-09-06 12:54:50 +00:00
|
|
|
this.doc.body.appendChild(this.node);
|
|
|
|
Htk.Toast.pushTop(this.$('form-holder'));
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (Vn.isMobile()) {
|
|
|
|
this._onScrollHandler = this._onScroll.bind(this);
|
|
|
|
window.addEventListener('scroll', this._onScrollHandler );
|
2015-12-19 15:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.hash = Vn.Hash;
|
2019-09-06 12:54:50 +00:00
|
|
|
this.formParam = new Vn.HashParam({key: 'form'});
|
|
|
|
this.formParam.on('changed', this._onFormChange, this);
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (!localStorage.getItem('hederaCookies')) {
|
|
|
|
localStorage.setItem('hederaCookies', true);
|
|
|
|
Htk.Toast.showWarning(_('By using this site you accept cookies'));
|
2015-12-19 15:42:38 +00:00
|
|
|
}
|
2018-01-15 08:24:15 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.supplantInit();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,hide: function() {
|
2015-12-19 15:42:38 +00:00
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._shown = false;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (Vn.isMobile())
|
|
|
|
window.removeEventListener('scroll', this._onScrollHandler);
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
Htk.Toast.popTop();
|
|
|
|
this.formParam.unref();
|
|
|
|
this.closeForm();
|
|
|
|
this.hideMenu();
|
|
|
|
Vn.Node.remove(this.node);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,logout: function() {
|
|
|
|
this.onLogoutClick();
|
2015-12-15 15:22:46 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,onLogoutClick: function() {
|
|
|
|
this._conn.close(this._onConnClose.bind(this));
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onConnClose: function() {
|
|
|
|
this.signalEmit('logout');
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onConnLoadChange: function(conn, isLoading) {
|
2015-12-19 15:42:38 +00:00
|
|
|
if (isLoading)
|
2019-09-06 12:54:50 +00:00
|
|
|
this.loaderPush();
|
2015-12-19 15:42:38 +00:00
|
|
|
else
|
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
|
|
|
,onMainQueryDone: function(resultSet) {
|
2016-10-04 15:27:49 +00:00
|
|
|
// Retrieving the user name
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var userName = resultSet.fetchValue();
|
|
|
|
Vn.Node.setText(this.$('user-name'), userName);
|
2016-10-04 15:27:49 +00:00
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var res = resultSet.fetchResult();
|
2015-09-11 09:37:16 +00:00
|
|
|
var columns = res.columns;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (res.next())
|
2015-09-11 09:37:16 +00:00
|
|
|
for (var i = 0; i < res.columns.length; i++)
|
2019-09-06 12:54:50 +00:00
|
|
|
Vn.Config[columns[i].name] = res.get(columns[i].name);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
Vn.Config.imageUrl = resultSet.fetchValue();
|
2017-12-20 11:34:04 +00:00
|
|
|
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var isTesting = !resultSet.fetchValue();
|
2018-01-17 14:00:13 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (isTesting) {
|
2018-01-17 14:00:13 +00:00
|
|
|
this.$('dev-info').style.display = 'block';
|
2019-09-06 12:54:50 +00:00
|
|
|
this.$('version').textContent = Vn.Cookie.get('vnVersion');
|
2018-01-17 14:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var res = resultSet.fetchResult();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (res.next() && res.get('testDomain')) {
|
|
|
|
if (location.host != res.get('productionDomain')) {
|
2018-01-17 14:00:13 +00:00
|
|
|
var linkText = 'Old website';
|
2018-05-11 09:25:10 +00:00
|
|
|
var linkField = 'productionDomain';
|
2019-09-06 12:54:50 +00:00
|
|
|
} else {
|
2018-01-17 14:00:13 +00:00
|
|
|
var linkText = 'Test the new website';
|
2018-05-11 09:25:10 +00:00
|
|
|
var linkField = 'testDomain';
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
Vn.Node.setText(this.$('test-link'), _(linkText));
|
|
|
|
this.$('test-link').href = '//'+ res.get(linkField);
|
2018-01-17 14:00:13 +00:00
|
|
|
this.$('test-link').style.display = 'block';
|
2019-09-06 12:54:50 +00:00
|
|
|
} else
|
2018-01-17 14:00:13 +00:00
|
|
|
this.$('test-link').style.display = 'none';
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
// Loading the default form
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this._onFormChange();
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,loadMenu: function() {
|
2017-12-20 11:34:04 +00:00
|
|
|
var sql = 'SELECT * FROM myMenu';
|
2019-09-06 12:54:50 +00:00
|
|
|
this._conn.execQuery(sql, this._onMenuLoad.bind(this));
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onMenuLoad: function(resultSet) {
|
2015-09-11 09:37:16 +00:00
|
|
|
// Retrieving menu sections
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var res = resultSet.fetchResult();
|
2015-09-11 09:37:16 +00:00
|
|
|
var sectionMap = {};
|
|
|
|
|
|
|
|
if (res)
|
2019-09-06 12:54:50 +00:00
|
|
|
for (var i = 0; res.next(); i++) {
|
|
|
|
var parent = res.get('parentFk');
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (!sectionMap[parent])
|
|
|
|
sectionMap[parent] = [];
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
sectionMap[parent].push(i);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
Vn.Node.removeChilds(this.$('main-menu'));
|
|
|
|
this.createMenu(res, sectionMap, null, this.$('main-menu'));
|
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
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,createMenu: function(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];
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var li = this.createElement('li');
|
|
|
|
ul.appendChild(li);
|
2016-10-18 21:54:52 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var text = this.createTextNode(_(res.get('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
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (res.get('path')) {
|
|
|
|
a.href = Vn.Hash.make({'form': res.get('path')});
|
|
|
|
this.menuOptions[res.get('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
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var formId = res.get('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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onLiMouseHover: function(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';
|
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onLiMouseOut: function() {
|
|
|
|
this.timeout = setTimeout(this.hideSubmenu.bind(this), 160);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,hideSubmenu: function() {
|
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
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,showMenu: function() {
|
|
|
|
this.showBackground();
|
|
|
|
Vn.Node.addClass(this.$('left-panel'), '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
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,hideMenu: function() {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (!this.menuShown)
|
|
|
|
return;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.hideBackground();
|
|
|
|
Vn.Node.removeClass(this.$('left-panel'), '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
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onScroll: function() {
|
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
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_scrollTimeoutFunc: function() {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var navbar = this.$('top-bar');
|
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
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,showBackground: function() {
|
|
|
|
Vn.Node.addClass(this.$('background'), 'show');
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,hideBackground: function() {
|
|
|
|
Vn.Node.removeClass(this.$('background'), 'show');
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,loaderPush: function() {
|
2016-10-04 15:27:49 +00:00
|
|
|
this.loadingCount++;
|
|
|
|
|
|
|
|
if (this.loadingCount == 1)
|
2019-09-06 12:54:50 +00:00
|
|
|
this.$('loader').start();
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,loaderPop: function() {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (this.loadingCount == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.loadingCount--;
|
|
|
|
|
|
|
|
if (this.loadingCount == 0)
|
2019-09-06 12:54:50 +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
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onFormChange: function() {
|
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.openForm(formPath,
|
|
|
|
this._onFormLoad.bind(this));
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,openForm: function(formPath, callback) {
|
|
|
|
this.hideMenu();
|
|
|
|
this.loaderPush();
|
2015-09-16 16:11:15 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.closeForm();
|
2015-09-11 09:37:16 +00:00
|
|
|
this.requestedForm = formPath;
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
var newChoosedOption = this.menuOptions[formPath];
|
|
|
|
|
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
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
this.activeCss = 'forms/'+ formPath +'/style.css';
|
2019-09-06 12:54:50 +00:00
|
|
|
Vn.includeCss(this.activeCss);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
var formInfo = this.forms[formPath];
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (!formInfo) {
|
|
|
|
formInfo = new Module('forms', formPath);
|
2015-09-11 09:37:16 +00:00
|
|
|
this.forms[formPath] = formInfo;
|
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
formInfo.addCallback(callback);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onFormLoad: function(formInfo) {
|
|
|
|
this.loaderPop();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (formInfo.error)
|
|
|
|
return Htk.Toast.showError(_('Error loading form'));
|
|
|
|
if (!this._shown)
|
2015-09-11 09:37:16 +00:00
|
|
|
return;
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
this.activeForm = new formInfo.klass(this, formInfo);
|
|
|
|
this.activeForm.open();
|
2015-12-15 15:22:46 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,setForm: function(form) {
|
|
|
|
Vn.Node.removeChilds(this.$('form-holder'));
|
2015-12-15 15:22:46 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (form) {
|
|
|
|
this.$('form-holder').appendChild(form);
|
|
|
|
setTimeout(this._onSetFormTimeout.bind(this), 0);
|
2015-12-15 15:22:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onSetFormTimeout: function() {
|
|
|
|
Vn.Node.addClass(this.$('form-holder'), 'show');
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,setTitle: function(title) {
|
|
|
|
Vn.Node.removeChilds(this.$('title'));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (title)
|
2019-09-06 12:54:50 +00:00
|
|
|
this.$('title').appendChild(title);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,setActions: function(actions) {
|
|
|
|
Vn.Node.removeChilds(this.$('action-bar'));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (actions)
|
2019-09-06 12:54:50 +00:00
|
|
|
this.$('action-bar').appendChild(actions);
|
2015-09-16 16:11:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,closeForm: function() {
|
|
|
|
if (this.activeForm) {
|
|
|
|
Vn.Node.removeClass(this.$('form-holder'), 'show');
|
|
|
|
this.activeForm.close();
|
|
|
|
this.activeForm.unref();
|
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
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,openReport: function(reportName, batch) {
|
|
|
|
this.loaderPush();
|
2015-11-17 10:34:33 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var module = new Module('reports', reportName);
|
|
|
|
module.addCallback(this._onReportLoad.bind(this, batch));
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onReportLoad: function(batch, module) {
|
|
|
|
this.loaderPop();
|
2015-11-17 10:34:33 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
if (module.error) {
|
|
|
|
Htk.Toast.showError(_('Error loading report'));
|
2015-11-17 10:34:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
var report = new module.klass(module, this);
|
|
|
|
report.open(batch);
|
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
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,supplantInit: function() {
|
|
|
|
var user = sessionStorage.getItem('supplantUser');
|
2018-01-15 08:24:15 +00:00
|
|
|
|
|
|
|
if (user != null)
|
2019-09-06 12:54:50 +00:00
|
|
|
this.supplantUser(user);
|
2018-01-15 08:24:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,supplantUser: function(user, callback) {
|
|
|
|
this._conn.supplantUser(user,
|
|
|
|
this._onUserSupplant.bind(this, callback, user));
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onUserSupplant: function(callback, user, supplantOk) {
|
2016-10-04 15:27:49 +00:00
|
|
|
if (!supplantOk)
|
|
|
|
return;
|
2015-11-30 16:46:24 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
sessionStorage.setItem('supplantUser', user);
|
|
|
|
this.loadMenu();
|
2016-10-04 15:27:49 +00:00
|
|
|
|
2018-05-11 09:25:10 +00:00
|
|
|
var sql = 'SELECT nickname FROM account.myUser';
|
2019-09-06 12:54:50 +00:00
|
|
|
this._conn.execQuery(sql, this._onSupplantName.bind(this));
|
2015-11-30 16:46:24 +00:00
|
|
|
|
|
|
|
if (callback)
|
2019-09-06 12:54:50 +00:00
|
|
|
callback();
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_onSupplantName: function(resultSet) {
|
|
|
|
var userName = resultSet.fetchValue();
|
|
|
|
Vn.Node.setText(this.$('supplanted'), userName);
|
|
|
|
Vn.Node.show(this.$('supplant'));
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,onSupplantExitClick: function() {
|
|
|
|
Vn.Node.hide(this.$('supplant'));
|
|
|
|
this._conn.supplantEnd();
|
|
|
|
sessionStorage.removeItem('supplantUser',
|
|
|
|
sessionStorage.getItem('supplantUser'));
|
|
|
|
this.loadMenu();
|
|
|
|
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
|
|
|
|
2019-09-06 12:54:50 +00:00
|
|
|
,_destroy: function() {
|
|
|
|
this.hide();
|
|
|
|
this.parent();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|