[pve-devel] [PATCH v2 manager] Add context menu to global search entries

Christian Ebner c.ebner at proxmox.com
Tue Jan 29 12:41:31 CET 2019


This add a context menu to the entries of the global search field instead of
showing the browsers default one.
This allows to search and easily manage nodes, VMs and CTs similar to the
behaviour in the resource tree.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---

Version 2:
    * createCmdMenu() now returns a reference to the menu in order to check if it
      is visible or not
    * textfield remains visible as long as the context menu exists and is visible

 www/manager6/Utils.js                  | 1 +
 www/manager6/form/GlobalSearchField.js | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index cf9cbdc9..cbd5c756 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -991,6 +991,7 @@ Ext.define('PVE.Utils', { utilities: {
 	}
 
 	menu.showAt(event.getXY());
+	return menu;
     },
 
     // helper for deleting field which are set to there default values
diff --git a/www/manager6/form/GlobalSearchField.js b/www/manager6/form/GlobalSearchField.js
index cac33f78..6393df12 100644
--- a/www/manager6/form/GlobalSearchField.js
+++ b/www/manager6/form/GlobalSearchField.js
@@ -45,6 +45,9 @@ Ext.define('PVE.form.GlobalSearchField', {
 
 	hideMe: function() {
 	    var me = this;
+	    if (typeof me.ctxMenu !== 'undefined' && me.ctxMenu.isVisible()) {
+		return;
+	    }
 	    me.hasFocus = false;
 	    if (!me.textfield.hasFocus) {
 		me.hide();
@@ -61,6 +64,10 @@ Ext.define('PVE.form.GlobalSearchField', {
 		var me = this;
 		me.textfield.selectAndHide(record.id);
 	    },
+	    itemcontextmenu: function(v, record, item, index, event) {
+		var me = this;
+		me.ctxMenu = PVE.Utils.createCmdMenu(v, record, item, index, event);
+	    },
 	    /* because of lint */
 	    focusleave: {
 		fn: 'hideMe'
-- 
2.11.0




More information about the pve-devel mailing list