2015-09-11 09:37:16 +00:00
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
var Tpl = require ('./gui.xml');
|
2017-04-19 06:16:37 +00:00
|
|
|
var Module = require ('./module');
|
|
|
|
var Form = require ('./form');
|
2015-09-25 00:53:59 +00:00
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
require ('./gui.css');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main screen component. It has a left menu, a navbar with configurable
|
|
|
|
* action buttons and the body where @Db.Form childs can be displayed.
|
|
|
|
*/
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-09-11 09:37:16 +00:00
|
|
|
({
|
2016-10-16 14:16:08 +00:00
|
|
|
Extends: Htk.Component,
|
2015-09-11 09:37:16 +00:00
|
|
|
Properties:
|
|
|
|
{
|
2017-04-19 06:16:37 +00:00
|
|
|
/**
|
|
|
|
* The main connection object.
|
|
|
|
*/
|
2015-09-11 09:37:16 +00:00
|
|
|
conn:
|
|
|
|
{
|
2016-09-24 14:32:31 +00:00
|
|
|
type: Db.Connection
|
2015-12-10 13:48:43 +00:00
|
|
|
,set: function (x)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2016-10-14 10:58:35 +00:00
|
|
|
this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange });
|
2015-12-10 13:48:43 +00:00
|
|
|
}
|
|
|
|
,get: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
|
|
|
return this._conn;
|
|
|
|
}
|
2017-04-19 06:16:37 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* The current open form.
|
|
|
|
*/
|
|
|
|
activeForm:
|
|
|
|
{
|
|
|
|
type: Form
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._activeForm;
|
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
,_forms: {}
|
|
|
|
,_activeForm: 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
|
|
|
|
|
|
|
,initialize: function (props)
|
|
|
|
{
|
2016-09-26 09:28:47 +00:00
|
|
|
this.builderInitString (Tpl);
|
2015-09-11 09:37:16 +00:00
|
|
|
this.loadingCount = 0;
|
|
|
|
|
|
|
|
this.$('background').onclick = function () {};
|
|
|
|
|
|
|
|
this.$('menu-button').addEventListener ('click', function (event)
|
|
|
|
{
|
|
|
|
event.stopPropagation ();
|
|
|
|
this.showMenu ();
|
|
|
|
}.bind (this));
|
|
|
|
|
|
|
|
this.$('left-panel').addEventListener ('click', function (event)
|
|
|
|
{
|
|
|
|
event.stopPropagation ();
|
|
|
|
});
|
2015-12-02 17:26:58 +00:00
|
|
|
|
2015-12-10 13:48:43 +00:00
|
|
|
this.parent (props);
|
2016-10-14 10:58:35 +00:00
|
|
|
|
|
|
|
this.$('social-bar').conn = this._conn;
|
|
|
|
|
|
|
|
var sql = 'SELECT name FROM customer_user;'
|
|
|
|
+'SELECT default_form, image_dir, image_host FROM config;'
|
|
|
|
+'SELECT production_domain, test_domain FROM config;';
|
|
|
|
this._conn.execQuery (sql, this.onMainQueryDone.bind (this));
|
|
|
|
|
|
|
|
this.loadMenu ();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,show: function ()
|
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
if (this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._shown = true;
|
2016-10-18 21:54:52 +00:00
|
|
|
this.doc.body.appendChild (this.node);
|
2016-10-30 22:48:18 +00:00
|
|
|
Htk.Toast.pushTop (this.$('form-holder'));
|
2015-12-19 15:42:38 +00:00
|
|
|
|
|
|
|
if (Vn.isMobile ())
|
|
|
|
{
|
|
|
|
this._onScrollHandler = this._onScroll.bind (this);
|
2017-04-08 11:42:27 +00:00
|
|
|
window.addEventListener ('scroll', this._onScrollHandler);
|
2015-12-19 15:42:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 14:06:07 +00:00
|
|
|
this.formParam = new Vn.Param ({
|
|
|
|
lot: this.hash,
|
2017-04-07 11:00:33 +00:00
|
|
|
name: 'form',
|
2017-04-05 14:06:07 +00:00
|
|
|
});
|
2015-12-19 15:42:38 +00:00
|
|
|
this.formParam.on ('changed', this._onFormChange, this);
|
2017-04-05 14:06:07 +00:00
|
|
|
|
2016-09-23 22:47:34 +00:00
|
|
|
if (!localStorage.getItem ('hederaCookies'))
|
2015-12-19 15:42:38 +00:00
|
|
|
{
|
2016-09-23 22:47:34 +00:00
|
|
|
localStorage.setItem ('hederaCookies', true);
|
2015-12-19 15:42:38 +00:00
|
|
|
Htk.Toast.showWarning (_('By using this site you accept cookies'));
|
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,hide: function ()
|
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._shown = false;
|
|
|
|
|
|
|
|
if (Vn.isMobile ())
|
|
|
|
window.removeEventListener ('scroll', this._onScrollHandler);
|
|
|
|
|
2016-10-30 22:48:18 +00:00
|
|
|
Htk.Toast.popTop ();
|
2015-12-19 15:42:38 +00:00
|
|
|
this.formParam.unref ();
|
2015-09-16 16:11:15 +00:00
|
|
|
this.closeForm ();
|
2015-12-10 23:24:14 +00:00
|
|
|
this.hideMenu ();
|
2015-09-11 09:37:16 +00:00
|
|
|
Vn.Node.remove (this.node);
|
|
|
|
}
|
|
|
|
|
2015-12-15 15:22:46 +00:00
|
|
|
,logout: function ()
|
|
|
|
{
|
|
|
|
this.onLogoutClick ();
|
|
|
|
}
|
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
,onLogoutClick: function ()
|
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
this._conn.close (this._onConnClose.bind (this));
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-19 15:42:38 +00:00
|
|
|
,_onConnClose: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2017-04-19 06:16:37 +00:00
|
|
|
this.emit ('logout');
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-19 15:42:38 +00:00
|
|
|
,_onConnLoadChange: function (conn, isLoading)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
if (isLoading)
|
|
|
|
this.loaderPush ();
|
|
|
|
else
|
|
|
|
this.loaderPop ();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onMainQueryDone: function (resultSet)
|
|
|
|
{
|
2016-10-04 15:27:49 +00:00
|
|
|
// Retrieving the user name
|
|
|
|
|
|
|
|
var userName = resultSet.fetchValue ();
|
|
|
|
Vn.Node.setText (this.$('user-name'), userName);
|
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2017-04-08 11:42:27 +00:00
|
|
|
Object.assign (Vn.Config, resultSet.fetchObject ());
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
2017-04-08 11:42:27 +00:00
|
|
|
var row = resultSet.fetchObject ();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2017-04-08 11:42:27 +00:00
|
|
|
if (row && row.test_domain)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2017-04-08 11:42:27 +00:00
|
|
|
if (location.host != row.production_domain)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
|
|
|
var linkText = 'ReturnToOldWebsite';
|
|
|
|
var linkField = 'production_domain';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var linkText = 'TestTheNewWebsite';
|
|
|
|
var linkField = 'test_domain';
|
|
|
|
}
|
|
|
|
|
|
|
|
Vn.Node.setText (this.$('test-link'), _(linkText));
|
2017-04-08 11:42:27 +00:00
|
|
|
this.$('test-link').href = '//'+ row[linkField];
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Vn.Node.hide (this.$('test-link'));
|
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
// Loading the default form
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
this._onFormChange ();
|
|
|
|
}
|
|
|
|
|
|
|
|
,loadMenu: function ()
|
|
|
|
{
|
|
|
|
var sql = 'CALL form_list ()';
|
|
|
|
this._conn.execQuery (sql, this._onMenuLoad.bind (this));
|
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
,_onMenuLoad: function (resultSet)
|
|
|
|
{
|
2015-09-11 09:37:16 +00:00
|
|
|
// Retrieving menu sections
|
|
|
|
|
2017-04-08 11:42:27 +00:00
|
|
|
var row;
|
2015-09-11 09:37:16 +00:00
|
|
|
var res = resultSet.fetchResult ();
|
|
|
|
var sectionMap = {};
|
|
|
|
|
|
|
|
if (res)
|
2017-04-08 11:42:27 +00:00
|
|
|
for (var i = 0; row = res.fetchObject (); i++)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2017-04-08 11:42:27 +00:00
|
|
|
var parent = row.parent;
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (!sectionMap[parent])
|
|
|
|
sectionMap[parent] = [];
|
|
|
|
|
|
|
|
sectionMap[parent].push (i);
|
|
|
|
}
|
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
Vn.Node.removeChilds (this.$('main-menu'));
|
2015-09-11 09:37:16 +00:00
|
|
|
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
|
|
|
|
|
|
|
,createMenu: function (res, sectionMap, parent, ul)
|
|
|
|
{
|
|
|
|
var sections = sectionMap[parent];
|
|
|
|
|
|
|
|
for (var i = 0; i < sections.length; i++)
|
|
|
|
{
|
|
|
|
res.row = sections[i];
|
2017-04-08 11:42:27 +00:00
|
|
|
var row = res.getObject ();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2016-10-18 21:54:52 +00:00
|
|
|
var li = this.createElement ('li');
|
2015-09-11 09:37:16 +00:00
|
|
|
ul.appendChild (li);
|
2016-10-18 21:54:52 +00:00
|
|
|
|
2017-04-08 11:42:27 +00:00
|
|
|
var text = this.createTextNode (_(row.description));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2016-10-18 21:54:52 +00:00
|
|
|
var a = this.createElement ('a');
|
2017-03-30 11:44:53 +00:00
|
|
|
a.className = 'clickable';
|
2016-10-18 21:54:52 +00:00
|
|
|
|
2017-04-08 11:42:27 +00:00
|
|
|
if (row.path)
|
2016-10-18 21:54:52 +00:00
|
|
|
{
|
2017-04-08 11:42:27 +00:00
|
|
|
a.href = this.hash.make ({'form': row.path});
|
2017-04-19 06:16:37 +00:00
|
|
|
this._menuOptions[row.path] = a;
|
2016-10-18 21:54:52 +00:00
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
a.appendChild (text);
|
2016-10-18 21:54:52 +00:00
|
|
|
li.appendChild (a);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2017-04-08 11:42:27 +00:00
|
|
|
var formId = row.id;
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (sectionMap[formId])
|
|
|
|
{
|
2016-10-18 21:54:52 +00:00
|
|
|
var submenu = this.createElement ('ul');
|
2015-09-11 09:37:16 +00:00
|
|
|
submenu.className = 'submenu';
|
|
|
|
li.appendChild (submenu);
|
|
|
|
|
|
|
|
li.addEventListener ('mouseover',
|
2015-12-02 17:26:58 +00:00
|
|
|
this._onLiMouseHover.bind (this, submenu, a));
|
2015-09-11 09:37:16 +00:00
|
|
|
li.addEventListener ('mouseout',
|
2015-12-02 17:26:58 +00:00
|
|
|
this._onLiMouseOut.bind (this));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
this.createMenu (res, sectionMap, formId, submenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
,_onLiMouseHover: function (submenu, parent)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2017-04-19 06:16:37 +00:00
|
|
|
if (this._menuShown)
|
2015-09-11 09:37:16 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
this.hideSubmenu ();
|
|
|
|
this.activeSubmenu = submenu;
|
|
|
|
|
|
|
|
var rect = parent.getBoundingClientRect ();
|
2016-10-18 21:54:52 +00:00
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
,_onLiMouseOut: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
|
|
|
this.timeout = setTimeout (this.hideSubmenu.bind (this), 160);
|
|
|
|
}
|
|
|
|
|
|
|
|
,hideSubmenu: function ()
|
|
|
|
{
|
|
|
|
var submenu = this.activeSubmenu;
|
|
|
|
|
|
|
|
if (submenu)
|
|
|
|
{
|
2016-10-18 21:54:52 +00:00
|
|
|
Vn.Node.removeClass (submenu, 'popup');
|
|
|
|
submenu.style.left = '';
|
|
|
|
submenu.style.top = '';
|
2015-09-11 09:37:16 +00:00
|
|
|
clearTimeout (this.timeout);
|
|
|
|
this.activeSubmenu = null;
|
|
|
|
this.timeout = 0;
|
|
|
|
}
|
|
|
|
}
|
2016-10-04 15:27:49 +00:00
|
|
|
|
|
|
|
,showMenu: function ()
|
|
|
|
{
|
|
|
|
this.showBackground ();
|
|
|
|
Vn.Node.addClass (this.$('left-panel'), 'show');
|
2017-04-19 06:16:37 +00:00
|
|
|
this._menuShown = true;
|
2016-10-04 15:27:49 +00:00
|
|
|
|
|
|
|
this.hideMenuCallback = this.hideMenu.bind (this);
|
2016-10-18 21:54:52 +00:00
|
|
|
this.doc.addEventListener ('click', this.hideMenuCallback);
|
2016-10-04 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,hideMenu: function ()
|
|
|
|
{
|
2017-04-19 06:16:37 +00:00
|
|
|
if (!this._menuShown)
|
2016-10-04 15:27:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
this.hideBackground ();
|
|
|
|
Vn.Node.removeClass (this.$('left-panel'), 'show');
|
2017-04-19 06:16:37 +00:00
|
|
|
this._menuShown = false;
|
2016-10-04 15:27:49 +00:00
|
|
|
|
2016-10-18 21:54:52 +00:00
|
|
|
this.doc.removeEventListener ('click', this.hideMenuCallback);
|
2016-10-04 15:27:49 +00:00
|
|
|
this.hideMenuCallback = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Navigation bar
|
|
|
|
|
|
|
|
,_onScroll: function ()
|
|
|
|
{
|
|
|
|
if (this._scrollTimeout === null)
|
|
|
|
this._scrollTimeout = setTimeout (
|
|
|
|
this._scrollTimeoutFunc.bind (this), 150);
|
|
|
|
}
|
|
|
|
|
|
|
|
,_scrollTimeoutFunc: function ()
|
|
|
|
{
|
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var navbar = this.$('top-bar');
|
2017-04-08 11:42:27 +00:00
|
|
|
var yOffset = window.pageYOffset;
|
2016-10-04 15:27:49 +00:00
|
|
|
var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight;
|
|
|
|
|
|
|
|
if (showNavbar !== this._navbarVisible)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
,showBackground: function ()
|
|
|
|
{
|
|
|
|
Vn.Node.addClass (this.$('background'), 'show');
|
|
|
|
}
|
|
|
|
|
|
|
|
,hideBackground: function ()
|
|
|
|
{
|
|
|
|
Vn.Node.removeClass (this.$('background'), 'show');
|
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner
|
|
|
|
|
|
|
|
,loaderPush: function ()
|
|
|
|
{
|
|
|
|
this.loadingCount++;
|
|
|
|
|
|
|
|
if (this.loadingCount == 1)
|
|
|
|
this.$('loader').start ();
|
|
|
|
}
|
|
|
|
|
|
|
|
,loaderPop: function ()
|
|
|
|
{
|
|
|
|
if (this.loadingCount == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.loadingCount--;
|
|
|
|
|
|
|
|
if (this.loadingCount == 0)
|
|
|
|
this.$('loader').stop ();
|
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
,_onFormChange: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
var formPath = this.formParam.value;
|
2017-04-05 14:06:07 +00:00
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
if (!formPath)
|
|
|
|
formPath = Vn.Config['default_form'];
|
|
|
|
|
|
|
|
this.openForm (formPath,
|
|
|
|
this._onFormLoad.bind (this));
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,openForm: function (formPath, callback)
|
|
|
|
{
|
|
|
|
this.hideMenu ();
|
|
|
|
this.loaderPush ();
|
2015-09-16 16:11:15 +00:00
|
|
|
|
|
|
|
this.closeForm ();
|
2017-04-19 06:16:37 +00:00
|
|
|
this._requestedForm = formPath;
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
var newChoosedOption = this._menuOptions[formPath];
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
if (newChoosedOption)
|
|
|
|
{
|
|
|
|
Vn.Node.addClass (newChoosedOption, 'selected');
|
2017-04-19 06:16:37 +00:00
|
|
|
this._choosedOption = newChoosedOption;
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
var formInfo = this._forms[formPath];
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (!formInfo)
|
|
|
|
{
|
2016-09-26 09:28:47 +00:00
|
|
|
formInfo = new Module ('forms', formPath);
|
2017-04-19 06:16:37 +00:00
|
|
|
this._forms[formPath] = formInfo;
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 16:20:51 +00:00
|
|
|
formInfo.load (callback);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
,_onFormLoad: function (formInfo)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-11-17 10:34:33 +00:00
|
|
|
this.loaderPop ();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
if (formInfo.error)
|
|
|
|
{
|
|
|
|
Htk.Toast.showError (_('Error loading form'));
|
2015-09-11 09:37:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
this._activeForm = new formInfo.klass ({
|
|
|
|
gui: this,
|
|
|
|
formInfo: formInfo
|
|
|
|
});
|
|
|
|
this._activeForm.open ();
|
2015-12-15 15:22:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,setForm: function (form)
|
|
|
|
{
|
|
|
|
Vn.Node.removeChilds (this.$('form-holder'));
|
|
|
|
|
|
|
|
if (form)
|
|
|
|
{
|
2017-03-17 12:42:10 +00:00
|
|
|
var div = this.createElement('div');
|
|
|
|
div.appendChild (form);
|
|
|
|
|
|
|
|
this.$('form-holder').appendChild (div);
|
2017-03-22 16:57:21 +00:00
|
|
|
setTimeout (this._onSetFormTimeout.bind (this), 10);
|
2015-12-15 15:22:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_onSetFormTimeout: function ()
|
|
|
|
{
|
2017-03-17 12:42:10 +00:00
|
|
|
Vn.Node.addClass (this.$('form-holder').firstChild, 'slide');
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,setTitle: function (title)
|
|
|
|
{
|
2016-12-20 09:32:17 +00:00
|
|
|
Vn.Node.setChild (this.$('title'), title);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,setActions: function (actions)
|
|
|
|
{
|
2016-12-20 09:32:17 +00:00
|
|
|
Vn.Node.setChild (this.$('action-bar'), actions);
|
2015-09-16 16:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,closeForm: function ()
|
|
|
|
{
|
2017-04-19 06:16:37 +00:00
|
|
|
if (this._activeForm)
|
2015-09-16 16:11:15 +00:00
|
|
|
{
|
2017-04-19 06:16:37 +00:00
|
|
|
this._activeForm.formInfo.unload ();
|
|
|
|
this._activeForm.close ();
|
|
|
|
this._activeForm.unref ();
|
|
|
|
this._activeForm = null;
|
2015-09-16 16:11:15 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
if (this._choosedOption)
|
2015-11-17 10:34:33 +00:00
|
|
|
{
|
2017-04-19 06:16:37 +00:00
|
|
|
Vn.Node.removeClass (this._choosedOption, 'selected');
|
|
|
|
this._choosedOption = null;
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 16:20:51 +00:00
|
|
|
,openReport: function (reportName, params)
|
2015-11-17 10:34:33 +00:00
|
|
|
{
|
2017-03-23 16:20:51 +00:00
|
|
|
var hashParams = {
|
|
|
|
form: 'preview',
|
|
|
|
report: reportName
|
|
|
|
};
|
2017-04-08 11:42:27 +00:00
|
|
|
this.hash.params = Object.assign (hashParams, params);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
2017-03-23 16:20:51 +00:00
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Supplant
|
2017-03-23 16:20:51 +00:00
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
,supplantUser: function (user, callback)
|
2015-11-30 16:46:24 +00:00
|
|
|
{
|
2016-10-04 15:27:49 +00:00
|
|
|
this._conn.supplantUser (user,
|
|
|
|
this._onUserSupplant.bind (this, callback));
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
,_onUserSupplant: function (callback, supplantOk)
|
2015-11-30 16:46:24 +00:00
|
|
|
{
|
2016-10-04 15:27:49 +00:00
|
|
|
if (!supplantOk)
|
|
|
|
return;
|
2015-11-30 16:46:24 +00:00
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
this.loadMenu ();
|
|
|
|
|
|
|
|
var sql = 'SELECT name FROM customer_user';
|
|
|
|
this._conn.execQuery (sql, this._onSupplantName.bind (this));
|
2015-11-30 16:46:24 +00:00
|
|
|
|
|
|
|
if (callback)
|
|
|
|
callback ();
|
|
|
|
}
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
,_onSupplantName: function (resultSet)
|
2015-11-30 16:46:24 +00:00
|
|
|
{
|
2016-10-04 15:27:49 +00:00
|
|
|
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
|
|
|
|
2016-10-04 15:27:49 +00:00
|
|
|
,onSupplantExitClick: function ()
|
2015-11-30 16:46:24 +00:00
|
|
|
{
|
2016-10-04 15:27:49 +00:00
|
|
|
Vn.Node.hide (this.$('supplant'));
|
|
|
|
this._conn.supplantEnd ();
|
|
|
|
this.loadMenu ();
|
2015-11-30 16:46:24 +00:00
|
|
|
this._onFormChange ();
|
|
|
|
}
|
2015-12-02 17:26:58 +00:00
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Destroy
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
,_destroy: function ()
|
|
|
|
{
|
2015-09-16 16:11:15 +00:00
|
|
|
this.hide ();
|
2015-09-11 09:37:16 +00:00
|
|
|
this.parent ();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|