Api: Fix favorites widget TypeScript conversion bugs

This commit is contained in:
nathangray 2020-05-20 15:27:38 -06:00
parent a29d79a7ab
commit 866cc19440
2 changed files with 16 additions and 5 deletions

View File

@ -82,6 +82,10 @@ var et2_favorites = /** @class */ (function (_super) {
_this.favSortedList = ['blank']; _this.favSortedList = ['blank'];
var apps = egw().user('apps'); var apps = egw().user('apps');
et2_favorites.is_admin = (typeof apps['admin'] != "undefined"); 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.stored_filters = _this.load_favorites(_this.options.app);
_this.preferred = egw.preference(_this.options.default_pref, _this.options.app); _this.preferred = egw.preference(_this.options.default_pref, _this.options.app);
if (!_this.preferred || typeof _this.stored_filters[_this.preferred] == "undefined") { if (!_this.preferred || typeof _this.stored_filters[_this.preferred] == "undefined") {
@ -165,8 +169,8 @@ var et2_favorites = /** @class */ (function (_super) {
// Load saved favorites // Load saved favorites
var preferences = egw.preference("*", app); var preferences = egw.preference("*", app);
for (var pref_name in preferences) { for (var 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') {
var name_1 = pref_name.substr(this.favorite_prefix.length); var name_1 = pref_name.substr(et2_favorites.PREFIX.length);
stored_filters[name_1] = preferences[pref_name]; stored_filters[name_1] = preferences[pref_name];
// Keep older favorites working - they used to store nm filters in 'filters',not state // Keep older favorites working - they used to store nm filters in 'filters',not state
if (preferences[pref_name]["filters"]) { if (preferences[pref_name]["filters"]) {
@ -337,6 +341,7 @@ var et2_favorites = /** @class */ (function (_super) {
image: { "default": egw().image('fav_filter') }, image: { "default": egw().image('fav_filter') },
statustext: { "default": "Favorite queries", "type": "string" } statustext: { "default": "Favorite queries", "type": "string" }
}; };
et2_favorites.PREFIX = "favorite_";
return et2_favorites; return et2_favorites;
}(et2_widget_dropdown_button_1.et2_dropdown_button)); }(et2_widget_dropdown_button_1.et2_dropdown_button));
et2_core_widget_1.et2_register_widget(et2_favorites, ["favorites"]); et2_core_widget_1.et2_register_widget(et2_favorites, ["favorites"]);

View File

@ -82,7 +82,7 @@ class et2_favorites extends et2_dropdown_button implements et2_INextmatchHeader
// Some convenient variables, used in closures / event handlers // Some convenient variables, used in closures / event handlers
header = null; header = null;
nextmatch = null; nextmatch = null;
favorite_prefix: "favorite_"; public static readonly PREFIX = "favorite_";
private stored_filters: {}; private stored_filters: {};
private favSortedList : any = null; private favSortedList : any = null;
private sidebox_target : JQuery = 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'); let apps = egw().user('apps');
et2_favorites.is_admin = (typeof apps['admin'] != "undefined"); 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.stored_filters = this.load_favorites(this.options.app);
this.preferred = egw.preference(this.options.default_pref,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); let preferences : any = egw.preference("*",app);
for(let pref_name in preferences) 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]; stored_filters[name] = preferences[pref_name];
// Keep older favorites working - they used to store nm filters in 'filters',not state // Keep older favorites working - they used to store nm filters in 'filters',not state
if(preferences[pref_name]["filters"]) if(preferences[pref_name]["filters"])