* Api: When clicking an email address, ask if user wants to add email to existing compose window or start a new mail

This commit is contained in:
nathan 2023-07-04 08:27:19 -06:00
parent 333750587c
commit 0e6f74da02
2 changed files with 82 additions and 53 deletions

View File

@ -592,37 +592,70 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
} }
} }
if(popups.length == 1) const pref_name = "mail_add_address_new_popup";
const new_dialog_pref = egw.preference(pref_name, "common");
if (popups.length == 0 || new_dialog_pref == "new")
{
return openUp(_app, _extra);
}
if (new_dialog_pref == "add" && popups.length == 1)
{
try
{ {
try {
popups[0].app[_app][_method](popups[0], _content); popups[0].app[_app][_method](popups[0], _content);
} }
catch(e) { catch (e)
window.setTimeout(function() { {
window.setTimeout(function ()
{
openUp(_app, _extra); openUp(_app, _extra);
}); });
} }
return;
} }
else if (popups.length > 1)
{
var buttons = [ var buttons = [
{label: this.lang("Add"), id: "add", "class": "ui-priority-primary", "default": true}, {label: this.lang("Add"), id: "add", "class": "ui-priority-primary", "default": true},
{label: this.lang("Cancel"), id: "cancel"} {label: this.lang("Cancel"), id: "cancel"}
]; ];
// Fill dialog options
var c = []; var c = [];
for (var i = 0; i < popups.length; i++) for (var i = 0; i < popups.length; i++)
{ {
c.push({label: popups[i].document.title || this.lang(_app), index: i}); c.push({label: popups[i].document.title || this.lang(_app), index: i});
} }
c.push({label: this.lang("New %1", egw.link_get_registry(_app, "entry")), index: "new"});
// Set initial value
switch (new_dialog_pref)
{
case "new":
c.index = "new";
break;
case "add":
c.index = 0;
break;
}
let dialog = new Et2Dialog(this.app_name()); let dialog = new Et2Dialog(this.app_name());
dialog.transformAttributes({ dialog.transformAttributes({
callback: function (_button_id, _value) callback: function (_button_id, _value)
{ {
if (_value.remember)
{
// Remember and do not ask again (if they chose new)
egw.set_preference("common", pref_name, _value.remember && _value.grid.index == "new" ? "new" : "add");
}
if (_value && _value.grid) if (_value && _value.grid)
{ {
switch (_button_id) switch (_button_id)
{ {
case "add": case "add":
if (_value.grid.index == "new")
{
return openUp(_app, _extra);
}
popups[_value.grid.index].app[_app][_method](popups[_value.grid.index], _content); popups[_value.grid.index].app[_app][_method](popups[_value.grid.index], _content);
return; return;
case "cancel": case "cancel":
@ -637,11 +670,6 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
}); });
document.body.appendChild(dialog); document.body.appendChild(dialog);
} }
else
{
openUp(_app, _extra);
}
}
}; };
}); });

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2.0//EN" "https://www.egroupware.org/etemplate2.0.dtd"> <!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2.0//EN" "https://www.egroupware.org/etemplate2.0.dtd">
<overlay> <overlay>
<template id="api.promptOpenedDialog" template="" lang="" group="0" version="17.1"> <template id="api.promptOpenedDialog" template="" lang="" group="0" version="23.1">
<grid id="grid"> <grid id="grid">
<columns> <columns>
<column/> <column/>
@ -12,9 +12,10 @@
<row> <row>
<radio id="index" set_value="$row_cont[index]"/> <radio id="index" set_value="$row_cont[index]"/>
<et2-description></et2-description> <et2-description></et2-description>
<et2-description id="${row}[label]"></et2-description> <et2-description id="${row}[label]" for="$row_cont[index]"></et2-description>
</row> </row>
</rows> </rows>
</grid> </grid>
<et2-checkbox id="remember" label="Remember and do not ask again" slot="footer" align="right"></et2-checkbox>
</template> </template>
</overlay> </overlay>