diff --git a/api/js/etemplate/et2_widget_favorites.js b/api/js/etemplate/et2_widget_favorites.js index 962fbfe0a3..3c893f5804 100644 --- a/api/js/etemplate/et2_widget_favorites.js +++ b/api/js/etemplate/et2_widget_favorites.js @@ -82,6 +82,10 @@ var et2_favorites = /** @class */ (function (_super) { _this.favSortedList = ['blank']; var apps = egw().user('apps'); et2_favorites.is_admin = (typeof apps['admin'] != "undefined"); + // Make sure we have an app + if (!_this.options.app) { + _this.options.app = _this.getInstanceManager().app; + } _this.stored_filters = _this.load_favorites(_this.options.app); _this.preferred = egw.preference(_this.options.default_pref, _this.options.app); if (!_this.preferred || typeof _this.stored_filters[_this.preferred] == "undefined") { @@ -165,8 +169,8 @@ var et2_favorites = /** @class */ (function (_super) { // Load saved favorites var preferences = egw.preference("*", app); for (var pref_name in preferences) { - if (pref_name.indexOf(this.favorite_prefix) == 0 && typeof preferences[pref_name] == 'object') { - var name_1 = pref_name.substr(this.favorite_prefix.length); + if (pref_name.indexOf(et2_favorites.PREFIX) == 0 && typeof preferences[pref_name] == 'object') { + var name_1 = pref_name.substr(et2_favorites.PREFIX.length); stored_filters[name_1] = preferences[pref_name]; // Keep older favorites working - they used to store nm filters in 'filters',not state if (preferences[pref_name]["filters"]) { @@ -337,6 +341,7 @@ var et2_favorites = /** @class */ (function (_super) { image: { "default": egw().image('fav_filter') }, statustext: { "default": "Favorite queries", "type": "string" } }; + et2_favorites.PREFIX = "favorite_"; return et2_favorites; }(et2_widget_dropdown_button_1.et2_dropdown_button)); et2_core_widget_1.et2_register_widget(et2_favorites, ["favorites"]); diff --git a/api/js/etemplate/et2_widget_favorites.ts b/api/js/etemplate/et2_widget_favorites.ts index 0144e52f7f..49b302bcfe 100644 --- a/api/js/etemplate/et2_widget_favorites.ts +++ b/api/js/etemplate/et2_widget_favorites.ts @@ -82,7 +82,7 @@ class et2_favorites extends et2_dropdown_button implements et2_INextmatchHeader // Some convenient variables, used in closures / event handlers header = null; nextmatch = null; - favorite_prefix: "favorite_"; + public static readonly PREFIX = "favorite_"; private stored_filters: {}; private favSortedList : any = null; private sidebox_target : JQuery = null; @@ -113,6 +113,12 @@ class et2_favorites extends et2_dropdown_button implements et2_INextmatchHeader let apps = egw().user('apps'); et2_favorites.is_admin = (typeof apps['admin'] != "undefined"); + // Make sure we have an app + if(!this.options.app) + { + this.options.app = this.getInstanceManager().app; + } + this.stored_filters = this.load_favorites(this.options.app); this.preferred = egw.preference(this.options.default_pref,this.options.app); @@ -224,9 +230,9 @@ class et2_favorites extends et2_dropdown_button implements et2_INextmatchHeader let preferences : any = egw.preference("*",app); for(let pref_name in preferences) { - if(pref_name.indexOf(this.favorite_prefix) == 0 && typeof preferences[pref_name] == 'object') + if(pref_name.indexOf(et2_favorites.PREFIX) == 0 && typeof preferences[pref_name] == 'object') { - let name = pref_name.substr(this.favorite_prefix.length); + let name = pref_name.substr(et2_favorites.PREFIX.length); stored_filters[name] = preferences[pref_name]; // Keep older favorites working - they used to store nm filters in 'filters',not state if(preferences[pref_name]["filters"])