diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index 0d09c70467..7b087ccbd3 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -1558,6 +1558,39 @@ var et2_nextmatch = /** @class */ (function (_super) { this.selectPopup.css("top", t_position.top) .css("left", s_position.left + this.div.width() - this.selectPopup.width()); }; + /** + * Get the currently displayed columns + * Each customfield is listed separately + */ + et2_nextmatch.prototype.get_columns = function () { + var colMgr = this.dataview.getColumnMgr(); + var visibility = colMgr.getColumnVisibilitySet(); + var colDisplay = []; + var custom_fields = []; + // visibility is indexed by internal ID, widget is referenced by position, preference needs name + for (var i = 0; i < colMgr.columns.length; i++) { + // @ts-ignore + var widget = this.columns[i].widget; + var colName = this._getColumnName(widget); + if (colName) { + // Server side wants each cf listed as a seperate column + if (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; + for (var name_2 in widget.options.fields) { + if (widget.options.fields[name_2]) + custom_fields.push(et2_nextmatch_customfields.PREFIX + name_2); + } + } + if (visibility[colMgr.columns[i].id].visible) { + colDisplay.push(colName); + } + } + } + // List each customfield as a seperate column + jQuery.merge(colDisplay, custom_fields); + return this.sortedColumnsList.length > 0 ? this.sortedColumnsList : colDisplay; + }; /** * Set the currently displayed columns, without updating user's preference * @@ -2017,8 +2050,7 @@ var et2_nextmatch = /** @class */ (function (_super) { }; jQuery.extend(value, this.activeFilters, this.value); if (typeof value.selectcols == "undefined" || value.selectcols.length === 0) { - this._updateUserPreferences(); - value.selectcols = this.activeFilters.selectcols; + value.selectcols = this.get_columns(); } return value; }; diff --git a/api/js/etemplate/et2_extension_nextmatch.ts b/api/js/etemplate/et2_extension_nextmatch.ts index 2d9391b580..7317f656bc 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -2136,6 +2136,47 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 .css("left", s_position.left + this.div.width() - this.selectPopup.width()); } + /** + * Get the currently displayed columns + * Each customfield is listed separately + */ + get_columns() + { + const colMgr = this.dataview.getColumnMgr(); + const visibility = colMgr.getColumnVisibilitySet(); + const colDisplay = []; + const custom_fields = []; + + // visibility is indexed by internal ID, widget is referenced by position, preference needs name + for(var i = 0; i < colMgr.columns.length; i++) + { + // @ts-ignore + const widget = this.columns[i].widget; + let colName = this._getColumnName(widget); + if(colName) + { + // Server side wants each cf listed as a seperate column + if(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; + for(let name in widget.options.fields) { + if(widget.options.fields[name]) custom_fields.push(et2_nextmatch_customfields.PREFIX+name); + } + } + if(visibility[colMgr.columns[i].id].visible) + { + colDisplay.push(colName); + } + } + } + + // List each customfield as a seperate column + jQuery.merge(colDisplay, custom_fields); + + return this.sortedColumnsList.length > 0 ? this.sortedColumnsList : colDisplay; + } + /** * Set the currently displayed columns, without updating user's preference * @@ -2717,8 +2758,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 if(typeof value.selectcols == "undefined" || value.selectcols.length === 0) { - this._updateUserPreferences(); - value.selectcols = this.activeFilters.selectcols; + value.selectcols = this.get_columns(); } return value; } diff --git a/api/js/jsapi/egw_app.js b/api/js/jsapi/egw_app.js index 315ed08079..b5f6ab8743 100644 --- a/api/js/jsapi/egw_app.js +++ b/api/js/jsapi/egw_app.js @@ -805,8 +805,8 @@ var EgwApp = /** @class */ (function () { if (typeof favorite.state != 'undefined' && typeof state[state_key] != 'undefined' && typeof favorite.state[state_key] != 'undefined' && (state[state_key] == favorite.state[state_key] || !state[state_key] && !favorite.state[state_key])) { match_count++; } - else if (state_key == 'selectcols') { - // Skip, might be set, might not + else if (state_key == 'selectcols' && typeof favorite.state.selectcols == "undefined") { + // Skip, not set in favorite } else if (typeof state[state_key] != 'undefined' && state[state_key] && typeof state[state_key] === 'object' && typeof favorite.state != 'undefined' && typeof favorite.state[state_key] != 'undefined' && favorite.state[state_key] && typeof favorite.state[state_key] === 'object') { diff --git a/api/js/jsapi/egw_app.ts b/api/js/jsapi/egw_app.ts index 67b264e84a..24dc873993 100644 --- a/api/js/jsapi/egw_app.ts +++ b/api/js/jsapi/egw_app.ts @@ -1032,9 +1032,9 @@ export abstract class EgwApp { match_count++; } - else if (state_key == 'selectcols') + else if (state_key == 'selectcols' && typeof favorite.state.selectcols == "undefined") { - // Skip, might be set, might not + // Skip, not set in favorite } else if (typeof state[state_key] != 'undefined' && state[state_key] && typeof state[state_key] === 'object' && typeof favorite.state != 'undefined' && typeof favorite.state[state_key] != 'undefined' && favorite.state[state_key] && typeof favorite.state[state_key] === 'object')