0
1
Fork 0
hedera-web-mindshore/js/hedera/form.js

112 lines
1.8 KiB
JavaScript

module.exports = new Class
({
Extends: Htk.Component
,isOpen: false
,uiLoaded: false
,initialize: function (gui, formInfo)
{
this.gui = gui;
this.conn = gui.conn;
this.hash = gui.hash;
this.formInfo = formInfo;
this.parent ();
}
,loadUi: function ()
{
if (!this.isOpen)
return;
var builder = new Vn.Builder ();
builder.signalData = this;
builder.add ('conn', this.conn);
builder.add ('hash', this.hash);
builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml');
var res = this.builderResultInit (builder);
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;
if (this.node)
{
this.gui.setForm (this.node);
this.gui.setTitle (res.$('title'));
this.gui.setActions (res.$('actions'));
this.activate ();
}
this.uiLoaded = true;
}
,unloadUi: function ()
{
if (!this.uiLoaded)
return;
if (this.node)
{
this.deactivate ();
this.gui.setTitle (null);
this.gui.setActions (null);
this.gui.setForm (null);
this.deactivate ();
this.node = null;
}
if (this.builder)
{
this.builder.unref ();
this.builder = null;
}
}
/**
* Called when the form is opened.
*/
,open: function ()
{
this.close ();
this.isOpen = true;
this.loadUi ();
}
/**
* Called when the form is closed.
*/
,close: function ()
{
if (!this.isOpen)
return;
this.isOpen = false;
this.unloadUi ();
}
/**
* Called when the form is activated.
*/
,activate: function () {}
/**
* Called when the form is deactivated.
*/
,deactivate: function () {}
,_destroy: function ()
{
this.close ();
this.parent ();
}
});