From 1a94a0ef98a3236c9676d3269535b9b42f50b484 Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 24 Mar 2021 10:21:02 -0600 Subject: [PATCH] Api: Stop annoying "column saved" message that kept coming up --- api/js/etemplate/et2_extension_nextmatch.js | 36 ++++++++++++++++- api/js/etemplate/et2_extension_nextmatch.ts | 44 ++++++++++++++++++++- api/js/jsapi/egw_app.js | 4 +- api/js/jsapi/egw_app.ts | 4 +- 4 files changed, 80 insertions(+), 8 deletions(-) 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')