[pmg-devel] [PATCH pmg-gui 4/4] SpamQuarantine: add keyboard shortcuts for actions

Dominik Csapak d.csapak at proxmox.com
Wed Mar 28 16:55:45 CEST 2018


d/D: deliver
delete: delete
w/W: whitelist
b/B: blacklist

the delete key registers differently depending on browser,
so we have to check for event.DELETE and '127'

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
why do those things always have to be so inconsistent
across browsers/versions...
 js/SpamQuarantine.js | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js
index 6ff74eb..ec0182d 100644
--- a/js/SpamQuarantine.js
+++ b/js/SpamQuarantine.js
@@ -166,6 +166,35 @@ Ext.define('PMG.SpamQuarantine', {
 	    menu.showAt(event.getXY());
 	},
 
+	keyPress: function (table, record, item, index, event) {
+	    var me = this;
+	    var list = me.lookup('list');
+	    var key = event.getKey();
+	    var action = '';
+	    switch(key) {
+		case event.DELETE:
+		case 127:
+		    action = 'delete';
+		    break;
+		case Ext.event.Event.D:
+		case Ext.event.Event.D + 32:
+		    action = 'deliver';
+		    break;
+		case Ext.event.Event.W:
+		case Ext.event.Event.W + 32:
+		    action = 'whitelist';
+		    break;
+		case Ext.event.Event.B:
+		case Ext.event.Event.B + 32:
+		    action = 'blacklist';
+		    break;
+	    }
+
+	    if (action !== '') {
+		me.doAction(action, list.getSelection());
+	    }
+	},
+
 	init: function(view) {
 	    this.lookup('list').cselect = view.cselect;
 	},
@@ -179,6 +208,7 @@ Ext.define('PMG.SpamQuarantine', {
 	    },
 	    'pmgQuarantineList': {
 		selectionChange: 'onSelectMail',
+		itemkeypress: 'keyPress',
 		rowcontextmenu: 'openContextMenu'
 	    }
 	}
-- 
2.11.0




More information about the pmg-devel mailing list