mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
Et2Widget: Stub some egw object methods that widgets use to avoid errors when egw object is not loaded
This commit is contained in:
parent
a4f2549acf
commit
e156ea8f64
@ -1439,7 +1439,24 @@ const Et2WidgetMixin = <T extends Constructor>(superClass : T) =>
|
||||
}
|
||||
|
||||
// If we're the root object, return the phpgwapi API instance
|
||||
return typeof egw === "function" ? egw('phpgwapi', wnd) : (window['egw'] ? window['egw'] : null);
|
||||
let egwInstance = typeof egw === "function" ? egw('phpgwapi', wnd) : (window['egw'] ? <IegwAppLocal><unknown>window['egw'] : null);
|
||||
|
||||
// Make sure required methods are there
|
||||
// These methods are used inside widgets, but may not always be available depending on egw() loading (tests, docs)
|
||||
const required = {
|
||||
debug: () => {console.log(arguments);},
|
||||
lang: (l) => {return l;},
|
||||
preference: () => {return false;},
|
||||
};
|
||||
for(let functionName in required)
|
||||
{
|
||||
if(egwInstance && typeof egwInstance[functionName] !== "function")
|
||||
{
|
||||
egwInstance[functionName] = required[functionName];
|
||||
}
|
||||
}
|
||||
|
||||
return egwInstance;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user