From e9abe385dc3619843aba7f983bc7c2d2e9055f04 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 5 Jun 2012 21:10:18 +0000 Subject: [PATCH] - Fix action column not being skipped - Add nextmatch-accountfilter --- etemplate/js/et2_extension_nextmatch.js | 74 +++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 9ae8e21307..5fdfe4894e 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -514,9 +514,9 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], { // Remove action column if(remove_action_index != null) { - this.columns.splice(x,x); - columnData.splice(x,x); - _colData.splice(x,x); + this.columns.splice(remove_action_index,remove_action_index); + columnData.splice(remove_action_index,remove_action_index); + _colData.splice(remove_action_index,remove_action_index); } // Create the column manager and update the grid container @@ -1454,6 +1454,11 @@ var et2_nextmatch_filterheader = et2_selectbox.extend(et2_INextmatchHeader, { this._super.apply(this, arguments); this.input.change(this, function(event) { + if(typeof event.data.nextmatch == 'undefined') + { + // Not fully set up yet + return; + } if(typeof event.data.nextmatch.activeFilters.col_filter == 'undefined') event.data.nextmatch.activeFilters.col_filter = {}; if(event.data.input.val()) @@ -1497,8 +1502,67 @@ var et2_nextmatch_filterheader = et2_selectbox.extend(et2_INextmatchHeader, { }); -et2_register_widget(et2_nextmatch_filterheader, ['nextmatch-filterheader', - 'nextmatch-accountfilter']); +et2_register_widget(et2_nextmatch_filterheader, ['nextmatch-filterheader']); + +var et2_nextmatch_accountfilterheader = et2_selectAccount.extend(et2_INextmatchHeader, { + + /** + * Override to add change handler + */ + createInputWidget: function() { + // Make sure there's an option for all + if(!this.options.empty_label && !this.options.select_options[""]) + { + this.options.empty_label = this.options.label ? this.options.label : egw.lang("All"); + } + this._super.apply(this, arguments); + + this.input.change(this, function(event) { + if(typeof event.data.nextmatch == 'undefined') + { + // Not fully set up yet + return; + } + if(typeof event.data.nextmatch.activeFilters.col_filter == 'undefined') + event.data.nextmatch.activeFilters.col_filter = {}; + if(event.data.input.val()) + { + event.data.nextmatch.activeFilters["col_filter"][event.data.id] = event.data.input.val() + } + else + { + delete (event.data.nextmatch.activeFilters["col_filter"][event.data.id]); + } + + event.data.nextmatch.applyFilters(); + }); + + }, + + set_select_options: function(_options) { + // Tell framework to ignore, or it will reset it to ''/empty when it does loadingFinished() + this.attributes.select_options.ignore = true; + this._super.apply(this, arguments); + }, + + /** + * Set nextmatch is the function which has to be implemented for the + * et2_INextmatchHeader interface. + */ + setNextmatch: function(_nextmatch) { + this.nextmatch = _nextmatch; + + // Set current filter value from nextmatch settings + if(this.nextmatch.options.settings.col_filter && this.nextmatch.options.settings.col_filter[this.id]) + { + this.set_value(this.nextmatch.options.settings.col_filter[this.id]); + + // Tell framework to ignore, or it will reset it to ''/empty when it does loadingFinished() + this.attributes.value.ignore = true; + } + } +}); +et2_register_widget(et2_nextmatch_accountfilterheader, ['nextmatch-accountfilter']); var et2_nextmatch_entryheader = et2_link_entry.extend(et2_INextmatchHeader, {