Implemented hiding grid columns and rows, fixed bug with et2_template::isInTree returning false in the wrong places and thus not all values being transmitted back to the server

This commit is contained in:
Andreas Stöckel 2011-08-22 15:58:47 +00:00
parent 445c04dce1
commit 4869ca9a49
8 changed files with 123 additions and 17 deletions

View File

@ -214,7 +214,10 @@ var et2_arrayMgr = Class.extend({
return val == checkVal;
}
return val != '' && (typeof val != "string" || val.toLowerCase() != "false");
et2_debug("log", "Parse bool expression: ", _expression, val);
return et2_evalBool(val);
// return val != '' && (typeof val != "string" || val.toLowerCase() != "false");
},
openPerspective: function(_owner, _root, _col, _row)

View File

@ -90,6 +90,14 @@ var et2_typeDefaults = {
function et2_evalBool(_val)
{
if (typeof _val == "string")
{
if (_val == "false")
{
return false;
}
}
return _val ? true : false;
}

View File

@ -71,6 +71,7 @@ var et2_grid = et2_DOMWidget.extend({
"widget": null,
"colData": _colData[x],
"rowData": _rowData[y],
"disabled": _colData[x].disabled || _rowData[y].disabled,
"colSpan": 1,
"autoColSpan": false,
"rowSpan": 1,
@ -89,7 +90,8 @@ var et2_grid = et2_DOMWidget.extend({
"width": "auto",
"class": "",
"align": "",
"span": "1"
"span": "1",
"disabled": false
};
},
@ -98,7 +100,8 @@ var et2_grid = et2_DOMWidget.extend({
"height": "auto",
"class": "",
"valign": "",
"span": "1"
"span": "1",
"disabled": false
};
},
@ -128,6 +131,8 @@ var et2_grid = et2_DOMWidget.extend({
// Parse the columns tag
et2_filteredNodeIterator(columns, function(node, nodeName) {
var colDataEntry = this._getColDataEntry();
colDataEntry["disabled"] = this.getArrayMgr("content")
.parseBoolExpression(et2_readAttrWithDefault(node, "disabled", ""));
if (nodeName == "column")
{
colDataEntry["width"] = et2_readAttrWithDefault(node, "width", "auto");
@ -145,6 +150,8 @@ var et2_grid = et2_DOMWidget.extend({
// Parse the rows tag
et2_filteredNodeIterator(rows, function(node, nodeName) {
var rowDataEntry = this._getRowDataEntry();
rowDataEntry["disabled"] = this.getArrayMgr("content")
.parseBoolExpression(et2_readAttrWithDefault(node, "disabled", ""));
if (nodeName == "row")
{
rowDataEntry["height"] = et2_readAttrWithDefault(node, "height", "auto");
@ -383,6 +390,7 @@ var et2_grid = et2_DOMWidget.extend({
{
var row = _cells[y];
var tr = $j(document.createElement("tr")).appendTo(this.tbody);
var row_hidden = true;
// Create the cells. x is incremented by the colSpan value of the
// cell.
@ -396,10 +404,21 @@ var et2_grid = et2_DOMWidget.extend({
// Create the cell
var td = $j(document.createElement("td")).appendTo(tr);
if (cell.disabled)
{
td.hide();
//td.css("border", "2px solid red");
}
else
{
row_hidden = false;
}
// Add the entry for the widget to the management array
this.managementArray.push({
"cell": td[0],
"widget": cell.widget
"widget": cell.widget,
"disabled": cell.disabled
});
// Set the span values of the cell
@ -431,6 +450,11 @@ var et2_grid = et2_DOMWidget.extend({
x++;
}
}
if (row_hidden)
{
tr.hide();
}
}
},
@ -483,7 +507,8 @@ var et2_grid = et2_DOMWidget.extend({
"widget": widget,
"td": null,
"colSpan": srcCell.colSpan,
"rowSpan": srcCell.rowSpan
"rowSpan": srcCell.rowSpan,
"disabled": srcCell.disabled
}
}
}
@ -523,11 +548,25 @@ var et2_grid = et2_DOMWidget.extend({
return null;
},
set_id: function(_value) {
this._super.apply(this, arguments);
isInTree: function(_sender) {
var vis = true;
// Check whether a namespace exists for this element
this.checkCreateNamespace();
if (typeof _sender != "undefined" && _sender != this)
{
vis = false;
// Check whether the _sender object exists inside the management array
for (var i = 0; i < this.managementArray.length; i++)
{
if (this.managementArray[i].widget == _sender)
{
vis = !(this.managementArray[i].disabled);
break;
}
}
}
return this._super(this, vis);
}
});

View File

@ -54,6 +54,7 @@ var et2_template = et2_DOMWidget.extend({
this.proxiedTemplate = null;
this.isProxied = false;
this.isProxy = false;
this.div = document.createElement("div");
@ -85,7 +86,7 @@ var et2_template = et2_DOMWidget.extend({
// Reset the "ignore" flag and manually copy the id
tmpl.options.id = this.id;
this.proxiedTemplate.id = tmpl.id;
this.proxiedTemplate.isProxied = true;
this.proxiedTemplate.isProxy = true;
// Disallow adding any new node to this template
this.supportedWidgetClasses = [];
@ -109,7 +110,7 @@ var et2_template = et2_DOMWidget.extend({
this.proxiedTemplate.loadingFinished();
return false;
}
else if (!this.isProxied)
else if (!this.isProxied && !this.isProxy)
{
this.setParentDOMNode(parentNode);
}
@ -134,8 +135,8 @@ var et2_template = et2_DOMWidget.extend({
return this.div;
},
isInTree: function() {
return this._super(!this.isProxied);
isInTree: function(_sender) {
return this._super(this, !this.isProxied);
}
});

View File

@ -346,7 +346,7 @@ var et2_widget = Class.extend({
* return this._super(inTree);
* when calling this function the _vis parameter does not have to be supplied.
*/
isInTree: function(_vis) {
isInTree: function(_sender, _vis) {
if (typeof _vis == "undefined")
{
_vis = true;
@ -354,7 +354,7 @@ var et2_widget = Class.extend({
if (this._parent)
{
return _vis && this._parent.isInTree();
return _vis && this._parent.isInTree(this);
}
return _vis;

View File

@ -204,6 +204,54 @@
</rows>
</grid>
<grid>
<columns>
<column disabled="true" />
<column />
<column />
<column />
<column />
</columns>
<rows>
<row>
<description value="1,1" />
<description value="1,2" />
<description value="1,3" />
<description value="1,4" />
<description value="1,5" />
</row>
<row disabled="true">
<description value="2,1" />
<description value="2,2" />
<description value="2,3" />
<description value="2,4" />
<description value="2,5" />
</row>
<row>
<description value="3,1" />
<description value="3,2" />
<description value="3,3" />
<description value="3,4" />
<description value="3,5" />
</row>
<row>
<description value="4,1" />
<description value="4,2" />
<description disabled="true" value="4,3" />
<description value="4,4" />
<description value="4,5" />
</row>
<row disabled="true">
<description value="5,1" />
<description value="5,2" />
<description value="5,3" />
<description value="5,4" />
<description value="5,5" />
</row>
</rows>
</grid>
</overlay>

View File

@ -73,8 +73,7 @@ var timesheet_data = {
"ts_owner":true,
"tabs":{
"customfields":true
},
"ts_description": true
}
}
}

View File

@ -251,3 +251,11 @@ hr {
margin: 10px 0px 10px 0px;
}
/**
* grid widget
*/
table.et2_grid {
border-collapse: collapse;
}