* If column information is stored in a favorite, restore it along with the filters

To get column information in the favorite, change the visible columns before you create the favorite.
If the favorite has no column information, the visible columns will not be changed.
This commit is contained in:
Nathan Gray 2015-05-11 17:29:31 +00:00
parent 53f381e246
commit 237d1d809e
4 changed files with 76 additions and 3 deletions

View File

@ -1436,6 +1436,68 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
.css("left", s_position.left + this.div.width() - this.selectPopup.width());
},
/**
* Set the currently displayed columns, without updating user's preference
*
* @param {string[]} column_list List of column names
* @param {boolean} trigger_update=false - explicitly trigger an update
*/
set_columns: function(column_list, trigger_update)
{
var columnMgr = this.dataview.getColumnMgr();
var visibility = {};
// Initialize to false
for (var i = 0; i < columnMgr.columns.length; i++)
{
var col = columnMgr.columns[i];
if(col.caption && col.visibility != ET2_COL_VISIBILITY_ALWAYS_NOSELECT )
{
visibility[col.id] = {visible: false};
}
}
for(var i = 0; i < this.columns.length; i++)
{
var widget = this.columns[i].widget;
var colName = this._getColumnName(widget);
if(column_list.indexOf(colName) !== -1)
{
visibility[columnMgr.columns[i].id].visible = true;
}
// Custom fields are listed seperately in column list, but are only 1 column
if(widget && widget.instanceOf(et2_nextmatch_customfields)) {
// Just the ID for server side, not the whole nm name - some apps use it to skip custom fields
colName = widget.id;
if(column_list.indexOf(colName) !== -1)
{
visibility[columnMgr.columns[i].id].visible = true;
}
var cf = this.columns[i].widget.options.customfields;
var visible = this.columns[i].widget.options.fields;
// Turn off all custom fields
for(var field_name in cf)
{
visible[field_name] = false;
}
// Turn on selected custom fields - start from 0 in case they're not in order
for(var j = 0; j < column_list.length; j++)
{
if(column_list[j].indexOf(et2_customfields_list.prototype.prefix) != 0) continue;
visible[column_list[j].substring(1)] = true;
}
widget.set_visible(visible);
}
}
columnMgr.setColumnVisibilitySet(visibility);
// We don't want to update user's preference, so directly update
this.dataview._updateColumns();
},
/**
* Set the letter search preference, and update the UI
*

View File

@ -422,8 +422,7 @@ class infolog_ui
$columselection = $this->prefs[$columnselection_pref];
//_debug_array($columselection);
if ($columselection)
if (!$query['selectcols'] && $columselection)
{
$columselection = is_array($columselection) ? $columselection : explode(',',$columselection);
}

View File

@ -213,7 +213,12 @@ app.classes.infolog = AppJS.extend(
{
// Show / hide descriptions
this.show_details(filter2.value == 'all', nm.getDOMNode(nm));
}
// Only change columns for a real user event, to avoid interfering with
// favorites
if (nm && filter2 && !nm.update_in_progress)
{
// Store selection as implicit preference
egw.set_preference('infolog', nm.options.settings.columnselection_pref.replace('-details','')+'-details-pref', filter2.value);
@ -223,6 +228,8 @@ app.classes.infolog = AppJS.extend(
// Load new preferences
var colData = nm.columns.slice();
for(var i = 0; i < nm.columns.length; i++) colData[i].disabled=false;
nm.set_columns(egw.preference(nm.options.settings.columnselection_pref,'infolog').split(','));
nm._applyUserPreferences(nm.columns, colData);
// Now apply them to columns
@ -231,7 +238,7 @@ app.classes.infolog = AppJS.extend(
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;
nm.dataview.getColumnMgr().updated = true;
// Update page
nm.dataview.updateColumns();
}

View File

@ -291,6 +291,11 @@ var AppJS = Class.extend(
{
_widget.sortBy(state.state.sort.id, state.state.sort.asc,false);
}
if(state.state && state.state.selectcols)
{
// Make sure it's a real array, not an object, then set cols
_widget.set_columns(jQuery.extend([],state.state.selectcols));
}
_widget.applyFilters(state.state || state.filter || {});
nextmatched = true;
}, this, et2_nextmatch);