forked from extern/egroupware
diverse fixes loading no longer existing legacy widgets like description
This commit is contained in:
parent
ac5932240b
commit
273fe9a28a
@ -629,7 +629,11 @@ const Et2WidgetMixin = (superClass) =>
|
||||
{
|
||||
// Get the constructor - if the widget is readonly, use the special "_ro"
|
||||
// constructor if it is available
|
||||
let constructor = et2_registry[typeof et2_registry[_nodeName] == "undefined" ? 'placeholder' : _nodeName];
|
||||
if (typeof et2_registry[_nodeName] === "undefined")
|
||||
{
|
||||
_nodeName = 'placeholder';
|
||||
}
|
||||
let constructor = et2_registry[_nodeName];
|
||||
if(readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined")
|
||||
{
|
||||
constructor = et2_registry[_nodeName + "_ro"];
|
||||
@ -1257,7 +1261,7 @@ export const Et2Widget = dedupeMixin(Et2WidgetMixin);
|
||||
* @param parent Parent widget
|
||||
*/
|
||||
// @ts-ignore Et2Widget is I guess not the right type
|
||||
export function loadWebComponent(_nodeName : string, _template_node : Element|{[index: string]: any}, parent : Et2Widget | et2_widget) : HTMLElement
|
||||
export function loadWebComponent(_nodeName : string, _template_node : Element|{[index: string]: any}, parent : Et2Widget|et2_widget|undefined) : HTMLElement
|
||||
{
|
||||
let attrs = {};
|
||||
let load_children = true;
|
||||
@ -1293,10 +1297,10 @@ export function loadWebComponent(_nodeName : string, _template_node : Element|{[
|
||||
throw Error("Unknown or unregistered WebComponent '" + _nodeName + "', could not find class. Also checked for " + tries.join(','));
|
||||
}
|
||||
}
|
||||
const readonly = parent.getArrayMgr("readonlys") ?
|
||||
const readonly = parent?.getArrayMgr("readonlys") ?
|
||||
(<any>parent.getArrayMgr("readonlys")).isReadOnly(
|
||||
attrs["id"], attrs["readonly"],
|
||||
typeof parent.readonly !== "undefined" ? parent.readonly : false) : false;
|
||||
typeof parent?.readonly !== "undefined" ? parent.readonly : false) : false;
|
||||
if(readonly === true && typeof window.customElements.get(_nodeName + "_ro") != "undefined")
|
||||
{
|
||||
_nodeName += "_ro";
|
||||
@ -1306,7 +1310,7 @@ export function loadWebComponent(_nodeName : string, _template_node : Element|{[
|
||||
let widget = <Et2Widget>document.createElement(_nodeName);
|
||||
widget.textContent = _template_node.textContent;
|
||||
|
||||
widget.setParent(parent);
|
||||
if (parent) widget.setParent(parent);
|
||||
|
||||
// Set read-only. Doesn't really matter if it's a ro widget, but otherwise it needs set
|
||||
widget.readOnly = readonly;
|
||||
|
@ -106,17 +106,21 @@ export function et2_createWidget(_name: string, _attrs: object, _parent?: any):
|
||||
// determine which constructor is used
|
||||
var nodeName = _attrs["type"] = _name;
|
||||
var readonly = _attrs["readonly"] =
|
||||
typeof _attrs["readonly"] == "undefined" ? false : _attrs["readonly"];
|
||||
typeof _attrs["readonly"] === "undefined" ? false : _attrs["readonly"];
|
||||
|
||||
// Get the constructor - if the widget is readonly, use the special "_ro"
|
||||
// constructor if it is available
|
||||
let constructor = et2_registry[typeof et2_registry[nodeName] == "undefined" ? 'placeholder' : nodeName];
|
||||
if (readonly && typeof et2_registry[nodeName + "_ro"] != "undefined")
|
||||
if (typeof et2_registry[nodeName] === "undefined")
|
||||
{
|
||||
nodeName = 'placeholder';
|
||||
}
|
||||
let constructor = et2_registry[nodeName];
|
||||
if (readonly && typeof et2_registry[nodeName + "_ro"] !== "undefined")
|
||||
{
|
||||
constructor = et2_registry[nodeName + "_ro"];
|
||||
}
|
||||
|
||||
// Do an sanity check for the attributes
|
||||
// Do a sanity check for the attributes
|
||||
ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], _attrs);
|
||||
// Create the new widget and return it
|
||||
return new constructor(_parent, _attrs);
|
||||
@ -784,9 +788,19 @@ export class et2_widget extends ClassWithAttributes
|
||||
_nodeName = attributes["type"] = this.getArrayMgr('content').expandName(_nodeName);
|
||||
}
|
||||
|
||||
// check and return web-components in case widget is no longer available as legacy widget
|
||||
if (typeof et2_registry[_nodeName] === "undefined" && window.customElements.get('et2-'+_nodeName))
|
||||
{
|
||||
return loadWebComponent('et2-'+_nodeName, _node, this);
|
||||
}
|
||||
|
||||
// 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];
|
||||
if (typeof et2_registry[_nodeName] === "undefined")
|
||||
{
|
||||
_nodeName = 'placeholder';
|
||||
}
|
||||
let constructor = et2_registry[_nodeName];
|
||||
if(readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined")
|
||||
{
|
||||
constructor = et2_registry[_nodeName + "_ro"];
|
||||
|
@ -47,6 +47,17 @@ export function et2_loadXMLFromURL(_url : string, _callback? : Function, _contex
|
||||
{
|
||||
win = egw.top;
|
||||
}
|
||||
|
||||
// if preprocessor is missing --> add it
|
||||
if (_url.indexOf('/etemplate.php/') === -1)
|
||||
{
|
||||
const parts = _url.match(/^(.*)(\/[^/]+\/templates\/.*)$/);
|
||||
if (parts)
|
||||
{
|
||||
_url = parts[1]+'/api/etemplate.php'+parts[2];
|
||||
}
|
||||
}
|
||||
|
||||
// we add the full url (protocol and domain) as sometimes just the path
|
||||
// gives a CSP error interpreting it as file:///path
|
||||
// (if there are a enough 404 errors in html content ...)
|
||||
@ -114,6 +125,3 @@ export function et2_readAttrWithDefault(_node : HTMLElement, _name : string, _de
|
||||
|
||||
return (val === null) ? _default : val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -528,7 +528,7 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
|
||||
// Not set
|
||||
if(options[i] === "") continue;
|
||||
|
||||
const attr = widget.attributes[legacy[i]];
|
||||
const attr = widget.attributes[legacy[i]] || {};
|
||||
let attrValue = options[i];
|
||||
|
||||
// If the attribute is marked as boolean, parse the
|
||||
|
@ -135,9 +135,8 @@ export class et2_template extends et2_DOMWidget
|
||||
{
|
||||
var splitted = template_name.split('.');
|
||||
var app = splitted.shift();
|
||||
// use template base url from initial template, to continue using webdav, if that was loaded via webdav
|
||||
url = this.getRoot()._inst.template_base_url + app + "/templates/default/" +
|
||||
splitted.join('.') + ".xet" + (cache_buster ? '?download=' + cache_buster : '');
|
||||
url = egw.link('/'+ app + "/templates/default/" +
|
||||
splitted.join('.')+ ".xet", {download:cache_buster? cache_buster :(new Date).valueOf()});
|
||||
}
|
||||
// if server did not give a cache-buster, fall back to current time
|
||||
if (url.indexOf('?') == -1) url += '?download='+(new Date).valueOf();
|
||||
|
@ -830,7 +830,7 @@ export class etemplate2
|
||||
public isDirty()
|
||||
{
|
||||
let dirty = false;
|
||||
this._widgetContainer.iterateOver(function(_widget)
|
||||
this._widgetContainer?.iterateOver(function(_widget)
|
||||
{
|
||||
if(_widget.isDirty && _widget.isDirty())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user