Etemplate: Fix TypeScript conversion error in historylog widget

Legacy options could not be accessed
This commit is contained in:
nathangray 2020-06-09 15:21:34 -06:00
parent 15a252c151
commit 676be91387
2 changed files with 14 additions and 12 deletions

View File

@ -341,11 +341,12 @@ var et2_historylog = /** @class */ (function (_super) {
// Parse / set legacy options // Parse / set legacy options
if (options) { if (options) {
var mgr = this.getArrayMgr("content"); 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 // Not set
if (options[i_3] === "") if (options[i_3] === "")
continue; continue;
var attr = widget.attributes[widget.legacyOptions[i_3]]; var attr = widget.attributes[legacy[i_3]];
var attrValue = options[i_3]; var attrValue = options[i_3];
// If the attribute is marked as boolean, parse the // If the attribute is marked as boolean, parse the
// expression as bool expression. // expression as bool expression.
@ -355,12 +356,12 @@ var et2_historylog = /** @class */ (function (_super) {
else { else {
attrValue = mgr.expandName(attrValue); attrValue = mgr.expandName(attrValue);
} }
attrs[widget.legacyOptions[i_3]] = attrValue; attrs[legacy[i_3]] = attrValue;
if (typeof widget['set_' + widget.legacyOptions[i_3]] === 'function') { if (typeof widget['set_' + legacy[i_3]] === 'function') {
widget['set_' + widget.legacyOptions[i_3]].call(widget, attrValue); widget['set_' + legacy[i_3]].call(widget, attrValue);
} }
else { else {
widget.options[widget.legacyOptions[i_3]] = attrValue; widget.options[legacy[i_3]] = attrValue;
} }
} }
} }

View File

@ -471,12 +471,13 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
if(options) if(options)
{ {
const mgr = this.getArrayMgr("content"); 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 // Not set
if(options[i] === "") continue; if(options[i] === "") continue;
const attr = widget.attributes[widget.legacyOptions[i]]; const attr = widget.attributes[legacy[i]];
let attrValue = options[i]; let attrValue = options[i];
// If the attribute is marked as boolean, parse the // 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); attrValue = mgr.expandName(attrValue);
} }
attrs[widget.legacyOptions[i]] = attrValue; attrs[legacy[i]] = attrValue;
if(typeof widget['set_'+widget.legacyOptions[i]] === 'function') if(typeof widget['set_'+legacy[i]] === 'function')
{ {
widget['set_'+widget.legacyOptions[i]].call(widget, attrValue); widget['set_'+legacy[i]].call(widget, attrValue);
} }
else else
{ {
widget.options[widget.legacyOptions[i]] = attrValue; widget.options[legacy[i]] = attrValue;
} }
} }
} }