[pmg-devel] [PATCH pmg-gui] fix #2677: show more info on multiple selected mails

Dominik Csapak d.csapak at proxmox.com
Wed Apr 22 10:26:59 CEST 2020


show how many mails are selected, and a short overview like this:

sender1
 subject1
 subject2

sender2
 subject3
 subject4

also fix the padding on multiSelect

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 js/SpamQuarantine.js | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js
index 60fbae8..b6e5460 100644
--- a/js/SpamQuarantine.js
+++ b/js/SpamQuarantine.js
@@ -72,13 +72,14 @@ Ext.define('PMG.SpamQuarantine', {
 
 	    var url = '/api2/htmlmail/quarantine/content?id=' + rec.data.id + ((raw)?'&raw=1':'');
 	    preview.setDisabled(false);
+	    preview.setBodyStyle('padding', '0px');
 	    this.lookupReference('raw').setDisabled(false);
 	    this.lookupReference('spam').setDisabled(false);
 	    this.lookupReference('download').setDisabled(false);
 	    preview.update("<iframe frameborder=0 width=100% height=100% sandbox='allow-same-origin' src='" + url +"'></iframe>");
 	},
 
-	multiSelect: function() {
+	multiSelect: function(selection) {
 	    var preview = this.lookupReference('preview');
 	    var raw = this.lookupReference('raw');
 	    var spam = this.lookupReference('spam');
@@ -87,7 +88,21 @@ Ext.define('PMG.SpamQuarantine', {
 	    var download = this.lookupReference('download');
 
 	    preview.setDisabled(false);
-	    preview.update('<h3>' + gettext('Multiple E-Mails selected') + '</h3>');
+	    preview.setBodyStyle('padding', '10px');
+	    let previewtext = `<h3>${gettext('Multiple E-Mails selected')} (${selection.length})</h3>`;
+
+	    let selectionsummary = {};
+	    selection.forEach((mail) => {
+		let sender = Ext.htmlEncode(mail.data.from);
+		if (!selectionsummary[sender]) {
+		    selectionsummary[sender] = `<b>${sender}</b>`;
+		}
+		selectionsummary[sender] += `<br>${Ext.htmlEncode(mail.data.subject)}`;
+	    });
+
+	    previewtext += Object.values(selectionsummary).join('<br><br>');
+
+	    preview.update(previewtext);
 	    raw.setDisabled(true);
 	    spam.setDisabled(true);
 	    spam.setPressed(false);
@@ -154,7 +169,7 @@ Ext.define('PMG.SpamQuarantine', {
 	    var list = this.lookupReference('list');
 	    var selection = list.selModel.getSelection();
 	    if (selection.length > 1) {
-		me.multiSelect();
+		me.multiSelect(selection);
 		return;
 	    }
 
-- 
2.20.1




More information about the pmg-devel mailing list