[icinga-checkins] icinga.org: icinga-web/mhein/default: * Finished new command API (ref #1941 )

git at icinga.org git at icinga.org
Thu Nov 3 12:24:39 CET 2011


Module: icinga-web
Branch: mhein/default
Commit: 10074393188978829234be054687cf36746b1eee
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=10074393188978829234be054687cf36746b1eee

Author: Marius Hein <marius.hein at netways.de>
Date:   Thu Nov  3 12:23:47 2011 +0100

* Finished new command API (ref #1941)

---

 app/modules/Api/lib/js/Command/FormAction.js    |   19 +++++++++++++------
 app/modules/Api/lib/js/Command/Type/Abstract.js |   13 +------------
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/app/modules/Api/lib/js/Command/FormAction.js b/app/modules/Api/lib/js/Command/FormAction.js
index 9b74bee..113b54f 100644
--- a/app/modules/Api/lib/js/Command/FormAction.js
+++ b/app/modules/Api/lib/js/Command/FormAction.js
@@ -9,6 +9,12 @@ Icinga.Api.Command.FormAction = Ext.extend(Ext.form.Action, {
 	command : {},
 	
 	constructor : function(form, options) {
+		
+		Ext.applyIf(options, {
+            clientValidation : true,
+            waitMsg : _('Sending command . . .')
+		});
+		
 		Icinga.Api.Command.FormAction.superclass.constructor.call(this, form, options);
 		
 		if (Ext.isEmpty(options.targets) === false) {
@@ -24,7 +30,7 @@ Icinga.Api.Command.FormAction = Ext.extend(Ext.form.Action, {
 		});
 		
 		this.commandSender.on('success', this.success.createDelegate(this));
-		this.commandSender.on('error', this.failure.createDelegate(this));
+		this.commandSender.on('failure', this.failure.createDelegate(this));
 	},
 	
 	setTargets : function(targets) {
@@ -40,11 +46,11 @@ Icinga.Api.Command.FormAction = Ext.extend(Ext.form.Action, {
 		if(o.clientValidation === false || this.form.isValid()) {
 			var data = this.form.getFieldValues();
 			
-			this.commandSender.send({
-				command : this.command.definition,
-				targets : this.targets,
-				data : data
-			});
+			this.commandSender.setCommand(this.command.definition);
+			this.commandSender.setData(data);
+			this.commandSender.addTarget(this.targets);
+			
+			this.commandSender.send();
 			
 		} else if (o.clientValidation !== false){ // client validation failed
             this.failureType = Ext.form.Action.CLIENT_INVALID;
@@ -53,6 +59,7 @@ Icinga.Api.Command.FormAction = Ext.extend(Ext.form.Action, {
 	},
 	
 	success : function() {
+		this.form.clearInvalid();
 		this.form.afterAction(this, true);
 	},
 	
diff --git a/app/modules/Api/lib/js/Command/Type/Abstract.js b/app/modules/Api/lib/js/Command/Type/Abstract.js
index d7cd344..1d57de6 100644
--- a/app/modules/Api/lib/js/Command/Type/Abstract.js
+++ b/app/modules/Api/lib/js/Command/Type/Abstract.js
@@ -21,7 +21,6 @@ Icinga.Api.Command.Type.Abstract = Ext.extend(Ext.form.FormPanel, {
 	
 	renderSubmit : false,
 	cancelHandler : null,
-    bbar : null,
 	
     xtypeMap : {
         date : 'datefield',
@@ -62,13 +61,7 @@ Icinga.Api.Command.Type.Abstract = Ext.extend(Ext.form.FormPanel, {
     	
     	this.registerHandlers();
     	
-    	var aOptions = Ext.apply({
-    		clientValidation : true,
-    		waitMsg : _('Sending command . . .')
-    	}, 
-    	this.initialConfig);
-    	
-    	AppKit.log(aOptions);
+    	var aOptions = Ext.apply({}, this.initialConfig);
     	
     	this.formAction = new Icinga.Api.Command.FormAction(this.getForm(), aOptions);
     	
@@ -83,10 +76,6 @@ Icinga.Api.Command.Type.Abstract = Ext.extend(Ext.form.FormPanel, {
     	this.form.on('actioncomplete', function(form, action) {
             this.disable();
         }, this);
-        
-        if (this.cancelHandler !== null) {
-            this.form.on('actionfailed', this.cancelhandler, this);
-        }
     },
     
     createSubmitBar : function() {





More information about the icinga-checkins mailing list