Get merge dialog working for CRM view

This commit is contained in:
nathan 2024-03-13 15:15:23 -06:00
parent 84a452492d
commit 303ab4a9c9
3 changed files with 35 additions and 16 deletions

View File

@ -1119,21 +1119,20 @@ class AddressbookApp extends EgwApp
* @param {egwAction} action - The document they clicked
* @param {egwActionObject[]} selected - Rows selected
*/
merge_mail(action, selected, target)
_mergeEmail(action, data)
{
// Special processing for email documents - ask about infolog
if(action && action.data && selected.length > 1)
if(action && data && (data.id.length > 1 || data.select_all))
{
var callback = function(button, value) {
const callback = (button, value) =>
{
if(button == Et2Dialog.OK_BUTTON)
{
var _action_data = jQuery.extend(true, {}, action.data);
if(value.infolog)
{
_action_data.menuaction += '&to_app=infolog&info_type=' + value.info_type;
action.data = _action_data;
data.menuaction += '&to_app=infolog&info_type=' + value.info_type;
}
nm_action(action, selected, target);
return super._mergeEmail(action, data);
}
};
let dialog = new Et2Dialog(this.egw);
@ -1150,7 +1149,7 @@ class AddressbookApp extends EgwApp
else
{
// Normal processing for only one contact selected
return nm_action(action, selected, target);
return super._mergeEmail(action, data);
}
}

View File

@ -23,6 +23,7 @@ import {Et2Favorites} from "../etemplate/Et2Favorites/Et2Favorites";
import {loadWebComponent} from "../etemplate/Et2Widget/Et2Widget";
import {Et2VfsSelectDialog} from "../etemplate/Et2Vfs/Et2VfsSelectDialog";
import {Et2Checkbox} from "../etemplate/Et2Checkbox/Et2Checkbox";
import type {EgwAction} from "../egw_action/EgwAction";
/**
* Type for push-message
@ -823,7 +824,7 @@ export abstract class EgwApp
let split = _selected[i].id.split("::");
ids.push(split[1]);
}
let document = await this._getMergeDocument();
let document = await this._getMergeDocument(nm?.getInstanceManager(), _action);
if(!document.document)
{
return;
@ -844,7 +845,7 @@ export abstract class EgwApp
{
vars.id = JSON.stringify(ids);
}
egw.open_link(egw.link('/index.php', vars), '_blank');
this.egw.open_link(this.egw.link('/index.php', vars), '_blank');
}
/**
@ -854,8 +855,13 @@ export abstract class EgwApp
* @protected
*/
protected _getMergeDocument() : Promise<{ document : string, pdf : boolean, mime : string }>
protected _getMergeDocument(et2?, action? : EgwAction) : Promise<{
document : string,
pdf : boolean,
mime : string
}>
{
let path = action?.data?.merge_data?.directory ?? "";
let dirPref = <string>this.egw.preference('document_dir', this.appname) ?? "";
let dirs = dirPref.split('/[,\s]+\//');
dirs.forEach((d, index) =>
@ -869,9 +875,13 @@ export abstract class EgwApp
class: "egw_app_merge_document",
title: this.egw.lang("Insert in document"),
mode: "open",
path: dirs.pop() ?? "",
path: path ?? dirs?.pop() ?? "",
open: true
}, this.et2);
}, et2.widgetContainer);
if(!et2)
{
document.body.append(fileSelect);
}
let pdf = <Et2Checkbox><unknown>loadWebComponent("et2-checkbox", {
slot: "footer",
label: "As PDF"
@ -894,7 +904,7 @@ export abstract class EgwApp
{
if(!values[0])
{
return {};
return {document: '', pdf: false, mime: ""};
}
const value = values[1].pop() ?? "";

View File

@ -2410,7 +2410,16 @@ abstract class Merge
public static function document_action($dirs, $group = 0, $caption = 'Insert in document', $prefix = 'document_', $default_doc = '',
$export_limit = null)
{
$documents = array();
if(count($dirs = preg_split('/[,\s]+\//', $dirs)) > 1)
{
foreach($dirs as $n => &$d)
{
if($n)
{
$d = '/' . $d;
} // re-adding trailing slash removed by split
}
}
if($export_limit == null)
{
$export_limit = self::getExportLimit();
@ -2426,7 +2435,8 @@ abstract class Merge
'group' => $group,
'merge_data' => array(
'menuaction' => $GLOBALS['egw_info']['flags']['currentapp'] . '.' . get_called_class() . '.merge_entries',
'merge' => get_called_class()
'merge' => get_called_class(),
'directory' => $dirs[0] ?? ""
)
);
}