2015-11-17 10:34:33 +00:00
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
var Gui = require ('./gui');
|
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-11-17 10:34:33 +00:00
|
|
|
({
|
2017-03-23 16:20:51 +00:00
|
|
|
Extends: Htk.Component
|
2017-04-19 06:16:37 +00:00
|
|
|
,Properties: {
|
|
|
|
gui:
|
|
|
|
{
|
|
|
|
type: Gui
|
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
this._gui = x;
|
|
|
|
this.conn = x.conn;
|
|
|
|
this.hash = x.hash;
|
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._gui;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
formInfo:
|
|
|
|
{
|
|
|
|
type: Object,
|
|
|
|
value: null
|
|
|
|
}
|
|
|
|
}
|
2015-12-10 13:48:43 +00:00
|
|
|
|
|
|
|
,isOpen: false
|
|
|
|
,uiLoaded: false
|
|
|
|
|
|
|
|
,loadUi: function ()
|
2015-11-17 10:34:33 +00:00
|
|
|
{
|
2015-12-10 13:48:43 +00:00
|
|
|
if (!this.isOpen)
|
|
|
|
return;
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
var builder = new Vn.Builder ();
|
|
|
|
builder.signalData = this;
|
2015-11-19 13:57:23 +00:00
|
|
|
builder.add ('conn', this.conn);
|
2017-04-05 14:06:07 +00:00
|
|
|
builder.add ('hash', this.hash);
|
2015-11-17 10:34:33 +00:00
|
|
|
builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml');
|
2017-03-23 16:20:51 +00:00
|
|
|
|
|
|
|
var res = this.builderResultInit (builder);
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
var models = res.getByTagName ('db-model');
|
|
|
|
|
|
|
|
for (var i = 0; i < models.length; i++)
|
|
|
|
models[i].conn = this.conn;
|
|
|
|
|
|
|
|
var queries = res.getByTagName ('db-query');
|
|
|
|
|
|
|
|
for (var i = 0; i < queries.length; i++)
|
|
|
|
queries[i].conn = this.conn;
|
2017-03-23 16:20:51 +00:00
|
|
|
|
2015-12-10 13:48:43 +00:00
|
|
|
if (this.node)
|
|
|
|
{
|
2015-12-15 15:22:46 +00:00
|
|
|
this.gui.setForm (this.node);
|
2015-12-10 13:48:43 +00:00
|
|
|
this.gui.setTitle (res.$('title'));
|
|
|
|
this.gui.setActions (res.$('actions'));
|
|
|
|
this.activate ();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.uiLoaded = true;
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
|
|
|
|
2015-12-10 13:48:43 +00:00
|
|
|
,unloadUi: function ()
|
2015-11-17 10:34:33 +00:00
|
|
|
{
|
2015-12-10 13:48:43 +00:00
|
|
|
if (!this.uiLoaded)
|
|
|
|
return;
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
if (this.node)
|
|
|
|
{
|
2015-12-10 13:48:43 +00:00
|
|
|
this.deactivate ();
|
2015-11-17 10:34:33 +00:00
|
|
|
this.gui.setTitle (null);
|
|
|
|
this.gui.setActions (null);
|
2017-03-17 12:42:10 +00:00
|
|
|
this.gui.setForm (null);
|
2015-12-10 13:48:43 +00:00
|
|
|
this.deactivate ();
|
2015-11-17 10:34:33 +00:00
|
|
|
this.node = null;
|
|
|
|
}
|
|
|
|
if (this.builder)
|
|
|
|
{
|
|
|
|
this.builder.unref ();
|
|
|
|
this.builder = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-10 13:48:43 +00:00
|
|
|
/**
|
|
|
|
* Called when the form is opened.
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2015-12-10 13:48:43 +00:00
|
|
|
,open: function ()
|
|
|
|
{
|
|
|
|
this.close ();
|
|
|
|
this.isOpen = true;
|
|
|
|
this.loadUi ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the form is closed.
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2015-12-10 13:48:43 +00:00
|
|
|
,close: function ()
|
|
|
|
{
|
|
|
|
if (!this.isOpen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.isOpen = false;
|
|
|
|
this.unloadUi ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the form is activated.
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2015-12-10 13:48:43 +00:00
|
|
|
,activate: function () {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the form is deactivated.
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2015-12-10 13:48:43 +00:00
|
|
|
,deactivate: function () {}
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
,_destroy: function ()
|
|
|
|
{
|
|
|
|
this.close ();
|
|
|
|
this.parent ();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|