diff --git a/mail/inc/class.mail_hooks.inc.php b/mail/inc/class.mail_hooks.inc.php index a71b801ffa..79c7c945cd 100644 --- a/mail/inc/class.mail_hooks.inc.php +++ b/mail/inc/class.mail_hooks.inc.php @@ -785,4 +785,38 @@ class mail_hooks ] ]; } + + /** + * options for attachments block actions + * @return string[][] + */ + public static function attachmentsBlockActions() + { + return [ + 'downloadOneAsFile' => [ + 'id' => 'downloadOneAsFile', + 'label' => 'Download', + 'icon' => 'fileexport', + 'value' => 'downloadOneAsFile' + ], + 'saveOneToVfs' => [ + 'id' => 'saveOneToVfs', + 'label' => 'Save in Filemanager', + 'icon' => 'filemanager/navbar.svg', + 'value' => 'saveOneToVfs' + ], + 'saveAllToVfs' => [ + 'id' => 'saveAllToVfs', + 'label' => 'Save all to Filemanager', + 'icon' => 'mail/save_all', + 'value' => 'saveAllToVfs' + ], + 'downloadAllToZip' => [ + 'id' => 'downloadAllToZip', + 'label' => 'Save as ZIP', + 'icon' => 'mail/save_zip', + 'value' => 'downloadAllToZip' + ] + ]; + } } diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 61c62c704d..790090bd84 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -2305,6 +2305,7 @@ $filter['before']= date("d-M-Y", $cutoffdate2); { $content['mail_displayattachments'] = $attachmentHTMLBlock; $content['attachmentsBlockTitle'] = count($attachmentHTMLBlock).' '.Lang('attachments'); + $sel_options['mail_displayattachments']['actions'] = mail_hooks::attachmentsBlockActions(); } $content['mail_id']=$rowID; @@ -2468,8 +2469,10 @@ $filter['before']= date("d-M-Y", $cutoffdate2); $attachmentHTML[$key]['partID']=$value['partID']; $attachmentHTML[$key]['mail_id'] = $rowID; $attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; - $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; $attachmentHTML[$key]['smime_type'] = $value['smime_type']; + $attachmentHTML[$key]['actions'] = 'downloadOneAsFile'; + $attachmentHTML[$key]['actionsDefaultLabel'] = 'Download'; + // reset mode array as it should be considered differently for // each attachment $mode = array(); @@ -2579,12 +2582,7 @@ $filter['before']= date("d-M-Y", $cutoffdate2); 'smime_type' => $value['smime_type'] ); $attachmentHTML[$key]['link_save'] ="".Api\Html::image('mail','fileexport').""; - // add save-all and download zip icon for first attachment only - // if more than one attachments. - if ($key == 0 && count($attachments) > 1) - { - $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = ""; - } + if (!$GLOBALS['egw_info']['user']['apps']['filemanager']) $attachmentHTML[$key]['no_vfs'] = true; } $attachmentHTMLBlock=""; diff --git a/mail/js/app.js b/mail/js/app.js index 190bb767d8..abb31f8e06 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1016,6 +1016,19 @@ app.classes.mail = AppJS.extend( } }, + /** + * Handle actions from attachments block + * @param _e + * @param _widget + */ + attachmentsBlockActions: function(_e, _widget) + { + const id = _widget.id.replace('[actions]',''); + const action = _widget.value; + _widget.label = _widget.select_options.filter(_item=>{return _item.value == _widget.value})[0].label; + this.saveAttachmentHandler(_widget,action, id); + }, + /** * mail_preview - implementation of the preview action * @@ -1025,6 +1038,7 @@ app.classes.mail = AppJS.extend( mail_preview: function(selected, nextmatch) { let data = {}; let rowId = ''; + let sel_options = {} let attachmentsBlock = this.et2.getWidgetById('attachmentsBlock'); let mailPreview = this.et2.getWidgetById('mailPreview'); if(typeof selected != 'undefined' && selected.length == 1) @@ -1069,8 +1083,46 @@ app.classes.mail = AppJS.extend( }); } - if (data.attachmentsBlock) data.attachmentsBlockTitle = `${data.attachmentsBlock.length} attachments`; - mailPreview.set_value({content:data}); + if (data.attachmentsBlock) + { + const actions = [ + { + id: 'downloadOneAsFile', + label:'Download', + icon:'fileexport', + value:'downloadOneAsFile' + }, + { + id: 'saveOneToVfs', + label: 'Save in Filemanager', + icon: 'filemanager/navbar.svg', + value: 'saveOneToVfs' + }, + { + id: 'saveAllToVfs', + label: 'Save all to Filemanager', + icon: 'mail/save_all', + value: 'saveAllToVfs' + }, + { + id: 'downloadAllToZip', + label: 'Save as ZIP', + icon: 'mail/save_zip', + value: 'downloadAllToZip' + } + ]; + data.attachmentsBlockTitle = `${data.attachmentsBlock.length} attachments`; + data.attachmentsBlock.forEach(_item => { + _item.actions='downloadOneAsFile'; + // for some reason label needs to be set explicitly for the dropdown button. It needs more investigation. + _item.actionsDefaultLabel='Download'; + }); + + sel_options.attachmentsBlock = {actions:actions}; + } + + + mailPreview.set_value({content:data, sel_options:sel_options}); if (selected && selected.length>1) { diff --git a/mail/templates/default/display.xet b/mail/templates/default/display.xet index e42a7fc0c2..4cf2819282 100644 --- a/mail/templates/default/display.xet +++ b/mail/templates/default/display.xet @@ -98,9 +98,7 @@ - - - + @@ -111,10 +109,7 @@ - - - - + diff --git a/mail/templates/default/index.xet b/mail/templates/default/index.xet index e2fa5914e0..c9749f08b4 100644 --- a/mail/templates/default/index.xet +++ b/mail/templates/default/index.xet @@ -90,23 +90,17 @@ - - - - + - + - - - - +