[pmg-devel] [PATCH pmg-gui 1/3] implement multiselection of spamquarantine mails

Dominik Csapak d.csapak at proxmox.com
Wed Mar 28 10:36:00 CEST 2018


and allow the actions to be sent for all simultaniously

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 js/QuarantineList.js  |  4 ++++
 js/SpamQuarantine.js  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 js/VirusQuarantine.js |  1 +
 3 files changed, 50 insertions(+)

diff --git a/js/QuarantineList.js b/js/QuarantineList.js
index fcfa3b4..597e573 100644
--- a/js/QuarantineList.js
+++ b/js/QuarantineList.js
@@ -18,6 +18,10 @@ Ext.define('PMG.QuarantineList', {
 	to: 0
     },
 
+    selModel: {
+	selType: 'checkboxmodel'
+    },
+
     controller: {
 	xclass: 'Ext.app.ViewController',
 
diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js
index cec03c1..5c6865b 100644
--- a/js/SpamQuarantine.js
+++ b/js/SpamQuarantine.js
@@ -63,9 +63,25 @@ Ext.define('PMG.SpamQuarantine', {
 
 	    var url = '/api2/htmlmail/quarantine/content?id=' + rec.data.id + ((raw)?'&raw=1':'');
 	    preview.setDisabled(false);
+	    this.lookupReference('raw').setDisabled(false);
+	    this.lookupReference('spam').setDisabled(false);
 	    preview.update("<iframe frameborder=0 width=100% height=100% sandbox='allow-same-origin' src='" + url +"'></iframe>");
 	},
 
+	multiSelect: function() {
+	    var preview = this.lookupReference('preview');
+	    var raw = this.lookupReference('raw');
+	    var spam = this.lookupReference('spam');
+	    var spaminfo = this.lookupReference('spaminfo');
+
+	    preview.setDisabled(false);
+	    preview.update('<h3>' + gettext('Multiple E-Mails selected') + '</h3>');
+	    raw.setDisabled(true);
+	    spam.setDisabled(true);
+	    spam.setPressed(false);
+	    spaminfo.setVisible(false);
+	},
+
 	toggleRaw: function(button) {
 	    var me = this;
 	    var list = this.lookupReference('list');
@@ -83,6 +99,30 @@ Ext.define('PMG.SpamQuarantine', {
 
 	    var action = button.reference;
 
+	    if (selected.length > 1) {
+		var idlist = [];
+		selected.forEach(function(item) {
+		    idlist.push(item.data.id);
+		});
+		Ext.Msg.confirm(
+		    gettext('Confirm'),
+		    Ext.String.format(
+			gettext("Action '{0}' for '{1}' items"),
+			action, selected.length
+		    ),
+		    function(button) {
+			if (button !== 'yes') {
+			    return;
+			}
+
+			PMG.Utils.doQuarantineAction(action, idlist.join(';'), function() {
+			    list.getController().load();
+			});
+		    }
+		);
+		return;
+	    }
+
 	    PMG.Utils.doQuarantineAction(action, selected[0].data.id, function() {
 		list.getController().load();
 	    });
@@ -91,6 +131,11 @@ Ext.define('PMG.SpamQuarantine', {
 	onSelectMail: function() {
 	    var me = this;
 	    var list = this.lookupReference('list');
+	    var selection = list.selModel.getSelection();
+	    if (selection.length > 1) {
+		me.multiSelect();
+		return;
+	    }
 	    var rec = list.selModel.getSelection()[0];
 
 	    me.updatePreview(me.raw || false, rec);
diff --git a/js/VirusQuarantine.js b/js/VirusQuarantine.js
index 8a1d46f..bd8ee8f 100644
--- a/js/VirusQuarantine.js
+++ b/js/VirusQuarantine.js
@@ -91,6 +91,7 @@ Ext.define('PMG.VirusQuarantine', {
 	{
 	    title: gettext('Virus Quarantine'),
 	    xtype: 'pmgQuarantineList',
+	    selModel: 'rowmodel',
 	    emptyText: gettext('No data in database'),
 	    emailSelection: false,
 	    reference: 'list',
-- 
2.11.0




More information about the pmg-devel mailing list