From faed2f97d4829e74ed20de610d6fd9ff0c32f6cc 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 06aa5754e0..8429a3dd14 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -1456,17 +1456,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 @@ -1505,6 +1505,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 f440ce2334..a456c21cb0 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -1997,6 +1997,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(); @@ -2004,13 +2011,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); @@ -2057,6 +2057,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