[pve-devel] [PATCH manager 1/9] make pveHelpButton more abstract

Dominik Csapak d.csapak at proxmox.com
Tue Sep 13 13:46:08 CEST 2016


this adds an option to set the helplink on the global event

also we now only set the link instead of the complete handler,
which is now static and gets the url from a property
(which we will set directly for other help buttons)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/button/HelpButton.js | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/www/manager6/button/HelpButton.js b/www/manager6/button/HelpButton.js
index 82f0935..4c2e07a 100644
--- a/www/manager6/button/HelpButton.js
+++ b/www/manager6/button/HelpButton.js
@@ -9,6 +9,7 @@ Ext.define('PVE.button.Help', {
     iconCls: ' x-btn-icon-el-default-toolbar-small fa fa-question-circle',
     cls: 'x-btn-default-toolbar-small pve-help-button',
     hidden: true,
+    listenToGlobalEvent: true,
     controller: {
 	xclass: 'Ext.app.ViewController',
 	listen: {
@@ -18,15 +19,26 @@ Ext.define('PVE.button.Help', {
 	    }
 	},
 	onPveShowHelp: function(helpLink) {
-	    this.getView().setHandler(function() {
-		var docsURI = window.location.origin +
-		'/pve-docs/' + helpLink;
-		window.open(docsURI);
-	    });
-	    this.getView().show();
+	    var me = this.getView();
+	    if (me.listenToGlobalEvent === true) {
+		me.onlineHelp = helpLink;
+		me.show();
+	    }
 	},
 	onPveHideHelp: function() {
-	    this.getView().hide();
+	    var me = this.getView();
+	    if (me.listenGlobalEvent === true) {
+		me.hide();
+	    }
+	}
+    },
+    handler: function() {
+	var me = this;
+	if (me.onlineHelp) {
+	    var docsURI = window.location.origin + '/pve-docs/' + me.onlineHelp;
+	    window.open(docsURI);
+	} else {
+	    Ext.Msg.alert(gettext('Help'), gettext('No Help available'));
 	}
     }
-});
\ No newline at end of file
+});
-- 
2.1.4




More information about the pve-devel mailing list