From 676be913872c9f6daa8204bbeae60a19aeb9039b Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 9 Jun 2020 15:21:34 -0600 Subject: [PATCH] Etemplate: Fix TypeScript conversion error in historylog widget Legacy options could not be accessed --- api/js/etemplate/et2_widget_historylog.js | 13 +++++++------ api/js/etemplate/et2_widget_historylog.ts | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/api/js/etemplate/et2_widget_historylog.js b/api/js/etemplate/et2_widget_historylog.js index 7f039f3157..4767099e47 100644 --- a/api/js/etemplate/et2_widget_historylog.js +++ b/api/js/etemplate/et2_widget_historylog.js @@ -341,11 +341,12 @@ var et2_historylog = /** @class */ (function (_super) { // Parse / set legacy options if (options) { var mgr = this.getArrayMgr("content"); - for (var i_3 = 0; i_3 < options.length && i_3 < widget.legacyOptions.length; i_3++) { + var legacy = widget.constructor.legacyOptions || []; + for (var i_3 = 0; i_3 < options.length && i_3 < legacy.length; i_3++) { // Not set if (options[i_3] === "") continue; - var attr = widget.attributes[widget.legacyOptions[i_3]]; + var attr = widget.attributes[legacy[i_3]]; var attrValue = options[i_3]; // If the attribute is marked as boolean, parse the // expression as bool expression. @@ -355,12 +356,12 @@ var et2_historylog = /** @class */ (function (_super) { else { attrValue = mgr.expandName(attrValue); } - attrs[widget.legacyOptions[i_3]] = attrValue; - if (typeof widget['set_' + widget.legacyOptions[i_3]] === 'function') { - widget['set_' + widget.legacyOptions[i_3]].call(widget, attrValue); + attrs[legacy[i_3]] = attrValue; + if (typeof widget['set_' + legacy[i_3]] === 'function') { + widget['set_' + legacy[i_3]].call(widget, attrValue); } else { - widget.options[widget.legacyOptions[i_3]] = attrValue; + widget.options[legacy[i_3]] = attrValue; } } } diff --git a/api/js/etemplate/et2_widget_historylog.ts b/api/js/etemplate/et2_widget_historylog.ts index 08fd01f9cb..12982ca73d 100644 --- a/api/js/etemplate/et2_widget_historylog.ts +++ b/api/js/etemplate/et2_widget_historylog.ts @@ -471,12 +471,13 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider if(options) { const mgr = this.getArrayMgr("content"); - for(let i = 0; i < options.length && i < widget.legacyOptions.length; i++) + let legacy = widget.constructor.legacyOptions || []; + for(let i = 0; i < options.length && i < legacy.length; i++) { // Not set if(options[i] === "") continue; - const attr = widget.attributes[widget.legacyOptions[i]]; + const attr = widget.attributes[legacy[i]]; let attrValue = options[i]; // If the attribute is marked as boolean, parse the @@ -489,14 +490,14 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider { attrValue = mgr.expandName(attrValue); } - attrs[widget.legacyOptions[i]] = attrValue; - if(typeof widget['set_'+widget.legacyOptions[i]] === 'function') + attrs[legacy[i]] = attrValue; + if(typeof widget['set_'+legacy[i]] === 'function') { - widget['set_'+widget.legacyOptions[i]].call(widget, attrValue); + widget['set_'+legacy[i]].call(widget, attrValue); } else { - widget.options[widget.legacyOptions[i]] = attrValue; + widget.options[legacy[i]] = attrValue; } } }