Fix some typescript bugs

- Don't default dialog width so the automatic calculations run
- Setting etemplate_exec_id after load doesn't work, moved to passing it in.  Fixes several file select issues
This commit is contained in:
nathangray 2020-04-09 14:26:57 -06:00
parent 0eb65b9efe
commit eda34d67b3
4 changed files with 139 additions and 136 deletions

View File

@ -769,7 +769,7 @@ var et2_dialog = /** @class */ (function (_super) {
name: "width",
type: "string",
description: "Define width of dialog, the default is auto",
"default": 'auto'
"default": et2_no_init
},
height: {
name: "height",

View File

@ -180,7 +180,7 @@ export class et2_dialog extends et2_widget {
name: "width",
type: "string",
description: "Define width of dialog, the default is auto",
"default": 'auto'
"default": et2_no_init
},
height: {
name: "height",

View File

@ -1072,7 +1072,18 @@ var et2_vfsSelect = /** @class */ (function (_super) {
}
}
buttons.push({ text: egw.lang("Close"), id: "close", image: "cancel" });
var data = jQuery.extend(_data, { 'currentapp': egw(window).app_name() });
// Don't rely only on app_name to fetch et2 object as app_name may not
// always represent current app of the window, e.g.: mail admin account.
// Try to fetch et2 from its template name.
var etemplate = jQuery('form').data('etemplate');
var et2;
if (etemplate && etemplate.name && !app[egw(window).app_name()]) {
et2 = etemplate2.getByTemplate(etemplate.name)[0];
}
else {
et2 = etemplate2.getByApplication(egw(window).app_name())[0];
}
var data = jQuery.extend(_data, { 'currentapp': egw(window).app_name(), etemplate_exec_id: et2.etemplate_exec_id });
// define a mini app object for vfs select UI
app.vfsSelectUI = new app.classes.vfsSelectUI;
// callback for dialog
@ -1146,26 +1157,15 @@ var et2_vfsSelect = /** @class */ (function (_super) {
this.dialog.template.uniqueId = 'api.vfsSelectUI';
app.vfsSelectUI.et2 = this.dialog.template.widgetContainer;
app.vfsSelectUI.vfsSelectWidget = this;
// Don't rely only on app_name to fetch et2 object as app_name may not
// always represent current app of the window, e.g.: mail admin account.
// Try to fetch et2 from its template name.
var etemplate = jQuery('form').data('etemplate');
var et2;
if (etemplate && etemplate.name && !app[egw(window).app_name()]) {
et2 = etemplate2.getByTemplate(etemplate.name)[0];
}
else {
et2 = etemplate2.getByApplication(egw(window).app_name())[0];
}
// we need an etemplate_exec_id for better handling serverside parts of
// widgets and since we can not have a etemplate_exec_id specifically
// for dialog template our best shot is to inherit its parent etemplate_exec_id.
this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id;
// Keep the dialog always at the top
this.dialog.div.parent().css({ "z-index": 100000 });
this.dialog.div.on('load', function (e) {
app.vfsSelectUI.et2_ready(app.vfsSelectUI.et2, 'api.vfsSelectUI');
});
// we need an etemplate_exec_id for better handling serverside parts of
// widgets and since we can not have a etemplate_exec_id specifically
// for dialog template our best shot is to inherit its parent etemplate_exec_id.
this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id;
};
/**
* Set recent path into sessionStorage

View File

@ -1304,7 +1304,23 @@ export class et2_vfsSelect extends et2_inputWidget
}
buttons.push({text: egw.lang("Close"), id:"close", image:"cancel"});
let data = jQuery.extend(_data, {'currentapp': egw(window).app_name()});
// Don't rely only on app_name to fetch et2 object as app_name may not
// always represent current app of the window, e.g.: mail admin account.
// Try to fetch et2 from its template name.
let etemplate = jQuery('form').data('etemplate');
let et2;
if (etemplate && etemplate.name && !app[egw(window).app_name()])
{
et2 = etemplate2.getByTemplate(etemplate.name)[0];
}
else
{
et2 = etemplate2.getByApplication(egw(window).app_name())[0];
}
let data = jQuery.extend(_data, {'currentapp': egw(window).app_name(), etemplate_exec_id: et2.etemplate_exec_id});
// define a mini app object for vfs select UI
app.vfsSelectUI = new app.classes.vfsSelectUI;
@ -1401,29 +1417,16 @@ export class et2_vfsSelect extends et2_inputWidget
app.vfsSelectUI.et2 = this.dialog.template.widgetContainer;
app.vfsSelectUI.vfsSelectWidget = this;
// Don't rely only on app_name to fetch et2 object as app_name may not
// always represent current app of the window, e.g.: mail admin account.
// Try to fetch et2 from its template name.
let etemplate = jQuery('form').data('etemplate');
let et2;
if (etemplate && etemplate.name && !app[egw(window).app_name()])
{
et2 = etemplate2.getByTemplate(etemplate.name)[0];
}
else
{
et2 = etemplate2.getByApplication(egw(window).app_name())[0];
}
// we need an etemplate_exec_id for better handling serverside parts of
// widgets and since we can not have a etemplate_exec_id specifically
// for dialog template our best shot is to inherit its parent etemplate_exec_id.
this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id;
// Keep the dialog always at the top
this.dialog.div.parent().css({"z-index": 100000});
this.dialog.div.on('load', function(e) {
app.vfsSelectUI.et2_ready(app.vfsSelectUI.et2, 'api.vfsSelectUI');
});
// we need an etemplate_exec_id for better handling serverside parts of
// widgets and since we can not have a etemplate_exec_id specifically
// for dialog template our best shot is to inherit its parent etemplate_exec_id.
this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id;
}
/**