From 59f0b65e634f64d3d59a2dd81dd2abcbbfe680e2 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 26 Aug 2014 13:51:06 +0000 Subject: [PATCH] Backport commit r48263, committed by Nathan Gray. Infolog lists embedded as action can have their own separate column preferences. --- etemplate/js/et2_extension_nextmatch.js | 4 ++-- infolog/inc/class.infolog_ui.inc.php | 18 +++++++++++------- infolog/js/app.js | 20 +++++++++++--------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 42993b3e42..03dca6a8fd 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -955,9 +955,9 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], for (var x = 0; x < _row.length; x++) { - this.columns[x] = { + this.columns[x] = jQuery.extend({ "widget": _row[x].widget - }; + },_colData[x]); columnData[x] = { diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 3682f89b7d..04e923d041 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -372,7 +372,11 @@ class infolog_ui // do we need to read the custom fields, depends on the column is enabled and customfields exist, prefs are filter specific // so we have to check that as well $details = $query['filter2'] == 'all'; - $columselection = $this->prefs['nextmatch-infolog.index.rows'.($details?'-details':'')]; + $columnselection_pref = 'nextmatch-'.($query['action'] ? 'infolog.'.$query['action'] : (is_object($query['template']) ? $query['template']->name : 'infolog.index.rows')) + .($details ? '-details' : ''); + + $columselection = $this->prefs[$columnselection_pref]; + //_debug_array($columselection); if ($columselection) { @@ -394,13 +398,11 @@ class infolog_ui // add a '-details' to the name of the columnselection pref if ($details) { - $query['columnselection_pref'] = 'nextmatch-'.(is_object($query['template'])?$query['template']->name:'infolog.index.rows').'-details'; - $query['default_cols'] = '!cat_id,info_used_time_info_planned_time,info_used_time_info_planned_time_info_replanned_time,info_id,actions'; + $query['default_cols'] = '!cat_id,info_used_time_info_planned_time,info_used_time_info_planned_time_info_replanned_time,info_id'; } else { - $query['columnselection_pref'] = 'nextmatch-infolog.index.rows'; - $query['default_cols'] = '!cat_id,info_datemodified,info_used_time_info_planned_time,info_used_time_info_planned_time_info_replanned_time,info_id,actions'; + $query['default_cols'] = '!cat_id,info_datemodified,info_used_time_info_planned_time,info_used_time_info_planned_time_info_replanned_time,info_id'; } // set old show_times pref, that get_info calculates the cumulated time of the timesheets (we only check used&planned to work for both time cols) $this->prefs['show_times'] = strpos($this->prefs[$query['columnselection_pref']],'info_used_time_info_planned_time') !== false; @@ -861,7 +863,7 @@ class infolog_ui $values['nm']['filter_onchange'] = "app.infolog.filter_change();"; //apply infolog_filter2_change javascript method (show/hide details each rows) over onchange filter2 - $values['nm']['filter2_onchange'] = "app.infolog.filter2_change();"; + $values['nm']['filter2_onchange'] = "app.infolog.filter2_change"; // disable favories dropdown button, if not running as infolog if ($called_as && $called_as != 'infolog') @@ -878,9 +880,11 @@ class infolog_ui $values['nm']['placeholder_actions'] = array('new'); // disable columns for main entry as set in the pref for details or no details + $values['nm']['columnselection_pref'] = 'nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows') + .($values['nm']['filter2']=='all' ? '-details' : ''); if ($action == 'sp') { - $pref = 'nextmatch-infolog.index.rows'.($values['nm']['filter2']=='all'?'-details':''); + $pref = $values['nm']['columnselection_pref']; foreach(array('info_used_time_info_planned_time_info_replanned_time','info_datemodified','info_owner_info_responsible','customfields') as $name) { $values['main']['no_'.$name] = strpos($this->prefs[$pref],$name) === false; diff --git a/infolog/js/app.js b/infolog/js/app.js index db1a0ecb15..df17c2b81e 100644 --- a/infolog/js/app.js +++ b/infolog/js/app.js @@ -151,11 +151,12 @@ app.classes.infolog = AppJS.extend( * show or hide the details of rows by selecting the filter2 option * either 'all' for details or 'no_description' for no details * + * @param {Event} event Change event + * @param {et2_nextmatch} nm The nextmatch widget that owns the filter */ - filter2_change: function() + filter2_change: function(event, nm) { - var nm = this.et2.getWidgetById('nm'); - var filter2 = this.et2.getWidgetById('filter2'); + var filter2 = nm.getWidgetById('filter2'); if (nm && filter2) { @@ -163,16 +164,17 @@ app.classes.infolog = AppJS.extend( this.show_details(filter2.value == 'all'); // Change preference location - widget is nextmatch - nm.options.settings.columnselection_pref = 'infolog.index.rows'+(filter2.value == 'all' ? '-details' :''); - + nm.options.settings.columnselection_pref = nm.options.settings.columnselection_pref.replace('-details','') + (filter2.value == 'all' ? '-details' :''); + // Load new preferences - var colData = []; - for(var i = 0; i < nm.columns.length; i++) colData[i] = {disabled: true, width: '20'}; + var colData = nm.columns.slice(); + for(var i = 0; i < nm.columns.length; i++) colData[i].disabled=false; nm._applyUserPreferences(nm.columns, colData); + + // Now apply them to columns for(var i = 0; i < colData.length; i++) { - // Wants a string - nm.dataview.getColumnMgr().columns[i].set_width(colData[i].width + 'px'); + nm.dataview.getColumnMgr().columns[i].set_width(colData[i].width); nm.dataview.getColumnMgr().columns[i].set_visibility(!colData[i].disabled); } nm.dataview.getColumnMgr().updated = true;