From 0136c6292c9a63de6dc5fa334f72d840a7f41f0e Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 19 Oct 2011 17:13:27 +0000 Subject: [PATCH] Fix custom field preference handling when previous columns disabled --- etemplate/js/et2_extension_customfields.js | 1 - etemplate/js/et2_extension_nextmatch.js | 29 +++++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/etemplate/js/et2_extension_customfields.js b/etemplate/js/et2_extension_customfields.js index 88587f011c..e672d0bee4 100644 --- a/etemplate/js/et2_extension_customfields.js +++ b/etemplate/js/et2_extension_customfields.js @@ -147,7 +147,6 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { delete(attrs.label); // Create widget -console.debug(attrs); var widget = this.widgets[field_name] = et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this); } diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 5a83841632..a3247db7f3 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -353,19 +353,25 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, { if(!colName) continue; if(size[colName]) _colData[i].width = size[colName]; - // Customfields needs special processing if(_row[i].widget.instanceOf(et2_nextmatch_customfields)) { - var cfDisplay = et2_csvSplit(columnDisplay[i],null,"_#"); - for(var j = 1; j < cfDisplay.length; j++) + // Find cf field + for(var j = 0; j < columnDisplay.length; j++) { - _row[i].widget.options.fields[cfDisplay[j]] = true; - } - // Resets field visibility too - _row[i].widget._getColumnName(); - _colData[i].disabled = negated; - continue RowLoop; + if(columnDisplay[j].indexOf(_row[i].widget.id) == 0) { + var cfDisplay = et2_csvSplit(columnDisplay[j],null,"_#"); + _row[i].widget.options.fields = {}; + for(var k = 1; k < cfDisplay.length; k++) + { + _row[i].widget.options.fields[cfDisplay[k]] = true; + } + // Resets field visibility too + _row[i].widget._getColumnName(); + _colData[i].disabled = negated; + continue RowLoop; + } + } } for(var j = 0; j < columnDisplay.length; j++) { @@ -1154,7 +1160,7 @@ var et2_nextmatch_customfields = et2_nextmatch_header.extend({ if(widget) cf.append(widget.getDOMNode()); // Check for column filter - if(this.options.fields.length > 0 && ( + if(!jQuery.isEmptyObject(this.options.fields) && ( this.options.fields[field_name] == false || typeof this.options.fields[field_name] == 'undefined')) { cf.hide(); @@ -1196,10 +1202,9 @@ var et2_nextmatch_customfields = et2_nextmatch_header.extend({ _getColumnName: function() { var name = this.id; var visible = []; - for(var field_name in this.options.customfields) { - if(this.options.fields.length == 0 || this.options.fields[field_name] == true) + if(jQuery.isEmptyObject(this.options.fields) || this.options.fields[field_name] == true) { visible.push(et2_customfields_list.prototype.prefix + field_name); jQuery(this.rows[field_name]).show();