Fix some app code using Et2Dialog.template, which previously returned the eTemplate2 object

It Et2Dialog.template is an attribute, and has to return the template name.
Use Et2Dialog.eTemplate to access the loaded etemplate2 object.
This commit is contained in:
nathan 2024-12-11 08:33:32 -07:00
parent 4eeeb3e3e1
commit aaefb6ce68
6 changed files with 53 additions and 32 deletions

View File

@ -619,7 +619,7 @@ class AdminApp extends EgwApp
dialog.transformAttributes(attrs); dialog.transformAttributes(attrs);
this.et2.getInstanceManager().DOMContainer.appendChild(dialog); this.et2.getInstanceManager().DOMContainer.appendChild(dialog);
dialog.updateComplete.then(() => { dialog.updateComplete.then(() => {
dialog.template.widgetContainer.getWidgetById("apps").focus(); dialog.eTemplate.widgetContainer.getWidgetById("apps").focus();
}); });
} }
@ -1653,14 +1653,14 @@ class AdminApp extends EgwApp
{ {
continue; continue;
} }
widget = this.template.widgetContainer.getWidgetById(required[i]); widget = this.eTemplate.widgetContainer.getWidgetById(required[i]);
widget.set_validation_error('This field is required!'); widget.set_validation_error('This field is required!');
isValid = false; isValid = false;
} }
// check mismatch passphrase // check mismatch passphrase
if (_value.passphrase && _value.passphrase !== _value.passphraseConf) if (_value.passphrase && _value.passphrase !== _value.passphraseConf)
{ {
var passphraseConf = this.template.widgetContainer.getWidgetById('passphrase'); var passphraseConf = this.eTemplate.widgetContainer.getWidgetById('passphrase');
passphraseConf.set_validation_error('Confirm passphrase is not match!'); passphraseConf.set_validation_error('Confirm passphrase is not match!');
isValid = false; isValid = false;
} }

View File

@ -667,12 +667,33 @@ export class Et2Dialog extends Et2Widget(SlDialog)
this.requestUpdate("template", old_template); this.requestUpdate("template", old_template);
} }
/**
* Getter for template name.
*
* Historically this returned the etemplate2 widget, but this was incorrect and has been fixed.
* Use `eTemplate` instead of `template` to access the etemplate2 widget.
*
* @returns {string}
*/
get template() get template()
{ {
// Can't return undefined or requestUpdate() will not notice a change // Can't return undefined or requestUpdate() will not notice a change
return this.__template || null; return this.__template || null;
} }
/**
* The loaded etemplate2 object.
*
* Only available if `template` is set
*
* @returns {etemplate2}
*/
get eTemplate()
{
return this._template_widget;
}
/** /**
* Title for the dialog, goes in the header * Title for the dialog, goes in the header
*/ */
@ -1454,10 +1475,10 @@ export class Et2Dialog extends Et2Widget(SlDialog)
dialog.getUpdateComplete().then(async function() dialog.getUpdateComplete().then(async function()
{ {
// Get access to template widgets // Get access to template widgets
log = dialog.template.widgetContainer.getDOMWidgetById('log').getDOMNode(); log = dialog.eTemplate.widgetContainer.getDOMWidgetById('log').getDOMNode();
progressbar = dialog.template.widgetContainer.getWidgetById('progressbar'); progressbar = dialog.eTemplate.widgetContainer.getWidgetById('progressbar');
progressbar.set_label('0 / ' + _list.length); progressbar.set_label('0 / ' + _list.length);
totals.widget = dialog.template.widgetContainer.getWidgetById('totals'); totals.widget = dialog.eTemplate.widgetContainer.getWidgetById('totals');
for(let index = 0; index < _list.length && !cancel; index++) for(let index = 0; index < _list.length && !cancel; index++)
{ {

View File

@ -701,10 +701,10 @@ export class et2_dataview_selectionManager
(this._context._widget.getDOMNode() || document.body).append(dialog); (this._context._widget.getDOMNode() || document.body).append(dialog);
dialog.updateComplete.then(() => dialog.updateComplete.then(() =>
{ {
dialog.template.DOMContainer.addEventListener('load', () => dialog.eTemplate.DOMContainer.addEventListener('load', () =>
{ {
// Get access to template widgets // Get access to template widgets
progressbar = dialog.template.widgetContainer.getWidgetById('progressbar'); progressbar = dialog.eTemplate.widgetContainer.getWidgetById('progressbar');
let rangePromise = fetchPromise; let rangePromise = fetchPromise;
for(var i = 0; i < queryRanges.length; i++) for(var i = 0; i < queryRanges.length; i++)

View File

@ -209,11 +209,11 @@ export class et2_placeholder_select extends et2_inputWidget
*/ */
_on_template_load() _on_template_load()
{ {
let app = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("app"); let app = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("app");
let group = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("group"); let group = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("group");
let placeholder_list = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("placeholder_list"); let placeholder_list = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("placeholder_list");
let preview = <Et2Description><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("preview_placeholder"); let preview = <Et2Description><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("preview_placeholder");
let entry = <Et2LinkEntry><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("entry"); let entry = <Et2LinkEntry><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("entry");
placeholder_list.set_select_options(this._get_placeholders(app.get_value(), group.get_value())); placeholder_list.set_select_options(this._get_placeholders(app.get_value(), group.get_value()));
@ -253,13 +253,13 @@ export class et2_placeholder_select extends et2_inputWidget
} }
placeholder_list.onchange = this._on_placeholder_select.bind(this); placeholder_list.onchange = this._on_placeholder_select.bind(this);
entry.onchange = this._on_placeholder_select.bind(this); entry.onchange = this._on_placeholder_select.bind(this);
(<Et2Button><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("insert_placeholder")).onclick = () => (<Et2Button><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("insert_placeholder")).onclick = () =>
{ {
this.options.insert_callback(this.dialog.template.widgetContainer.getDOMWidgetById("preview_placeholder").getDOMNode().textContent); this.options.insert_callback(this.dialog.eTemplate.widgetContainer.getDOMWidgetById("preview_placeholder").getDOMNode().textContent);
}; };
(<Et2Button><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("insert_content")).onclick = () => (<Et2Button><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("insert_content")).onclick = () =>
{ {
this.options.insert_callback(this.dialog.template.widgetContainer.getDOMWidgetById("preview_content").getDOMNode().textContent); this.options.insert_callback(this.dialog.eTemplate.widgetContainer.getDOMWidgetById("preview_content").getDOMNode().textContent);
}; };
app.set_value(app.get_value()); app.set_value(app.get_value());
@ -271,11 +271,11 @@ export class et2_placeholder_select extends et2_inputWidget
*/ */
_on_placeholder_select() _on_placeholder_select()
{ {
let app = <Et2LinkEntry><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("app"); let app = <Et2LinkEntry><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("app");
let entry = <Et2LinkEntry><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("entry"); let entry = <Et2LinkEntry><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("entry");
let placeholder_list = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("placeholder_list"); let placeholder_list = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("placeholder_list");
let preview = <Et2Description><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("preview_placeholder"); let preview = <Et2Description><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("preview_placeholder");
let preview_content = <Et2Description><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("preview_content"); let preview_content = <Et2Description><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("preview_content");
// Show the selected placeholder // Show the selected placeholder
this.set_value(placeholder_list.get_value()); this.set_value(placeholder_list.get_value());
@ -443,10 +443,10 @@ export class et2_placeholder_snippet_select extends et2_placeholder_select
*/ */
_on_template_load() _on_template_load()
{ {
let app = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("app"); let app = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("app");
let placeholder_list = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("placeholder_list"); let placeholder_list = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("placeholder_list");
let preview = <Et2Description><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("preview_content"); let preview = <Et2Description><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("preview_content");
let entry = <Et2LinkEntry><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("entry"); let entry = <Et2LinkEntry><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("entry");
placeholder_list.set_select_options(this._get_placeholders("addressbook", "addresses")); placeholder_list.set_select_options(this._get_placeholders("addressbook", "addresses"));
@ -473,10 +473,10 @@ export class et2_placeholder_snippet_select extends et2_placeholder_select
*/ */
_on_placeholder_select() _on_placeholder_select()
{ {
let app = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("app"); let app = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("app");
let entry = <Et2LinkEntry><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("entry"); let entry = <Et2LinkEntry><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("entry");
let placeholder_list = <Et2Select><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("placeholder_list"); let placeholder_list = <Et2Select><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("placeholder_list");
let preview_content = <Et2Description><unknown>this.dialog.template.widgetContainer.getDOMWidgetById("preview_content"); let preview_content = <Et2Description><unknown>this.dialog.eTemplate.widgetContainer.getDOMWidgetById("preview_content");
let placeholder = ""; let placeholder = "";
if(app && app.value) if(app && app.value)
{ {

View File

@ -1447,7 +1447,7 @@ export class filemanagerAPP extends EgwApp
document.body.appendChild(dialog); document.body.appendChild(dialog);
dialog.addEventListener("load", () => dialog.addEventListener("load", () =>
{ {
dialog.template.widgetContainer.getWidgetById("share_link").onclick = copy_link_to_clipboard; dialog.eTemplate.widgetContainer.getWidgetById("share_link").onclick = copy_link_to_clipboard;
}); });
} }

View File

@ -280,7 +280,7 @@ class TimesheetApp extends EgwApp
const dialog = new Et2Dialog(this.egw); const dialog = new Et2Dialog(this.egw);
dialog.getUpdateComplete().then(() => dialog.getUpdateComplete().then(() =>
{ {
const time = <Et2DateTime><any>dialog.template.widgetContainer.getWidgetById('time'); const time = <Et2DateTime><any>dialog.eTemplate.widgetContainer.getWidgetById('time');
// start-time set end-time as max // start-time set end-time as max
if (0+tse_type & 1) if (0+tse_type & 1)
{ {