From 87bb95beb42f1f56729a21e829fb22fc05796f0f Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 17 Oct 2011 16:34:58 +0000 Subject: [PATCH] Check for updated visibility (ex nextmatch column selection change) --- etemplate/js/et2_extension_customfields.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_extension_customfields.js b/etemplate/js/et2_extension_customfields.js index a215f7d5a8..7c0bfee967 100644 --- a/etemplate/js/et2_extension_customfields.js +++ b/etemplate/js/et2_extension_customfields.js @@ -29,7 +29,8 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { }, 'fields': { 'name': 'Custom fields', - 'description': 'Auto filled' + 'description': 'Auto filled', + "default": {} }, 'value': { 'name': 'Custom fields', @@ -96,13 +97,22 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { // Already set up - avoid duplicates in nextmatch if(this._type == 'customfields-list' && !this.isInTree()) return; + // Check for global setting changes (visibility) + var global_data = this.getArrayMgr("modifications").getRoot().getEntry('~custom_fields~'); + if(global_data.fields) this.options.fields = global_data.fields; + // Create the table rows for(var field_name in this.options.customfields) { + var field = this.options.customfields[field_name]; + + // Field is not to be shown + if(this.options.fields[field_name] == false || + this.options.fields != {} && typeof this.options.fields[field_name] == 'undefined') continue; + // Avoid creating field twice if(this.rows[field_name]) continue; - var field = this.options.customfields[field_name]; var row = jQuery(document.createElement("tr")) .appendTo(this.tbody); var cf = jQuery(document.createElement("td")) @@ -147,7 +157,7 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { // Customized settings for this widget (unlikely) var data = this.getArrayMgr("modifications").getEntry(this.id); // Check for global settings - var global_data = this.getArrayMgr("modifications").getEntry('~custom_fields~'); + var global_data = this.getArrayMgr("modifications").getRoot().getEntry('~custom_fields~', true); if(global_data) data = jQuery.extend({}, data, global_data); for(var key in data) {