2020-01-21 19:22:54 +01:00
|
|
|
/**
|
|
|
|
* EGroupware eTemplate2 - JS Dialog Widget class
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
2021-06-07 17:33:53 +02:00
|
|
|
* @link https://www.egroupware.org
|
2020-01-21 19:22:54 +01:00
|
|
|
* @author Nathan Gray
|
|
|
|
* @copyright Nathan Gray 2013
|
|
|
|
*/
|
|
|
|
|
2022-03-21 16:48:45 +01:00
|
|
|
import {Et2Dialog} from "./Et2Dialog/Et2Dialog";
|
2022-03-23 00:21:59 +01:00
|
|
|
import {et2_attribute_registry, et2_register_widget, et2_widget} from "./et2_core_widget";
|
2020-01-21 19:22:54 +01:00
|
|
|
|
|
|
|
/**
|
2022-03-21 16:48:45 +01:00
|
|
|
* Just a stub that wraps Et2Dialog
|
|
|
|
* @deprecated
|
2020-01-21 19:22:54 +01:00
|
|
|
*/
|
2022-03-21 16:48:45 +01:00
|
|
|
export class et2_dialog extends Et2Dialog
|
|
|
|
{
|
2022-03-23 00:21:59 +01:00
|
|
|
|
|
|
|
constructor(parent, attrs?)
|
|
|
|
{
|
|
|
|
super(parent.egw());
|
|
|
|
if(attrs)
|
|
|
|
{
|
|
|
|
this.transformAttributes(attrs);
|
|
|
|
}
|
|
|
|
document.body.appendChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
get template()
|
|
|
|
{
|
|
|
|
return super.template || {};
|
|
|
|
}
|
|
|
|
|
|
|
|
set template(value)
|
|
|
|
{
|
|
|
|
super.template = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
get div()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a parent to inject application specific egw object with loaded translations into et2_dialog
|
|
|
|
*
|
|
|
|
* @param {string|egw} _egw_or_appname egw object with already loaded translations or application name to load translations for
|
|
|
|
*/
|
|
|
|
static _create_parent(_egw_or_appname? : string | IegwAppLocal)
|
|
|
|
{
|
|
|
|
if(typeof _egw_or_appname == 'undefined')
|
|
|
|
{
|
|
|
|
// @ts-ignore
|
|
|
|
_egw_or_appname = egw_appName;
|
|
|
|
}
|
|
|
|
// create a dummy parent with a correct reference to an application specific egw object
|
|
|
|
let parent = new et2_widget();
|
|
|
|
// if egw object is passed in because called from et2, just use it
|
|
|
|
if(typeof _egw_or_appname != 'string')
|
|
|
|
{
|
|
|
|
parent.setApiInstance(_egw_or_appname);
|
|
|
|
}
|
|
|
|
// otherwise use given appname to create app-specific egw instance and load default translations
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent.setApiInstance(egw(_egw_or_appname));
|
|
|
|
parent.egw().langRequireApp(parent.egw().window, _egw_or_appname);
|
|
|
|
}
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get it working transparently as a legacy dialog
|
|
|
|
et2_register_widget(et2_dialog, ["dialog", "legacy_dialog"]);
|
|
|
|
const type_map = {String: "string", Function: "js"};
|
|
|
|
let attrs = {};
|
|
|
|
for(const [key, value] of Object.entries(et2_dialog.properties))
|
|
|
|
{
|
|
|
|
let attr = et2_dialog.properties[key];
|
|
|
|
|
|
|
|
attrs[key] = {type: type_map[attr.type?.name || attr.name] || "string"};
|
|
|
|
}
|
|
|
|
et2_attribute_registry[et2_dialog.name] = attrs
|
|
|
|
|
|
|
|
customElements.define("legacy-dialog", et2_dialog);
|