mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 17:14:44 +01:00
Allow gridview / nextmatch columns to be disabled and not show as options in the column list by sending something from the server. Previously was only parsed & disabled on first load.
eg: setting the column disabled=@no_column, then setting no_column=true in the get_rows response to disable it. Note: to re-enable the column ,you must send no_column=false
This commit is contained in:
parent
45d4076798
commit
53dcea9004
@ -21,6 +21,7 @@ var ET2_COL_VISIBILITY_ALWAYS = 0;
|
|||||||
var ET2_COL_VISIBILITY_VISIBLE = 1;
|
var ET2_COL_VISIBILITY_VISIBLE = 1;
|
||||||
var ET2_COL_VISIBILITY_INVISIBLE = 2;
|
var ET2_COL_VISIBILITY_INVISIBLE = 2;
|
||||||
var ET2_COL_VISIBILITY_ALWAYS_NOSELECT = 3;
|
var ET2_COL_VISIBILITY_ALWAYS_NOSELECT = 3;
|
||||||
|
var ET2_COL_VISIBILITY_DISABLED = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class which stores the data of a single column.
|
* Class which stores the data of a single column.
|
||||||
@ -251,7 +252,9 @@ var et2_dataview_columns = (function(){ "use strict"; return Class.extend({
|
|||||||
result.push({
|
result.push({
|
||||||
"id": this.columns[i].id,
|
"id": this.columns[i].id,
|
||||||
"width": this.getColumnWidth(i),
|
"width": this.getColumnWidth(i),
|
||||||
"visible": this.columns[i].visibility != ET2_COL_VISIBILITY_INVISIBLE
|
"visible": this.columns[i].visibility !== ET2_COL_VISIBILITY_INVISIBLE &&
|
||||||
|
this.columns[i].visibility !== ET2_COL_VISIBILITY_DISABLED
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,6 +275,7 @@ var et2_dataview_columns = (function(){ "use strict"; return Class.extend({
|
|||||||
result[this.columns[i].id] = {
|
result[this.columns[i].id] = {
|
||||||
"caption": this.columns[i].caption,
|
"caption": this.columns[i].caption,
|
||||||
"enabled": (this.columns[i].visibility != ET2_COL_VISIBILITY_ALWAYS) &&
|
"enabled": (this.columns[i].visibility != ET2_COL_VISIBILITY_ALWAYS) &&
|
||||||
|
(this.columns[i].visibility != ET2_COL_VISIBILITY_DISABLED) &&
|
||||||
(this.columns[i].type != ET2_COL_TYPE_NAME_ICON_FIXED),
|
(this.columns[i].type != ET2_COL_TYPE_NAME_ICON_FIXED),
|
||||||
"visible": this.columns[i].visibility != ET2_COL_VISIBILITY_INVISIBLE
|
"visible": this.columns[i].visibility != ET2_COL_VISIBILITY_INVISIBLE
|
||||||
};
|
};
|
||||||
@ -327,7 +331,9 @@ var et2_dataview_columns = (function(){ "use strict"; return Class.extend({
|
|||||||
for (var i = 0; i < this.columns.length; i++)
|
for (var i = 0; i < this.columns.length; i++)
|
||||||
{
|
{
|
||||||
var col = this.columns[i];
|
var col = this.columns[i];
|
||||||
if (col.visibility != ET2_COL_VISIBILITY_INVISIBLE)
|
if (col.visibility !== ET2_COL_VISIBILITY_INVISIBLE &&
|
||||||
|
col.visibility !== ET2_COL_VISIBILITY_DISABLED
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Some bounds sanity checking
|
// Some bounds sanity checking
|
||||||
if(col.fixedWidth > tw || col.fixedWidth < 0)
|
if(col.fixedWidth > tw || col.fixedWidth < 0)
|
||||||
@ -356,7 +362,9 @@ var et2_dataview_columns = (function(){ "use strict"; return Class.extend({
|
|||||||
{
|
{
|
||||||
var w = 0;
|
var w = 0;
|
||||||
var col = this.columns[i];
|
var col = this.columns[i];
|
||||||
if (col.visibility != ET2_COL_VISIBILITY_INVISIBLE)
|
if (col.visibility != ET2_COL_VISIBILITY_INVISIBLE &&
|
||||||
|
col.visibility !== ET2_COL_VISIBILITY_DISABLED
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (col._larger)
|
if (col._larger)
|
||||||
{
|
{
|
||||||
@ -395,7 +403,8 @@ var et2_dataview_columns = (function(){ "use strict"; return Class.extend({
|
|||||||
// Pick the first relative column and use it
|
// Pick the first relative column and use it
|
||||||
for(columnIndex = 0; columnIndex < this.columns.length; columnIndex++)
|
for(columnIndex = 0; columnIndex < this.columns.length; columnIndex++)
|
||||||
{
|
{
|
||||||
if(this.columns[columnIndex].visibility == ET2_COL_VISIBILITY_INVISIBLE ||
|
if(this.columns[columnIndex].visibility === ET2_COL_VISIBILITY_INVISIBLE ||
|
||||||
|
col.visibility === ET2_COL_VISIBILITY_DISABLED ||
|
||||||
this.columnWidths[columnIndex] <= 0)
|
this.columnWidths[columnIndex] <= 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -850,9 +850,9 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
|
|||||||
for(var i = 0; i < _row.length; i++)
|
for(var i = 0; i < _row.length; i++)
|
||||||
{
|
{
|
||||||
colName = '';
|
colName = '';
|
||||||
if(_row[i].disabled)
|
if(_row[i].disabled === true)
|
||||||
{
|
{
|
||||||
_colData[i].disabled = true;
|
_colData[i].visible = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,14 +873,14 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
|
|||||||
}
|
}
|
||||||
// Resets field visibility too
|
// Resets field visibility too
|
||||||
_row[i].widget._getColumnName();
|
_row[i].widget._getColumnName();
|
||||||
_colData[i].disabled = negated || jQuery.isEmptyObject(_row[i].widget.options.fields);
|
_colData[i].visible = !(negated || jQuery.isEmptyObject(_row[i].widget.options.fields));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Disable if there are no custom fields
|
// Disable if there are no custom fields
|
||||||
if(jQuery.isEmptyObject(_row[i].widget.customfields))
|
if(jQuery.isEmptyObject(_row[i].widget.customfields))
|
||||||
{
|
{
|
||||||
_colData[i].disabled = true;
|
_colData[i].visible = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
colName = _row[i].widget.id;
|
colName = _row[i].widget.id;
|
||||||
@ -907,12 +907,12 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
|
|||||||
{
|
{
|
||||||
if(columnDisplay[j] == colName)
|
if(columnDisplay[j] == colName)
|
||||||
{
|
{
|
||||||
_colData[i].disabled = negated;
|
_colData[i].visible = !negated;
|
||||||
|
|
||||||
continue RowLoop;
|
continue RowLoop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_colData[i].disabled = !negated;
|
_colData[i].visible = negated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1047,12 +1047,18 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
|
|||||||
"widget": _row[x].widget
|
"widget": _row[x].widget
|
||||||
},_colData[x]);
|
},_colData[x]);
|
||||||
|
|
||||||
|
var visibility = (!_colData[x] || _colData[x].visible) ?
|
||||||
|
ET2_COL_VISIBILITY_VISIBLE :
|
||||||
|
ET2_COL_VISIBILITY_INVISIBLE;
|
||||||
|
if(_colData[x].disabled && _colData[x].disabled !=='' &&
|
||||||
|
this.getArrayMgr("content").parseBoolExpression(_colData[x].disabled))
|
||||||
|
{
|
||||||
|
visibility = ET2_COL_VISIBILITY_DISABLED;
|
||||||
|
}
|
||||||
columnData[x] = {
|
columnData[x] = {
|
||||||
"id": "col_" + x,
|
"id": "col_" + x,
|
||||||
"caption": this._genColumnCaption(_row[x].widget),
|
"caption": this._genColumnCaption(_row[x].widget),
|
||||||
"visibility": (!_colData[x] || _colData[x].disabled) ?
|
"visibility": visibility,
|
||||||
ET2_COL_VISIBILITY_INVISIBLE : ET2_COL_VISIBILITY_VISIBLE,
|
|
||||||
"width": _colData[x] ? _colData[x].width : 0
|
"width": _colData[x] ? _colData[x].width : 0
|
||||||
};
|
};
|
||||||
if(_colData[x].minWidth)
|
if(_colData[x].minWidth)
|
||||||
@ -1142,7 +1148,7 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
|
|||||||
columnWidgets[x] = _row[x].widget;
|
columnWidgets[x] = _row[x].widget;
|
||||||
}
|
}
|
||||||
// Pass along column alignment
|
// Pass along column alignment
|
||||||
if(_row[x].align)
|
if(_row[x].align && columnWidgets[x])
|
||||||
{
|
{
|
||||||
columnWidgets[x].align = _row[x].align;
|
columnWidgets[x].align = _row[x].align;
|
||||||
}
|
}
|
||||||
@ -1296,7 +1302,8 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
|
|||||||
var col = columnMgr.columns[i];
|
var col = columnMgr.columns[i];
|
||||||
var widget = this.columns[i].widget;
|
var widget = this.columns[i].widget;
|
||||||
|
|
||||||
if(col.caption && col.visibility != ET2_COL_VISIBILITY_ALWAYS_NOSELECT)
|
if(col.caption && col.visibility !== ET2_COL_VISIBILITY_ALWAYS_NOSELECT &&
|
||||||
|
col.visibility !== ET2_COL_VISIBILITY_DISABLED)
|
||||||
{
|
{
|
||||||
columns[col.id] = col.caption;
|
columns[col.id] = col.caption;
|
||||||
if(col.visibility == ET2_COL_VISIBILITY_VISIBLE) columns_selected.push(col.id);
|
if(col.visibility == ET2_COL_VISIBILITY_VISIBLE) columns_selected.push(col.id);
|
||||||
@ -1369,7 +1376,8 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
|
|||||||
for (var i = 0; i < columnMgr.columns.length; i++)
|
for (var i = 0; i < columnMgr.columns.length; i++)
|
||||||
{
|
{
|
||||||
var col = columnMgr.columns[i];
|
var col = columnMgr.columns[i];
|
||||||
if(col.caption && col.visibility != ET2_COL_VISIBILITY_ALWAYS_NOSELECT )
|
if(col.caption && col.visibility !== ET2_COL_VISIBILITY_ALWAYS_NOSELECT &&
|
||||||
|
col.visibility !== ET2_COL_VISIBILITY_DISABLED )
|
||||||
{
|
{
|
||||||
visibility[col.id] = {visible: false};
|
visibility[col.id] = {visible: false};
|
||||||
}
|
}
|
||||||
|
@ -581,6 +581,27 @@ var et2_nextmatch_controller = (function(){ "use strict"; return et2_dataview_co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Might be trying to disable a column
|
||||||
|
var col_refresh = false;
|
||||||
|
for(var column_index = 0; column_index < nm.columns.length; column_index++)
|
||||||
|
{
|
||||||
|
if(typeof nm.columns[column_index].disabled === 'string' &&
|
||||||
|
nm.columns[column_index].disabled[0] === '@')
|
||||||
|
{
|
||||||
|
col_refresh = true;
|
||||||
|
nm.dataview.columnMgr.getColumnById('col_'+column_index)
|
||||||
|
.set_visibility(
|
||||||
|
mgr.parseBoolExpression(nm.columns[column_index].disabled) ?
|
||||||
|
ET2_COL_VISIBILITY_DISABLED :
|
||||||
|
ET2_COL_VISIBILITY_VISIBLE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(col_refresh)
|
||||||
|
{
|
||||||
|
nm.dataview.columnMgr.updated = true;
|
||||||
|
nm.dataview._updateColumns();
|
||||||
|
}
|
||||||
|
|
||||||
// If we're doing an autorefresh and the count decreases, preserve the
|
// If we're doing an autorefresh and the count decreases, preserve the
|
||||||
// selection or it will be lost when the grid rows are shuffled. Increases
|
// selection or it will be lost when the grid rows are shuffled. Increases
|
||||||
|
@ -107,12 +107,16 @@ var et2_grid = (function(){ "use strict"; return et2_DOMWidget.extend([et2_IDeta
|
|||||||
// Initialize the cell description objects
|
// Initialize the cell description objects
|
||||||
for (var x = 0; x < w; x++)
|
for (var x = 0; x < w; x++)
|
||||||
{
|
{
|
||||||
|
// Some columns (nm) we do not parse into a boolean
|
||||||
|
var col_disabled = typeof _colData[x].disabled == 'boolean' ?
|
||||||
|
_colData[x].disabled :
|
||||||
|
this.getArrayMgr("content").parseBoolExpression(_colData[x].disabled);
|
||||||
cells[y][x] = {
|
cells[y][x] = {
|
||||||
"td": null,
|
"td": null,
|
||||||
"widget": null,
|
"widget": null,
|
||||||
"colData": _colData[x],
|
"colData": _colData[x],
|
||||||
"rowData": _rowData[y],
|
"rowData": _rowData[y],
|
||||||
"disabled": _colData[x].disabled || _rowData[y].disabled,
|
"disabled": col_disabled || _rowData[y].disabled,
|
||||||
"class": _colData[x]["class"],
|
"class": _colData[x]["class"],
|
||||||
"colSpan": 1,
|
"colSpan": 1,
|
||||||
"autoColSpan": false,
|
"autoColSpan": false,
|
||||||
@ -171,10 +175,22 @@ var et2_grid = (function(){ "use strict"; return et2_DOMWidget.extend([et2_IDeta
|
|||||||
},
|
},
|
||||||
|
|
||||||
_fetchRowColData: function(columns, rows, colData, rowData) {
|
_fetchRowColData: function(columns, rows, colData, rowData) {
|
||||||
|
// Some things cannot be done inside a nextmatch - nm will do the expansion later
|
||||||
|
var nm = false;
|
||||||
|
var widget = this;
|
||||||
|
while(!nm && widget != this.getRoot())
|
||||||
|
{
|
||||||
|
nm = (widget._type == 'nextmatch');
|
||||||
|
widget = widget.getParent();
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the columns tag
|
// Parse the columns tag
|
||||||
et2_filteredNodeIterator(columns, function(node, nodeName) {
|
et2_filteredNodeIterator(columns, function(node, nodeName) {
|
||||||
var colDataEntry = this._getColDataEntry();
|
var colDataEntry = this._getColDataEntry();
|
||||||
colDataEntry["disabled"] = this.getArrayMgr("content")
|
// This cannot be done inside a nm, it will expand it later
|
||||||
|
colDataEntry["disabled"] = nm ?
|
||||||
|
et2_readAttrWithDefault(node, "disabled", "") :
|
||||||
|
this.getArrayMgr("content")
|
||||||
.parseBoolExpression(et2_readAttrWithDefault(node, "disabled", ""));
|
.parseBoolExpression(et2_readAttrWithDefault(node, "disabled", ""));
|
||||||
if (nodeName == "column")
|
if (nodeName == "column")
|
||||||
{
|
{
|
||||||
@ -254,12 +270,6 @@ var et2_grid = (function(){ "use strict"; return et2_DOMWidget.extend([et2_IDeta
|
|||||||
// Old etemplate checked first two widgets, or first two box children
|
// Old etemplate checked first two widgets, or first two box children
|
||||||
// This cannot be done inside a nextmatch - nm will do the expansion later
|
// This cannot be done inside a nextmatch - nm will do the expansion later
|
||||||
var nm = false;
|
var nm = false;
|
||||||
var widget = this;
|
|
||||||
while(!nm && widget != this.getRoot())
|
|
||||||
{
|
|
||||||
nm = (widget._type == 'nextmatch');
|
|
||||||
widget = widget.getParent();
|
|
||||||
}
|
|
||||||
if(nm)
|
if(nm)
|
||||||
{
|
{
|
||||||
// No further checks for repeated rows
|
// No further checks for repeated rows
|
||||||
|
Loading…
Reference in New Issue
Block a user