Add addressbook's "Save as infolog" to new merge dialog
This commit is contained in:
parent
0d6e885ac3
commit
6d7b097072
|
@ -24,6 +24,10 @@ import {LitElement} from "lit";
|
||||||
import {Et2SelectCountry} from "../../api/js/etemplate/Et2Select/Select/Et2SelectCountry";
|
import {Et2SelectCountry} from "../../api/js/etemplate/Et2Select/Select/Et2SelectCountry";
|
||||||
|
|
||||||
import {Et2SelectState} from "../../api/js/etemplate/Et2Select/Select/Et2SelectState";
|
import {Et2SelectState} from "../../api/js/etemplate/Et2Select/Select/Et2SelectState";
|
||||||
|
import type {EgwAction} from "../../api/js/egw_action/EgwAction";
|
||||||
|
import {EgwActionObject} from "../../api/js/egw_action/EgwActionObject";
|
||||||
|
import {Et2MergeDialog} from "../../api/js/etemplate/Et2Dialog/Et2MergeDialog";
|
||||||
|
import {et2_createWidget} from "../../api/js/etemplate/et2_core_widget";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to call app.addressbook.openCRMview with
|
* Object to call app.addressbook.openCRMview with
|
||||||
|
@ -1166,47 +1170,59 @@ class AddressbookApp extends EgwApp
|
||||||
return emails;
|
return emails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask the user for a target document to merge into
|
||||||
|
*
|
||||||
|
* Overridden from parent to add addressbook's options:
|
||||||
|
* - save as infolog
|
||||||
|
*
|
||||||
|
* @returns {Promise<{document : string, pdf : boolean, mime : string}>}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
protected async _getMergeDocument(et2?, action? : EgwAction, selected? : EgwActionObject[]) : Promise<{
|
||||||
|
documents : { path : string; mime : string }[];
|
||||||
|
options : { [p : string] : string | boolean }
|
||||||
|
}>
|
||||||
|
{
|
||||||
|
const promise = super._getMergeDocument(et2, action, selected);
|
||||||
|
|
||||||
|
// Find dialog
|
||||||
|
const dialog = this.et2?.getDOMNode()?.querySelector('et2-merge-dialog') ?? document.body.querySelector('et2-merge-dialog');
|
||||||
|
|
||||||
|
// Add additional option UI by loading a template
|
||||||
|
const options = <Et2MergeDialog><unknown>et2_createWidget('template', {
|
||||||
|
application: this.appname,
|
||||||
|
id: this.appname + ".mail_merge_dialog",
|
||||||
|
}, dialog);
|
||||||
|
// Wait for template load
|
||||||
|
const wait = [];
|
||||||
|
options.loadingFinished(wait);
|
||||||
|
await Promise.all(wait);
|
||||||
|
|
||||||
|
// Get template values, add them in
|
||||||
|
const result = await promise;
|
||||||
|
result.options = {...this.et2.getInstanceManager().getValues(options), ...result.options};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge the selected contacts into the target document.
|
* Merge the selected contacts into the target document.
|
||||||
*
|
*
|
||||||
* Normally we let the framework handle this, but in addressbook we want to
|
* Normally we let the framework handle this, but in addressbook we want to
|
||||||
* interfere and customize things a little to ask about saving to infolog.
|
* interfere and customize things a little to save to infolog.
|
||||||
*
|
*
|
||||||
* @param {egwAction} action - The document they clicked
|
* @param {egwAction} action - The document they clicked
|
||||||
* @param {egwActionObject[]} selected - Rows selected
|
* @param {egwActionObject[]} selected - Rows selected
|
||||||
*/
|
*/
|
||||||
_mergeEmail(action, data)
|
_mergeEmail(action, data)
|
||||||
{
|
{
|
||||||
// Special processing for email documents - ask about infolog
|
if(data.options.info_type)
|
||||||
if(action && data && (data.id.length > 1 || data.select_all))
|
|
||||||
{
|
{
|
||||||
const callback = (button, value) =>
|
data.merge += '&to_app=infolog&info_type=' + data.options.info_type;
|
||||||
{
|
|
||||||
if(button == Et2Dialog.OK_BUTTON)
|
|
||||||
{
|
|
||||||
if(value.infolog)
|
|
||||||
{
|
|
||||||
data.menuaction += '&to_app=infolog&info_type=' + value.info_type;
|
|
||||||
}
|
|
||||||
return super._mergeEmail(action, data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let dialog = new Et2Dialog(this.egw);
|
|
||||||
dialog.transformAttributes({
|
|
||||||
callback: callback,
|
|
||||||
title: action.caption,
|
|
||||||
buttons: Et2Dialog.BUTTONS_OK_CANCEL,
|
|
||||||
type: Et2Dialog.QUESTION_MESSAGE,
|
|
||||||
template: egw.webserverUrl + '/addressbook/templates/default/mail_merge_dialog.xet',
|
|
||||||
value: {content: {info_type: 'email'}, sel_options: this.et2.getArrayMgr('sel_options').data}
|
|
||||||
});
|
|
||||||
document.body.appendChild(<LitElement><unknown>dialog);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Normal processing for only one contact selected
|
|
||||||
return super._mergeEmail(action, data);
|
|
||||||
}
|
}
|
||||||
|
// Normal processing otherwise
|
||||||
|
return super._mergeEmail(action, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,22 +2,6 @@
|
||||||
<!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="addressbook.mail_merge_dialog" template="" lang="" group="0" version="">
|
<template id="addressbook.mail_merge_dialog" template="" lang="" group="0" version="">
|
||||||
<grid>
|
<et2-select id="info_type" emptyLabel="Save as infolog"></et2-select>
|
||||||
<columns>
|
|
||||||
<column/>
|
|
||||||
<column/>
|
|
||||||
</columns>
|
|
||||||
<rows>
|
|
||||||
<row>
|
|
||||||
<et2-description value="Do you want to send the message to all selected entries, WITHOUT further editing?"></et2-description>
|
|
||||||
</row>
|
|
||||||
<row>
|
|
||||||
<et2-hbox>
|
|
||||||
<et2-checkbox id="infolog" label="Save as infolog"></et2-checkbox>
|
|
||||||
<et2-select id="info_type"></et2-select>
|
|
||||||
</et2-hbox>
|
|
||||||
</row>
|
|
||||||
</rows>
|
|
||||||
</grid>
|
|
||||||
</template>
|
</template>
|
||||||
</overlay>
|
</overlay>
|
|
@ -22,6 +22,7 @@ export class Et2MergeDialog extends Et2Widget(LitElement)
|
||||||
et2-details::part(content) {
|
et2-details::part(content) {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: var(--sl-spacing-medium);
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
@ -139,6 +140,7 @@ export class Et2MergeDialog extends Et2Widget(LitElement)
|
||||||
label="${this.egw().lang("Link to each entry")}"
|
label="${this.egw().lang("Link to each entry")}"
|
||||||
></et2-checkbox>
|
></et2-checkbox>
|
||||||
<et2-checkbox label=${this.egw().lang("Merge individually")} id="individual"></et2-checkbox>
|
<et2-checkbox label=${this.egw().lang("Merge individually")} id="individual"></et2-checkbox>
|
||||||
|
<slot></slot>
|
||||||
</et2-details>
|
</et2-details>
|
||||||
</et2-vfs-select-dialog>`;
|
</et2-vfs-select-dialog>`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -861,6 +861,8 @@ export abstract class EgwApp
|
||||||
if(document.documents.length == 1 && document.documents[0].mime == "message/rfc822")
|
if(document.documents.length == 1 && document.documents[0].mime == "message/rfc822")
|
||||||
{
|
{
|
||||||
vars.document = document.documents[0].path;
|
vars.document = document.documents[0].path;
|
||||||
|
// Remove not applicable options
|
||||||
|
['pdf', 'download'].forEach(k => delete vars.options[k]);
|
||||||
return this._mergeEmail(_action.clone(), vars);
|
return this._mergeEmail(_action.clone(), vars);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue