forked from verdnatura/hedera-web
136 lines
2.3 KiB
JavaScript
136 lines
2.3 KiB
JavaScript
|
|
var Model = require ('./model');
|
|
|
|
module.exports = new Class
|
|
({
|
|
Implements: Vn.LotIface
|
|
,Properties:
|
|
{
|
|
/**
|
|
* The model associated to this form.
|
|
*/
|
|
model:
|
|
{
|
|
type: Model
|
|
},
|
|
/**
|
|
* The row where the form positioned, has -1 if the row is unselected.
|
|
*/
|
|
row:
|
|
{
|
|
type: Number
|
|
},
|
|
/**
|
|
* The number of rows in the form.
|
|
*/
|
|
numRows:
|
|
{
|
|
type: Number
|
|
},
|
|
/**
|
|
* Checks if the form data is ready.
|
|
*/
|
|
ready:
|
|
{
|
|
type: Boolean
|
|
}
|
|
}
|
|
|
|
,refresh: function ()
|
|
{
|
|
if (this._model)
|
|
this._model.refresh ();
|
|
}
|
|
|
|
/**
|
|
* Get the index of the column from its name.
|
|
*
|
|
* @param {string} columnName The column name
|
|
* @return {integer} The column index or -1 if column not exists
|
|
*/
|
|
,getColumnIndex: function (columnName)
|
|
{
|
|
return this._model ?
|
|
this._model.getColumnIndex (columnName) : -1;
|
|
}
|
|
|
|
,insertRow: function ()
|
|
{
|
|
if (this._model)
|
|
this.row = this._model.insertRow ();
|
|
}
|
|
|
|
,performOperations: function ()
|
|
{
|
|
if (this._model)
|
|
this._model.performOperations ();
|
|
}
|
|
|
|
/**
|
|
* Removes the current row.
|
|
*/
|
|
,deleteRow: function ()
|
|
{
|
|
if (this._row >= 0)
|
|
this._model.deleteRow (this._row);
|
|
}
|
|
|
|
/**
|
|
* Gets a value from the form.
|
|
*
|
|
* @param {string} columnName The column name
|
|
* @return {Object} The value
|
|
*/
|
|
,get: function (columnName)
|
|
{
|
|
return this._model ?
|
|
this._model.get (this._row, columnName) : undefined;
|
|
}
|
|
|
|
/**
|
|
* Sets a value on the form.
|
|
*
|
|
* @param {string} columnName The column name
|
|
* @param {Object} value The new value
|
|
*/
|
|
,set: function (columnName, value)
|
|
{
|
|
this._model.set (this._row, columnName, value);
|
|
}
|
|
|
|
/**
|
|
* Gets a value from the form using the column index.
|
|
*
|
|
* @param {string} columnName The column index
|
|
* @return {Object} The value
|
|
*/
|
|
,getByIndex: function (column)
|
|
{
|
|
return this._model.getByIndex (this._row, column);
|
|
}
|
|
|
|
/**
|
|
* Sets a value on the form using the column index.
|
|
*
|
|
* @param {string} columnName The column index
|
|
* @param {Object} value The new value
|
|
*/
|
|
,setByIndex: function (column, value)
|
|
{
|
|
return this._model.setByIndex (this._row, column, value);
|
|
}
|
|
|
|
,keys: function ()
|
|
{
|
|
return this._model ?
|
|
this.model.keys () : null;
|
|
}
|
|
|
|
,getParams: function ()
|
|
{
|
|
return this._model ?
|
|
this.model.getObject (this._row) : null;
|
|
}
|
|
});
|
|
|