2021-08-10 23:02:52 +02:00
|
|
|
import {et2_IDOMNode, et2_implements_registry} from "./et2_core_interfaces";
|
|
|
|
import {et2_arrayMgr} from "./et2_core_arrayMgr";
|
|
|
|
import {et2_attribute_registry, et2_registry, et2_widget} from "./et2_core_widget";
|
|
|
|
import {etemplate2} from "./etemplate2";
|
|
|
|
import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions";
|
|
|
|
import {et2_cloneObject, et2_csvSplit} from "./et2_core_common";
|
|
|
|
// @ts-ignore
|
|
|
|
import {IegwAppLocal} from "../jsapi/egw_global";
|
|
|
|
import {ClassWithAttributes, ClassWithInterfaces} from "./et2_core_inheritance";
|
2021-08-12 18:32:05 +02:00
|
|
|
import {LitElement} from "@lion/core";
|
2021-08-10 23:02:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This mixin will allow any LitElement to become an Et2Widget
|
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* @example
|
|
|
|
* export class Et2Loading extends Et2Widget(BXLoading) { ... }
|
|
|
|
* @example
|
|
|
|
* export class Et2Button extends Et2InputWidget(Et2Widget(BXButton)) { ... }
|
|
|
|
*
|
|
|
|
* @see Mixin explanation https://lit.dev/docs/composition/mixins/
|
|
|
|
*/
|
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
type Constructor<T = {}> = new (...args : any[]) => T;
|
|
|
|
export const Et2Widget = <T extends Constructor<LitElement>>(superClass : T) =>
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
class Et2WidgetClass extends superClass implements et2_IDOMNode
|
|
|
|
{
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/** et2_widget compatability **/
|
2021-08-19 01:41:23 +02:00
|
|
|
protected _mgrs : et2_arrayMgr[] = [];
|
|
|
|
protected _parent : Et2WidgetClass | et2_widget | null = null;
|
|
|
|
private _inst : etemplate2 | null = null;
|
2021-08-13 23:26:18 +02:00
|
|
|
private supportedWidgetClasses = [];
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Not actually required by et2_widget, but needed to keep track of non-webComponent children
|
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
private _legacy_children : et2_widget[] = [];
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
2021-08-19 18:54:32 +02:00
|
|
|
* Properties - default values, and actually creating them as fields
|
2021-08-13 23:26:18 +02:00
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
private label : string = "";
|
|
|
|
private statustext : string = "";
|
2021-08-19 18:54:32 +02:00
|
|
|
private disabled : Boolean = false;
|
2021-08-10 23:02:52 +02:00
|
|
|
|
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/** WebComponent **/
|
|
|
|
static get properties()
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
...super.properties,
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 18:54:32 +02:00
|
|
|
/**
|
|
|
|
* Defines whether this widget is visible.
|
|
|
|
* Not to be confused with an input widget's HTML attribute 'disabled'.",
|
|
|
|
*/
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
reflect: true
|
|
|
|
},
|
|
|
|
|
2021-08-10 23:02:52 +02:00
|
|
|
/**
|
2021-08-13 23:26:18 +02:00
|
|
|
* Tooltip which is shown for this element on hover
|
2021-08-10 23:02:52 +02:00
|
|
|
*/
|
2021-08-13 23:26:18 +02:00
|
|
|
statustext: {type: String},
|
|
|
|
|
|
|
|
label: {type: String},
|
|
|
|
onclick: {
|
|
|
|
type: Function,
|
|
|
|
converter: (value) =>
|
|
|
|
{
|
|
|
|
debugger;
|
|
|
|
return et2_compileLegacyJS(value, this, this);
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
};
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Widget Mixin constructor
|
|
|
|
*
|
|
|
|
* Note the ...args parameter and super() call
|
|
|
|
*
|
|
|
|
* @param args
|
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
constructor(...args : any[])
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
super(...args);
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
connectedCallback()
|
|
|
|
{
|
|
|
|
super.connectedCallback();
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
this.set_label(this.label);
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.statustext)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this.egw().tooltipBind(this, this.statustext);
|
|
|
|
}
|
2021-08-19 18:54:32 +02:00
|
|
|
if(this.onclick && !this.disabled)
|
|
|
|
{
|
|
|
|
this.addEventListener("click", this._handleClick.bind(this));
|
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
disconnectedCallback()
|
|
|
|
{
|
|
|
|
this.egw().tooltipUnbind(this);
|
2021-08-19 18:54:32 +02:00
|
|
|
|
|
|
|
this.removeEventListener("click", this._handleClick.bind(this));
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* NOT the setter, since we cannot add to the DOM before connectedCallback()
|
|
|
|
*
|
|
|
|
* TODO: This is not best practice. Should just set property, DOM modification should be done in render
|
|
|
|
* https://lit-element.polymer-project.org/guide/templates#design-a-performant-template
|
|
|
|
*
|
|
|
|
* @param value
|
|
|
|
*/
|
|
|
|
set_label(value)
|
|
|
|
{
|
|
|
|
let oldValue = this.label;
|
|
|
|
|
|
|
|
// Remove old
|
|
|
|
let oldLabels = this.getElementsByClassName("et2_label");
|
2021-08-19 01:41:23 +02:00
|
|
|
while(oldLabels[0])
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this.removeChild(oldLabels[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.label = value;
|
2021-08-19 01:41:23 +02:00
|
|
|
if(value)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
let label = document.createElement("span");
|
|
|
|
label.classList.add("et2_label");
|
|
|
|
label.textContent = this.label;
|
|
|
|
// We should have a slot in the template for the label
|
|
|
|
//label.slot="label";
|
|
|
|
this.appendChild(label);
|
|
|
|
this.requestUpdate('label', oldValue);
|
|
|
|
}
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Event handlers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler calling custom handler set via onclick attribute to this.onclick
|
|
|
|
*
|
|
|
|
* @param _ev
|
|
|
|
* @returns
|
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
_handleClick(_ev : MouseEvent) : boolean
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
if (typeof this.onclick == 'function')
|
|
|
|
{
|
|
|
|
// Make sure function gets a reference to the widget, splice it in as 2. argument if not
|
|
|
|
var args = Array.prototype.slice.call(arguments);
|
2021-08-19 01:41:23 +02:00
|
|
|
if(args.indexOf(this) == -1) args.splice(1, 0, this);
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
return this.onclick.apply(this, args);
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
return true;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/** et2_widget compatability **/
|
|
|
|
destroy()
|
|
|
|
{
|
|
|
|
// Not really needed, use the disconnectedCallback() and let the browser handle it
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
isInTree() : boolean
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
// TODO: Probably should watch the state or something
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads the widget tree from an XML node
|
|
|
|
*
|
|
|
|
* @param _node xml node
|
|
|
|
*/
|
|
|
|
loadFromXML(_node)
|
|
|
|
{
|
|
|
|
// Load the child nodes.
|
2021-08-19 01:41:23 +02:00
|
|
|
for(var i = 0; i < _node.childNodes.length; i++)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
var node = _node.childNodes[i];
|
|
|
|
var widgetType = node.nodeName.toLowerCase();
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
if(widgetType == "#comment")
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
continue;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
if(widgetType == "#text")
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(node.data.replace(/^\s+|\s+$/g, ''))
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this.innerText = node.data;
|
|
|
|
}
|
|
|
|
continue;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Create the new element
|
|
|
|
this.createElementFromNode(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a et2_widget from an XML node.
|
|
|
|
*
|
|
|
|
* First the type and attributes are read from the node. Then the readonly & modifications
|
|
|
|
* arrays are checked for changes specific to the loaded data. Then the appropriate
|
|
|
|
* constructor is called. After the constructor returns, the widget has a chance to
|
|
|
|
* further initialize itself from the XML node when the widget's loadFromXML() method
|
|
|
|
* is called with the node.
|
|
|
|
*
|
|
|
|
* @param _node XML node to read
|
|
|
|
* @param _name XML node name
|
|
|
|
*
|
|
|
|
* @return et2_widget
|
|
|
|
*/
|
|
|
|
createElementFromNode(_node, _name?)
|
|
|
|
{
|
|
|
|
var attributes = {};
|
2021-08-19 01:41:23 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Parse the "readonly" and "type" flag for this element here, as they
|
|
|
|
// determine which constructor is used
|
2021-08-19 18:54:32 +02:00
|
|
|
let _nodeName = attributes["type"] = _node.getAttribute("type") ?
|
2021-08-13 23:26:18 +02:00
|
|
|
_node.getAttribute("type") : _node.nodeName.toLowerCase();
|
2021-08-19 18:54:32 +02:00
|
|
|
const readonly = attributes["readonly"] = this.getArrayMgr("readonlys") ?
|
|
|
|
(<any>this.getArrayMgr("readonlys")).isReadOnly(
|
|
|
|
_node.getAttribute("id"), _node.getAttribute("readonly"),
|
|
|
|
typeof this.readonly !== "undefined" ? this.readonly : false) : false;
|
2021-08-13 23:26:18 +02:00
|
|
|
|
|
|
|
// Check to see if modifications change type
|
|
|
|
var modifications = this.getArrayMgr("modifications");
|
2021-08-19 01:41:23 +02:00
|
|
|
if(modifications && _node.getAttribute("id"))
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
let entry : any = modifications.getEntry(_node.getAttribute("id"));
|
|
|
|
if(entry == null)
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
// Try again, but skip the fancy stuff
|
|
|
|
// TODO: Figure out why the getEntry() call doesn't always work
|
|
|
|
entry = modifications.data[_node.getAttribute("id")];
|
2021-08-19 01:41:23 +02:00
|
|
|
if(entry)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this.egw().debug("warn", "getEntry(" + _node.getAttribute("id") + ") failed, but the data is there.", modifications, entry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Try the root, in case a namespace got missed
|
|
|
|
entry = modifications.getRoot().getEntry(_node.getAttribute("id"));
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-19 01:41:23 +02:00
|
|
|
if(entry && entry.type && typeof entry.type === 'string')
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
_nodeName = attributes["type"] = entry.type;
|
|
|
|
}
|
|
|
|
entry = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if _nodeName / type-attribute contains something to expand (eg. type="@${row}[type]"),
|
|
|
|
// we need to expand it now as it defines the constructor and by that attributes parsed via parseXMLAttrs!
|
2021-08-19 01:41:23 +02:00
|
|
|
if(_nodeName.charAt(0) == '@' || _nodeName.indexOf('$') >= 0)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
_nodeName = attributes["type"] = this.getArrayMgr('content').expandName(_nodeName);
|
|
|
|
}
|
|
|
|
|
|
|
|
let widget = null;
|
2021-08-19 01:41:23 +02:00
|
|
|
if(undefined == window.customElements.get(_nodeName))
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
// Get the constructor - if the widget is readonly, use the special "_ro"
|
|
|
|
// constructor if it is available
|
|
|
|
var constructor = et2_registry[typeof et2_registry[_nodeName] == "undefined" ? 'placeholder' : _nodeName];
|
2021-08-19 01:41:23 +02:00
|
|
|
if(readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
constructor = et2_registry[_nodeName + "_ro"];
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Parse the attributes from the given XML attributes object
|
|
|
|
this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype);
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Do an sanity check for the attributes
|
|
|
|
ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], attributes);
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Creates the new widget, passes this widget as an instance and
|
|
|
|
// passes the widgetType. Then it goes on loading the XML for it.
|
|
|
|
widget = new constructor(this, attributes);
|
|
|
|
|
|
|
|
// Load the widget itself from XML
|
|
|
|
widget.loadFromXML(_node);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-19 18:54:32 +02:00
|
|
|
if(readonly === true && typeof window.customElements.get(_nodeName + "_ro") != "undefined")
|
|
|
|
{
|
|
|
|
_nodeName += "_ro";
|
|
|
|
}
|
|
|
|
widget = loadWebComponent(_nodeName, _node, this);
|
2021-08-13 23:26:18 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.addChild)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
// webcomponent going into old et2_widget
|
|
|
|
this.addChild(widget);
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
|
|
|
return widget;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* The parseXMLAttrs function takes an XML DOM attributes object
|
|
|
|
* and adds the given attributes to the _target associative array. This
|
|
|
|
* function also parses the legacyOptions.
|
|
|
|
*
|
|
|
|
* @param _attrsObj is the XML DOM attributes object
|
|
|
|
* @param {object} _target is the object to which the attributes should be written.
|
|
|
|
* @param {et2_widget} _proto prototype with attributes and legacyOptions attribute
|
|
|
|
*/
|
|
|
|
parseXMLAttrs(_attrsObj, _target, _proto)
|
|
|
|
{
|
|
|
|
// Check whether the attributes object is really existing, if not abort
|
2021-08-19 01:41:23 +02:00
|
|
|
if(typeof _attrsObj == "undefined")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Iterate over the given attributes and parse them
|
|
|
|
var mgr = this.getArrayMgr("content");
|
2021-08-19 01:41:23 +02:00
|
|
|
for(var i = 0; i < _attrsObj.length; i++)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
var attrName = _attrsObj[i].name;
|
|
|
|
var attrValue = _attrsObj[i].value;
|
|
|
|
|
|
|
|
// Special handling for the legacy options
|
2021-08-19 01:41:23 +02:00
|
|
|
if(attrName == "options" && _proto.constructor.legacyOptions && _proto.constructor.legacyOptions.length > 0)
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
let legacy = _proto.constructor.legacyOptions || [];
|
|
|
|
let attrs = et2_attribute_registry[Object.getPrototypeOf(_proto).constructor.name] || {};
|
|
|
|
// Check for modifications on legacy options here. Normal modifications
|
|
|
|
// are handled in widget constructor, but it's too late for legacy options then
|
2021-08-19 01:41:23 +02:00
|
|
|
if(_target.id && this.getArrayMgr("modifications").getEntry(_target.id))
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
var mod : any = this.getArrayMgr("modifications").getEntry(_target.id);
|
|
|
|
if(typeof mod.options != "undefined") attrValue = _attrsObj[i].value = mod.options;
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
|
|
|
// expand legacyOptions with content
|
2021-08-19 01:41:23 +02:00
|
|
|
if(attrValue.charAt(0) == '@' || attrValue.indexOf('$') != -1)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
attrValue = mgr.expandName(attrValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the legacy options (as a string, other types not allowed)
|
|
|
|
var splitted = et2_csvSplit(attrValue + "");
|
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
for(var j = 0; j < splitted.length && j < legacy.length; j++)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
// Blank = not set, unless there's more legacy options provided after
|
2021-08-19 01:41:23 +02:00
|
|
|
if(splitted[j].trim().length === 0 && legacy.length >= splitted.length) continue;
|
2021-08-13 23:26:18 +02:00
|
|
|
|
|
|
|
// Check to make sure we don't overwrite a current option with a legacy option
|
2021-08-19 01:41:23 +02:00
|
|
|
if(typeof _target[legacy[j]] === "undefined")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
attrValue = splitted[j];
|
|
|
|
|
|
|
|
/**
|
2021-08-10 23:02:52 +02:00
|
|
|
If more legacy options than expected, stuff them all in the last legacy option
|
|
|
|
Some legacy options take a comma separated list.
|
2021-08-13 23:26:18 +02:00
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
if(j == legacy.length - 1 && splitted.length > legacy.length)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
attrValue = splitted.slice(j);
|
|
|
|
}
|
|
|
|
|
|
|
|
var attr = et2_attribute_registry[_proto.constructor.name][legacy[j]] || {};
|
|
|
|
|
|
|
|
// If the attribute is marked as boolean, parse the
|
|
|
|
// expression as bool expression.
|
2021-08-19 01:41:23 +02:00
|
|
|
if(attr.type == "boolean")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
attrValue = mgr.parseBoolExpression(attrValue);
|
|
|
|
}
|
2021-08-19 01:41:23 +02:00
|
|
|
else if(typeof attrValue != "object")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
attrValue = mgr.expandName(attrValue);
|
|
|
|
}
|
|
|
|
_target[legacy[j]] = attrValue;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-19 01:41:23 +02:00
|
|
|
else if(attrName == "readonly" && typeof _target[attrName] != "undefined")
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
// do NOT overwrite already evaluated readonly attribute
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
else
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
let attrs = et2_attribute_registry[_proto.constructor.name] || {};
|
2021-08-19 01:41:23 +02:00
|
|
|
if(mgr != null && typeof attrs[attrName] != "undefined")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
var attr = attrs[attrName];
|
|
|
|
|
|
|
|
// If the attribute is marked as boolean, parse the
|
|
|
|
// expression as bool expression.
|
2021-08-19 01:41:23 +02:00
|
|
|
if(attr.type == "boolean")
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
attrValue = mgr.parseBoolExpression(attrValue);
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
else
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
attrValue = mgr.expandName(attrValue);
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the attribute
|
|
|
|
_target[attrName] = attrValue;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
iterateOver(_callback : Function, _context, _type)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(et2_implements_registry[_type] && et2_implements_registry[_type](this))
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
_callback.call(_context, this);
|
|
|
|
}
|
|
|
|
// TODO: children
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Needed for legacy compatability.
|
|
|
|
*
|
|
|
|
* @param {Promise[]} promises List of promises from widgets that are not done. Pass an empty array, it will be filled if needed.
|
|
|
|
*/
|
|
|
|
loadingFinished(promises)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* This is needed mostly as a bridge between non-WebComponent widgets and
|
|
|
|
* connectedCallback(). It's not really needed if the whole tree is WebComponent.
|
|
|
|
* WebComponents can be added as children immediately after creation, and they handle the
|
|
|
|
* rest themselves with their normal lifecycle (especially connectedCallback(), which is kind
|
|
|
|
* of the equivalent of doLoadingFinished()
|
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.getParent() instanceof et2_widget)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this.getParent().getDOMNode(this).append(this);
|
|
|
|
}
|
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
for(let i = 0; i < this._legacy_children.length; i++)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
let child = this._legacy_children[i];
|
|
|
|
let child_node = typeof child.getDOMNode !== "undefined" ? child.getDOMNode(child) : null;
|
2021-08-19 01:41:23 +02:00
|
|
|
if(child_node && child_node !== this)
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
this.append(child_node);
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
child.loadingFinished(promises);
|
|
|
|
}
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
getWidgetById(_id)
|
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.id == _id)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
setParent(new_parent : Et2WidgetClass | et2_widget)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this._parent = new_parent;
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.id)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
// Create a namespace for this object
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this._createNamespace())
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this.checkCreateNamespace();
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
getParent() : HTMLElement | et2_widget
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
let parentNode = this.parentNode;
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// If parent is an old et2_widget, use it
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this._parent)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this._parent;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
return <HTMLElement>parentNode;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
addChild(child : et2_widget | Et2WidgetClass)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(child instanceof et2_widget)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
child._parent = this;
|
|
|
|
|
|
|
|
// During legacy widget creation, the child's DOM node won't be available yet.
|
|
|
|
this._legacy_children.push(child);
|
2021-08-19 01:41:23 +02:00
|
|
|
let child_node = null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
child_node = typeof child.getDOMNode !== "undefined" ? child.getDOMNode(child) : null;
|
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
// Child did not give up its DOM node nicely but errored instead
|
|
|
|
}
|
|
|
|
if(child_node && child_node !== this)
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
this.append(child_node);
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.append(child);
|
|
|
|
}
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Get [legacy] children
|
|
|
|
* Use <obj>.children to get web component children
|
|
|
|
* @returns {et2_widget[]}
|
|
|
|
*/
|
|
|
|
getChildren()
|
|
|
|
{
|
|
|
|
return this._legacy_children;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
getType() : string
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this.nodeName;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
getDOMNode() : HTMLElement
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
/**
|
|
|
|
* Creates a copy of this widget.
|
|
|
|
*
|
|
|
|
* @param {et2_widget} _parent parent to set for clone, default null
|
|
|
|
*/
|
|
|
|
clone(_parent?) : Et2WidgetClass
|
|
|
|
{
|
|
|
|
// Default _parent to null
|
|
|
|
if(typeof _parent == "undefined")
|
|
|
|
{
|
|
|
|
_parent = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the copy
|
|
|
|
var copy = <Et2WidgetClass>this.cloneNode(true);
|
|
|
|
|
|
|
|
// Create a clone of all child widgets of the given object
|
|
|
|
for(var i = 0; i < copy.getChildren().length; i++)
|
|
|
|
{
|
|
|
|
copy.addChild(copy.getChildren()[i].clone(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy a reference to the content array manager
|
|
|
|
copy.setArrayMgrs(this.getArrayMgrs());
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Sets the array manager for the given part
|
|
|
|
*
|
|
|
|
* @param {string} _part which array mgr to set
|
|
|
|
* @param {object} _mgr
|
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
setArrayMgr(_part : string, _mgr : et2_arrayMgr)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this._mgrs[_part] = _mgr;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Returns the array manager object for the given part
|
|
|
|
*
|
|
|
|
* @param {string} managed_array_type name of array mgr to return
|
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
getArrayMgr(managed_array_type : string) : et2_arrayMgr | null
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this._mgrs && typeof this._mgrs[managed_array_type] != "undefined")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this._mgrs[managed_array_type];
|
|
|
|
}
|
2021-08-19 01:41:23 +02:00
|
|
|
else if(this.getParent())
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this.getParent().getArrayMgr(managed_array_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Sets all array manager objects - this function can be used to set the
|
|
|
|
* root array managers of the container object.
|
|
|
|
*
|
|
|
|
* @param {object} _mgrs
|
|
|
|
*/
|
|
|
|
setArrayMgrs(_mgrs)
|
|
|
|
{
|
|
|
|
this._mgrs = <et2_arrayMgr[]>et2_cloneObject(_mgrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an associative array containing the top-most array managers.
|
|
|
|
*
|
|
|
|
* @param _mgrs is used internally and should not be supplied.
|
|
|
|
*/
|
2021-08-19 01:41:23 +02:00
|
|
|
getArrayMgrs(_mgrs? : object)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(typeof _mgrs == "undefined")
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
_mgrs = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add all managers of this object to the result, if they have not already
|
|
|
|
// been set in the result
|
2021-08-19 01:41:23 +02:00
|
|
|
for(var key in this._mgrs)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(typeof _mgrs[key] == "undefined")
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
_mgrs[key] = this._mgrs[key];
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Recursively applies this function to the parent widget
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this._parent)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
this._parent.getArrayMgrs(_mgrs);
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
return _mgrs;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
{
|
|
|
|
// Get the content manager
|
|
|
|
var mgrs = this.getArrayMgrs();
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
for(var key in mgrs)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
var mgr = mgrs[key];
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Get the original content manager if we have already created a
|
|
|
|
// perspective for this node
|
2021-08-19 01:41:23 +02:00
|
|
|
if(typeof this._mgrs[key] != "undefined" && mgr.perspectiveData.owner == this)
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
mgr = mgr.parentMgr;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Check whether the manager has a namespace for the id of this object
|
|
|
|
var entry = mgr.getEntry(this.id);
|
2021-08-19 01:41:23 +02:00
|
|
|
if(typeof entry === 'object' && entry !== null || this.id)
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
// The content manager has an own node for this object, so
|
|
|
|
// create an own perspective.
|
|
|
|
this._mgrs[key] = mgr.openPerspective(this, this.id);
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
else
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
// The current content manager does not have an own namespace for
|
|
|
|
// this element, so use the content manager of the parent.
|
|
|
|
delete (this._mgrs[key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Returns the instance manager
|
|
|
|
*
|
|
|
|
* @return {etemplate2}
|
|
|
|
*/
|
|
|
|
getInstanceManager()
|
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this._inst != null)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this._inst;
|
|
|
|
}
|
2021-08-19 01:41:23 +02:00
|
|
|
else if(this.getParent())
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return this.getParent().getInstanceManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
/**
|
|
|
|
* Returns the path into the data array. By default, array manager takes care of
|
|
|
|
* this, but some extensions need to override this
|
|
|
|
*/
|
|
|
|
getPath()
|
|
|
|
{
|
|
|
|
var path = this.getArrayMgr("content").getPath();
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Prevent namespaced widgets with value from going an extra layer deep
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.id && this._createNamespace() && path[path.length - 1] == this.id) path.pop();
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
return path;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
_createNamespace() : boolean
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
egw() : IegwAppLocal
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.getParent() != null && !(this.getParent() instanceof HTMLElement))
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return (<et2_widget>this.getParent()).egw();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the window this object belongs to
|
|
|
|
var wnd = null;
|
|
|
|
// @ts-ignore Technically this doesn't have implements(), but it's mixed in
|
2021-08-19 01:41:23 +02:00
|
|
|
if(this.implements(et2_IDOMNode))
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
var node = (<et2_IDOMNode><unknown>this).getDOMNode();
|
2021-08-19 01:41:23 +02:00
|
|
|
if(node && node.ownerDocument)
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
wnd = node.ownerDocument.parentNode || node.ownerDocument.defaultView;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we're the root object, return the phpgwapi API instance
|
|
|
|
return egw('phpgwapi', wnd);
|
|
|
|
}
|
|
|
|
};
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
function applyMixins(derivedCtor : any, baseCtors : any[])
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
baseCtors.forEach(baseCtor =>
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name =>
|
|
|
|
{
|
2021-08-19 01:41:23 +02:00
|
|
|
if(name !== 'constructor')
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
derivedCtor.prototype[name] = baseCtor.prototype[name];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
// Add some more stuff in
|
|
|
|
applyMixins(Et2WidgetClass, [ClassWithInterfaces]);
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
return Et2WidgetClass as unknown as Constructor<et2_IDOMNode> & T;
|
2021-08-19 18:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a Web Component
|
|
|
|
* @param _nodeName
|
|
|
|
* @param _template_node
|
|
|
|
*/
|
|
|
|
export function loadWebComponent(_nodeName : string, _template_node, parent : Et2WidgetClass | et2_widget) : HTMLElement
|
|
|
|
{
|
|
|
|
let widget = <Et2WidgetClass>document.createElement(_nodeName);
|
|
|
|
widget.textContent = _template_node.textContent;
|
|
|
|
|
|
|
|
const widget_class = window.customElements.get(_nodeName);
|
|
|
|
if(!widget_class)
|
|
|
|
{
|
|
|
|
throw Error("Unknown or unregistered WebComponent '" + _nodeName + "', could not find class");
|
|
|
|
}
|
|
|
|
widget.setParent(parent);
|
|
|
|
var mgr = widget.getArrayMgr("content");
|
|
|
|
|
|
|
|
// Set read-only. Doesn't really matter if it's a ro widget, but otherwise it needs set
|
|
|
|
widget.readonly = parent.getArrayMgr("readonlys") ?
|
|
|
|
(<any>parent.getArrayMgr("readonlys")).isReadOnly(
|
|
|
|
_template_node.getAttribute("id"), _template_node.getAttribute("readonly"),
|
|
|
|
typeof parent.readonly !== "undefined" ? parent.readonly : false) : false;
|
|
|
|
|
|
|
|
// Apply any set attributes - widget will do its own coercion
|
|
|
|
_template_node.getAttributeNames().forEach(attribute =>
|
|
|
|
{
|
|
|
|
let attrValue = _template_node.getAttribute(attribute);
|
|
|
|
|
|
|
|
// If there is not attribute set, ignore it. Widget sets its own default.
|
|
|
|
if(typeof attrValue === "undefined") return;
|
|
|
|
|
|
|
|
// If the attribute is marked as boolean, parse the
|
|
|
|
// expression as bool expression.
|
|
|
|
if(widget_class.getPropertyOptions(attribute).type == "Boolean")
|
|
|
|
{
|
|
|
|
attrValue = mgr.parseBoolExpression(attrValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
attrValue = mgr.expandName(attrValue);
|
|
|
|
}
|
|
|
|
widget.setAttribute(attribute, attrValue);
|
|
|
|
});
|
|
|
|
|
|
|
|
if(widget_class.getPropertyOptions("value") && widget.set_value)
|
|
|
|
{
|
|
|
|
if(mgr != null)
|
|
|
|
{
|
|
|
|
let val = mgr.getEntry(widget.id, false, true);
|
|
|
|
if(val !== null)
|
|
|
|
{
|
|
|
|
widget.set_value(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Children need to be loaded
|
|
|
|
widget.loadFromXML(_template_node);
|
|
|
|
|
|
|
|
return widget;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|