From 38b930d51cc8b3b3f8f67bbe5dccca685af7abc5 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 9 May 2017 15:09:00 +0200 Subject: [PATCH] * Mail: Make multiple mail selection available for both "save to disk" and :save to filemanager" actions --- mail/inc/class.mail_ui.inc.php | 4 +-- mail/js/app.js | 53 ++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 87b2ada984..1f3ab3ab3c 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -1124,7 +1124,7 @@ class mail_ui 'group' => $group, 'icon' => 'fileexport', 'onExecute' => 'javaScript:app.mail.mail_save', - 'allowOnMultiple' => false, + 'allowOnMultiple' => true, 'hideOnMobile' => true ), 'save2filemanager' => array( @@ -1133,7 +1133,7 @@ class mail_ui 'group' => $group, 'icon' => 'filemanager/navbar', 'onExecute' => 'javaScript:app.mail.mail_save2fm', - 'allowOnMultiple' => false, + 'allowOnMultiple' => true, ), ), 'hideOnMobile' => true diff --git a/mail/js/app.js b/mail/js/app.js index a2c7b5d3c8..0c4920fbb5 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -2520,12 +2520,23 @@ app.classes.mail = AppJS.extend( } } } - //alert('mail_save('+_elems[0].id+')'); - var url = window.egw_webserverUrl+'/index.php?'; - url += 'menuaction=mail.mail_ui.saveMessage'; // todo compose for Draft folder - url += '&id='+_elems[0].id; - //window.open(url,'_blank','dependent=yes,width=100,height=100,scrollbars=yes,status=yes'); - this.et2._inst.download(url); + + for (var i in _elems) + { + //alert('mail_save('+_elems[0].id+')'); + var url = window.egw_webserverUrl+'/index.php?'; + url += 'menuaction=mail.mail_ui.saveMessage'; // todo compose for Draft folder + url += '&id='+_elems[i].id; + var a = document.createElement('a'); + a = jQuery(a) + .prop('href', url) + .prop('download',"") + .appendTo(this.et2.getDOMNode()); + var evt = document.createEvent('MouseEvent'); + evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); + a[0].dispatchEvent(evt); + a.remove(); + } }, /** @@ -2872,20 +2883,32 @@ app.classes.mail = AppJS.extend( } } } - var _id = _elems[0].id; - var dataElem = egw.dataGetUIDdata(_id); var url = window.egw_webserverUrl+'/index.php?'; url += 'menuaction=filemanager.filemanager_select.select'; // todo compose for Draft folder - url += '&mode=saveas'; - var subject = dataElem? dataElem.data.subject: _elems[0].subject; - var filename = subject.replace(/[\f\n\t\v]/g,"_")|| 'unknown'; - url += '&name='+encodeURIComponent(filename+'.eml'); + url += '&mode='+ (_elems.length>1?'select-dir':'saveas'); url += '&mime=message'+encodeURIComponent('/')+'rfc822'; url += '&method=mail.mail_ui.vfsSaveMessage'; - url += '&id='+_elems[0].id; - url += '&label=Save'; - egw_openWindowCentered(url,'vfs_save_message_'+_elems[0].id,'680','400',window.outerWidth/2,window.outerHeight/2); + url += '&label='+(_elems.length>1?egw.lang('Save all'):egw.lang('save')); + for (var i in _elems) + { + var _id = _elems[i].id; + var dataElem = egw.dataGetUIDdata(_id); + var subject = dataElem? dataElem.data.subject: _elems[i].subject; + var filename = subject.replace(/[\f\n\t\v]/g,"_")|| 'unknown'; + if (_elems.length>1) + { + url += '&id['+i+']='+_id; + url += '&name['+i+']='+encodeURIComponent(filename+'.eml'); + } + else + { + url += '&id='+_id; + url += '&name='+encodeURIComponent(filename+'.eml'); + } + + } + egw.openPopup(url,'680','400','vfs_save_messages', 'filemanager'); }, /**