Getting etemplate2 sort of working

This commit is contained in:
nathangray
2020-01-21 11:45:21 -07:00
parent 239f75c8b9
commit 5c5d1dd39d
18 changed files with 425 additions and 784 deletions

View File

@ -74,12 +74,12 @@ var ClassWithAttributes = /** @class */ (function () {
*
* @param {object} _attrs is the associative array containing the attributes.
*/
ClassWithAttributes.prototype.generateAttributeSet = function (_attrs) {
ClassWithAttributes.generateAttributeSet = function (widget, _attrs) {
// Sanity check and validation
for (var key in _attrs) {
if (typeof this.attributes[key] != "undefined") {
if (!this.attributes[key].ignore) {
_attrs[key] = et2_checkType(_attrs[key], this.attributes[key].type, key, this);
if (typeof widget[key] != "undefined") {
if (!widget[key].ignore) {
_attrs[key] = et2_checkType(_attrs[key], widget[key].type, key, this);
}
}
else {
@ -90,9 +90,9 @@ var ClassWithAttributes = /** @class */ (function () {
}
}
// Include default values or already set values for this attribute
for (var key in this.attributes) {
for (var key in widget) {
if (typeof _attrs[key] == "undefined") {
var _default = this.attributes[key]["default"];
var _default = widget[key]["default"];
if (_default == et2_no_init) {
_default = undefined;
}
@ -116,6 +116,20 @@ var ClassWithAttributes = /** @class */ (function () {
}
}
};
ClassWithAttributes.buildAttributes = function (class_prototype) {
var class_tree = [];
var attributes = {};
var n = 0;
do {
n++;
class_tree.push(class_prototype);
class_prototype = Object.getPrototypeOf(class_prototype);
} while (class_prototype !== ClassWithAttributes && n < 50);
for (var i = class_tree.length - 1; i > 0; i--) {
class_tree[i - 1]._attributes = ClassWithAttributes.extendAttributes(class_tree[i - 1]._attributes, class_tree[i]._attributes);
}
return class_tree[0]._attributes;
};
/**
* Extend current _attributes with the one from the parent class
*
@ -189,3 +203,4 @@ var ClassWithAttributes = /** @class */ (function () {
return ClassWithAttributes;
}());
exports.ClassWithAttributes = ClassWithAttributes;
//# sourceMappingURL=et2_core_inheritance.js.map