mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:04:53 +01:00
Merge changes
- Disable individual checkbox when only one entry is selected - One entry + email document opens compose with other documents attached instead of sending directly - Download button gives emails too
This commit is contained in:
parent
7858ed8fae
commit
20da951b59
@ -25,6 +25,7 @@ import type {EgwAction} from "../egw_action/EgwAction";
|
||||
import {Et2MergeDialog} from "../etemplate/Et2Dialog/Et2MergeDialog";
|
||||
import {EgwActionObject} from "../egw_action/EgwActionObject";
|
||||
import type {Et2Details} from "../etemplate/Layout/Et2Details/Et2Details";
|
||||
import {Et2Checkbox} from "../etemplate/Et2Checkbox/Et2Checkbox";
|
||||
|
||||
/**
|
||||
* Type for push-message
|
||||
@ -867,11 +868,24 @@ export abstract class EgwApp
|
||||
let email = document.documents.find(f => f.mime == "message/rfc822");
|
||||
|
||||
// Can we do this in one, or do we have to split it up for feedback?
|
||||
if(!vars.options.individual && !email)
|
||||
if(!vars.options.individual && (!email || email && !all && ids.length == 1))
|
||||
{
|
||||
vars.options.open_email = !vars.options.download && typeof email != "undefined";
|
||||
|
||||
// Handle it all on the server in one request
|
||||
this.egw.loading_prompt(vars.menuaction, true);
|
||||
mergedFiles = await this.egw.request(vars.menuaction, [vars.id, vars.document, vars.options]);
|
||||
this.egw.message(mergedFiles, "success");
|
||||
this.egw.loading_prompt(vars.menuaction, false);
|
||||
|
||||
// One entry, email template selected - we can open that in the compose window
|
||||
if(email)
|
||||
{
|
||||
debugger;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.egw.message(mergedFiles, "success");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -927,11 +941,16 @@ export abstract class EgwApp
|
||||
{
|
||||
document.body.append(fileSelect);
|
||||
}
|
||||
// Start details open when you have multiple selected
|
||||
// Customize dialog
|
||||
fileSelect.updateComplete.then(() =>
|
||||
{
|
||||
// Start details open when you have multiple selected
|
||||
// @ts-ignore
|
||||
(<Et2Details>fileSelect.shadowRoot.querySelector('et2-details')).open = selected.length > 1;
|
||||
|
||||
// Disable individual when only one entry is selected
|
||||
// @ts-ignore
|
||||
(<Et2Checkbox>fileSelect.shadowRoot.querySelector("et2-details > [id='individual']")).disabled = selected.length == 1;
|
||||
});
|
||||
// Remove when done
|
||||
fileSelect.getComplete().then(() => {fileSelect.remove();});
|
||||
|
@ -2531,7 +2531,7 @@ abstract class Merge
|
||||
{
|
||||
$ids = self::get_all_ids($document_merge);
|
||||
}
|
||||
foreach(['pdf', 'individual', 'link'] as $option)
|
||||
foreach(['pdf', 'individual', 'link', 'download'] as $option)
|
||||
{
|
||||
$$option = is_null($options) || empty($options) ? (boolean)$_REQUEST['options'][$option] : (boolean)$options[$option];
|
||||
}
|
||||
@ -2582,14 +2582,14 @@ abstract class Merge
|
||||
{
|
||||
$mail_ids = [$mail_ids];
|
||||
}
|
||||
if(count((array)$mail_ids) == 1)
|
||||
if(count((array)$mail_ids) == 1 && !$open_email)
|
||||
{
|
||||
$mail_ids[] = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
// Special email handling so we can grab it and stick it where we want
|
||||
$mail_folder = $document_merge->keep_emails ? '' : FALSE;
|
||||
$mail_folder = $document_merge->keep_emails ? (count($id_group) == 1 ? $mail_bo->getDraftFolder() : '') : FALSE;
|
||||
$mail_id = '';
|
||||
$msgs = $mail_bo->importMessageToMergeAndSend($document_merge, Api\Vfs::PREFIX . $email, $mail_ids, $mail_folder, $mail_id, $attach);
|
||||
}
|
||||
@ -2598,7 +2598,7 @@ abstract class Merge
|
||||
throw new Api\Exception("Unable to send email", 100, $e);
|
||||
}
|
||||
// Save to VFS so we can link to entry
|
||||
if($link)
|
||||
if($link || $download)
|
||||
{
|
||||
// Load message
|
||||
$message = $mail_bo->getMessageRawBody($mail_id, '', $mail_folder);
|
||||
@ -2612,28 +2612,51 @@ abstract class Merge
|
||||
{
|
||||
$filename .= '.' . pathinfo($email, PATHINFO_EXTENSION);
|
||||
}
|
||||
foreach((array)$ids as $id)
|
||||
if($download)
|
||||
{
|
||||
$target = Api\Link::vfs_path($app, $id, $filename);
|
||||
$target = $document_merge->get_save_path($filename);
|
||||
|
||||
// Make sure we won't overwrite something already there
|
||||
$target = Vfs::make_unique($target);
|
||||
|
||||
file_put_contents(Vfs::PREFIX . $target, $message);
|
||||
$merged[] = $target;
|
||||
}
|
||||
if($link)
|
||||
{
|
||||
foreach((array)$ids as $id)
|
||||
{
|
||||
$target = Api\Link::vfs_path($app, $id, $filename);
|
||||
|
||||
// Make sure we won't overwrite something already there
|
||||
$target = Vfs::make_unique($target);
|
||||
|
||||
file_put_contents(Vfs::PREFIX . $target, $message);
|
||||
if(!$download)
|
||||
{
|
||||
$merged[] = $target;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$attach = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find out what to do with it - can't handle multiple documents directly
|
||||
if($return || count($merged) > 1)
|
||||
{
|
||||
return $merged;
|
||||
}
|
||||
|
||||
// Open email in compose?
|
||||
if($email && count($id_group) == 1 && $mail_id && class_exists("mail_ui"))
|
||||
{
|
||||
$mail_uid = \mail_ui::generateRowID($mail_bo->profileID, $mail_folder, $mail_id);
|
||||
$mail_popup = '';
|
||||
$mail_info = Api\Link::edit('mail', $mail_uid, $mail_popup);
|
||||
$mail_info['from'] = 'composefromdraft';
|
||||
Api\Framework::popup(Api\Framework::link("/index.php", $mail_info), '_blank', $mail_popup);
|
||||
return;
|
||||
}
|
||||
// Merge done, present to user
|
||||
if($document_merge->get_editable_mimes()[Vfs::mime_content_type($target)] &&
|
||||
!in_array(Vfs::mime_content_type($target), explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['collab_excluded_mimes'])))
|
||||
@ -2767,10 +2790,12 @@ abstract class Merge
|
||||
$_REQUEST['document'] = $documents;
|
||||
$app = $options['app'] ?? $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
$message = implode(', ', Api\Link::titles($app, $ids)) . ":\n";
|
||||
$return = true;
|
||||
$open_email = $options['open_email'];
|
||||
|
||||
try
|
||||
{
|
||||
$merge_result = static::merge_entries($ids, $document_merge, $options, true);
|
||||
$merge_result = static::merge_entries($ids, $document_merge, $options, !$open_email);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user