From b5af4032385ae2baba9912b1a7494f2f831697bf Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 10 Feb 2020 14:14:17 -0700 Subject: [PATCH] Fix template namespace --- api/js/etemplate/et2_core_widget.js | 6 ++++-- api/js/etemplate/et2_core_widget.ts | 6 ++++-- api/js/etemplate/et2_widget_template.js | 8 ++++---- api/js/etemplate/et2_widget_template.ts | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/api/js/etemplate/et2_core_widget.js b/api/js/etemplate/et2_core_widget.js index 9b1fd1a96c..5595818e3a 100644 --- a/api/js/etemplate/et2_core_widget.js +++ b/api/js/etemplate/et2_core_widget.js @@ -161,7 +161,7 @@ var et2_widget = /** @class */ (function (_super) { if (_attrs["id"]) { // Create a namespace for this object if (_this._createNamespace()) { - _this.checkCreateNamespace(); + _this.checkCreateNamespace(_attrs); } } if (_this.id) { @@ -783,8 +783,10 @@ var et2_widget = /** @class */ (function (_super) { * Checks whether a namespace exists for this element in the content array. * If yes, an own perspective of the content array is created. If not, the * parent content manager is used. + * + * Constructor attributes are passed in case a child needs to make decisions */ - et2_widget.prototype.checkCreateNamespace = function () { + et2_widget.prototype.checkCreateNamespace = function (_attrs) { // Get the content manager var mgrs = this.getArrayMgrs(); for (var key in mgrs) { diff --git a/api/js/etemplate/et2_core_widget.ts b/api/js/etemplate/et2_core_widget.ts index 55dbc9d2e9..3672b416ed 100644 --- a/api/js/etemplate/et2_core_widget.ts +++ b/api/js/etemplate/et2_core_widget.ts @@ -233,7 +233,7 @@ export class et2_widget extends ClassWithAttributes if (_attrs["id"]) { // Create a namespace for this object if (this._createNamespace()) { - this.checkCreateNamespace(); + this.checkCreateNamespace(_attrs); } } @@ -967,8 +967,10 @@ Comment this out (for now) * Checks whether a namespace exists for this element in the content array. * If yes, an own perspective of the content array is created. If not, the * parent content manager is used. + * + * Constructor attributes are passed in case a child needs to make decisions */ - checkCreateNamespace() + checkCreateNamespace(_attrs? : any) { // Get the content manager var mgrs = this.getArrayMgrs(); diff --git a/api/js/etemplate/et2_widget_template.js b/api/js/etemplate/et2_widget_template.js index cc02db8df7..66d3d2c0fe 100644 --- a/api/js/etemplate/et2_widget_template.js +++ b/api/js/etemplate/et2_widget_template.js @@ -139,10 +139,10 @@ var et2_template = /** @class */ (function (_super) { * Templates always have ID set, but seldom do we want them to * create a namespace based on their ID. */ - et2_template.prototype.checkCreateNamespace = function () { - if (this.content) { - var old_id = this.id; - this.id = this.content; + et2_template.prototype.checkCreateNamespace = function (_attrs) { + if (_attrs.content) { + var old_id = _attrs.id; + this.id = _attrs.content; _super.prototype.checkCreateNamespace.apply(this, arguments); this.id = old_id; } diff --git a/api/js/etemplate/et2_widget_template.ts b/api/js/etemplate/et2_widget_template.ts index bcb53079e1..db24b99f5a 100644 --- a/api/js/etemplate/et2_widget_template.ts +++ b/api/js/etemplate/et2_widget_template.ts @@ -191,12 +191,12 @@ class et2_template extends et2_DOMWidget * Templates always have ID set, but seldom do we want them to * create a namespace based on their ID. */ - checkCreateNamespace() + checkCreateNamespace(_attrs) { - if(this.content) + if(_attrs.content) { - var old_id = this.id; - this.id = this.content; + var old_id = _attrs.id; + this.id = _attrs.content; super.checkCreateNamespace.apply(this, arguments); this.id = old_id; }