[pmg-devel] [PATCH pmg-gui 3/4] SpamQuarantine: add context menu

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


with the actions: deliver,delete,whitelist,blacklist

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 js/Makefile           |  1 +
 js/SpamContextMenu.js | 43 +++++++++++++++++++++++++++++++++++++++++++
 js/SpamQuarantine.js  | 16 +++++++++++++++-
 3 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 js/SpamContextMenu.js

diff --git a/js/Makefile b/js/Makefile
index dd35f74..069fc7b 100644
--- a/js/Makefile
+++ b/js/Makefile
@@ -79,6 +79,7 @@ JSSRC=							\
 	ReceiverStatistics.js				\
 	ContactStatistics.js				\
 	HourlyMailDistribution.js			\
+	SpamContextMenu.js				\
 	Application.js
 
 OnlineHelpInfo.js: /usr/bin/asciidoc-pmg
diff --git a/js/SpamContextMenu.js b/js/SpamContextMenu.js
new file mode 100644
index 0000000..819f1dc
--- /dev/null
+++ b/js/SpamContextMenu.js
@@ -0,0 +1,43 @@
+Ext.define('PMG.menu.SpamContextMenu', {
+    extend: 'Ext.menu.Menu',
+
+    showSeparator: false,
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+	callCallback: function(btn) {
+	    var me = this.getView();
+	    if (Ext.isFunction(me.callback)) {
+		me.callback(btn.action);
+	    }
+	}
+    },
+
+    items: [
+	{
+	    text: gettext('Deliver'),
+	    iconCls: 'fa fa-fw fa-paper-plane-o',
+	    action: 'deliver',
+	    handler: 'callCallback'
+	},
+	{
+	    text: gettext('Delete'),
+	    iconCls: 'fa fa-fw fa-trash-o',
+	    action: 'delete',
+	    handler: 'callCallback'
+	},
+	{ xtype: 'menuseparator' },
+	{
+	    text: gettext('Whitelist'),
+	    iconCls: 'fa fa-fw fa-check',
+	    action: 'whitelist',
+	    handler: 'action'
+	},
+	{
+	    text: gettext('Blacklist'),
+	    iconCls: 'fa fa-fw fa-times',
+	    action: 'blacklist',
+	    handler: 'action'
+	}
+    ]
+});
diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js
index 32faa6d..6ff74eb 100644
--- a/js/SpamQuarantine.js
+++ b/js/SpamQuarantine.js
@@ -153,6 +153,19 @@ Ext.define('PMG.SpamQuarantine', {
 	    grid.setVisible(!grid.isVisible());
 	},
 
+	openContextMenu: function(table, record, tr, index, event) {
+	    event.stopEvent();
+	    var me = this;
+	    var list = me.lookup('list');
+	    var menu = Ext.create('PMG.menu.SpamContextMenu', {
+		callback: function(action) {
+		    me.doAction(action, list.getSelection());
+		}
+	    });
+
+	    menu.showAt(event.getXY());
+	},
+
 	init: function(view) {
 	    this.lookup('list').cselect = view.cselect;
 	},
@@ -165,7 +178,8 @@ Ext.define('PMG.SpamQuarantine', {
 		click: 'toggleSpamInfo'
 	    },
 	    'pmgQuarantineList': {
-		selectionChange: 'onSelectMail'
+		selectionChange: 'onSelectMail',
+		rowcontextmenu: 'openContextMenu'
 	    }
 	}
     },
-- 
2.11.0




More information about the pmg-devel mailing list