forked from verdnatura/hedera-web
93 lines
1.6 KiB
JavaScript
Executable File
93 lines
1.6 KiB
JavaScript
Executable File
|
|
Vn.Module = new Class
|
|
({
|
|
Extends: Vn.Object
|
|
|
|
,initialize: function (gui, formInfo)
|
|
{
|
|
this.gui = gui;
|
|
this.conn = gui.conn;
|
|
this.hash = gui.hash;
|
|
this.formInfo = formInfo;
|
|
}
|
|
|
|
/**
|
|
* Gets an object from the builder associated to this form.
|
|
*
|
|
* @param {string} objectId The object identifier
|
|
* @return {Object} The object, or %null if not found
|
|
**/
|
|
,$: function (objectId)
|
|
{
|
|
if (this.builder)
|
|
return this.builder.getById (objectId);
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Called when the form is opened.
|
|
**/
|
|
,open: function ()
|
|
{
|
|
this.close ();
|
|
|
|
var builder = new Vn.Builder ();
|
|
builder.signalData = this;
|
|
builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml');
|
|
|
|
var res = this.builder = builder.load ();
|
|
this.node = res.$('form');
|
|
|
|
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;
|
|
|
|
this.gui.formHolder.appendChild (this.node);
|
|
this.gui.setTitle (res.$('title'));
|
|
this.gui.setActions (res.$('actions'));
|
|
}
|
|
|
|
/**
|
|
* Called when the form is activated.
|
|
**/
|
|
,activate: function () {}
|
|
|
|
/**
|
|
* Called when the form is deactivated.
|
|
**/
|
|
,deactivate: function () {}
|
|
|
|
/**
|
|
* Called when the form is closed.
|
|
**/
|
|
,close: function ()
|
|
{
|
|
if (this.node)
|
|
{
|
|
this.gui.setTitle (null);
|
|
this.gui.setActions (null);
|
|
Vn.Node.remove (this.node);
|
|
this.node = null;
|
|
}
|
|
if (this.builder)
|
|
{
|
|
this.builder.unref ();
|
|
this.builder = null;
|
|
}
|
|
}
|
|
|
|
,_destroy: function ()
|
|
{
|
|
this.close ();
|
|
this.parent ();
|
|
}
|
|
});
|
|
|