From a562867671d2265d4ffabfb095056bcfd8eabc96 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 6 Aug 2020 08:40:41 -0600 Subject: [PATCH] Etemplate: Add et2_nextmatch.set_disable_autorefresh() to change it dynamically --- api/js/etemplate/et2_extension_nextmatch.js | 24 +++++++++++++---- api/js/etemplate/et2_extension_nextmatch.ts | 30 ++++++++++++++++----- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index ef840d598b..4b2a7939a5 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -1457,17 +1457,17 @@ var et2_nextmatch = /** @class */ (function (_super) { * @param time int Refresh period, in seconds */ et2_nextmatch.prototype._set_autorefresh = function (time) { + // Start / update timer + if (this._autorefresh_timer) { + window.clearInterval(this._autorefresh_timer); + delete this._autorefresh_timer; + } // Store preference var refresh_preference = "nextmatch-" + this.options.settings.columnselection_pref + "-autorefresh"; var app = this._get_appname(); if (this._get_autorefresh() != time) { this.egw().set_preference(app, refresh_preference, time); } - // Start / update timer - if (this._autorefresh_timer) { - window.clearInterval(this._autorefresh_timer); - delete this._autorefresh_timer; - } if (time > 0) { this._autorefresh_timer = setInterval(jQuery.proxy(this.controller.update, this.controller), time * 1000); // Bind to tab show/hide events, so that we don't bother refreshing in the background @@ -1506,6 +1506,20 @@ var et2_nextmatch = /** @class */ (function (_super) { var refresh_preference = "nextmatch-" + this.options.settings.columnselection_pref + "-autorefresh"; return this.egw().preference(refresh_preference, this._get_appname()); }; + /** + * Enable or disable autorefresh + * + * If false, autorefresh will be shown in column selection. If the user already has an autorefresh preference + * for this nextmatch, the timer will be started. + * + * If true, the timer will be stopped and autorefresh will not be shown in column selection + * + * @param disabled + */ + et2_nextmatch.prototype.set_disable_autorefresh = function (disabled) { + this.options.disable_autorefresh = disabled; + this._set_autorefresh(this._get_autorefresh()); + }; /** * When the template attribute is set, the nextmatch widget tries to load * that template and to fetch the grid which is inside of it. It then calls diff --git a/api/js/etemplate/et2_extension_nextmatch.ts b/api/js/etemplate/et2_extension_nextmatch.ts index 737431c61b..20813f0eb5 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -1998,6 +1998,13 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 */ _set_autorefresh( time) { + // Start / update timer + if (this._autorefresh_timer) + { + window.clearInterval(this._autorefresh_timer); + delete this._autorefresh_timer; + } + // Store preference const refresh_preference = "nextmatch-" + this.options.settings.columnselection_pref + "-autorefresh"; const app = this._get_appname(); @@ -2005,13 +2012,6 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 { this.egw().set_preference(app,refresh_preference,time); } - - // Start / update timer - if (this._autorefresh_timer) - { - window.clearInterval(this._autorefresh_timer); - delete this._autorefresh_timer; - } if(time > 0) { this._autorefresh_timer = setInterval(jQuery.proxy(this.controller.update, this.controller), time * 1000); @@ -2058,6 +2058,22 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 return this.egw().preference(refresh_preference,this._get_appname()); } + /** + * Enable or disable autorefresh + * + * If false, autorefresh will be shown in column selection. If the user already has an autorefresh preference + * for this nextmatch, the timer will be started. + * + * If true, the timer will be stopped and autorefresh will not be shown in column selection + * + * @param disabled + */ + set_disable_autorefresh( disabled : boolean) + { + this.options.disable_autorefresh = disabled; + this._set_autorefresh(this._get_autorefresh()); + } + /** * When the template attribute is set, the nextmatch widget tries to load * that template and to fetch the grid which is inside of it. It then calls