You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2011/07/07 13:55:53 UTC

svn commit: r1143781 - /felix/trunk/webconsole/src/main/resources/res/ui/config.js

Author: fmeschbe
Date: Thu Jul  7 11:55:53 2011
New Revision: 1143781

URL: http://svn.apache.org/viewvc?rev=1143781&view=rev
Log:
#FELIX-3024 Add Unbind and Delete buttons to the configuration dialog

Modified:
    felix/trunk/webconsole/src/main/resources/res/ui/config.js

Modified: felix/trunk/webconsole/src/main/resources/res/ui/config.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/config.js?rev=1143781&r1=1143780&r2=1143781&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/config.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/config.js Thu Jul  7 11:55:53 2011
@@ -125,7 +125,11 @@ function displayConfigForm(obj) {
 	var ua = navigator.userAgent;
 	if (ua.indexOf('MSIE 6') != -1 || ua.indexOf('MSIE 7') != -1) $(parent).html(parent.innerHTML);
 
-	initStaticWidgets(editor.attr('__pid', obj.pid).dialog('option', 'title', obj.title).dialog('open'));
+	initStaticWidgets(editor
+		.attr('__pid', obj.pid)
+		.attr('__location', obj.bundleLocation?obj.bundleLocation:'')
+		.dialog('option', 'title', obj.title)
+		.dialog('open'));
 }
 
 function printTextArea(/* Element */ parent, props )
@@ -410,8 +414,6 @@ function removeValue(vidx)
 
 function configConfirm(/* String */ message, /* String */ title, /* String */ location)
 {
-    var message = i18n.del_ask;
-    
     if (title) {
         message += "\r\n" + i18n.del_config + title;
     }
@@ -422,14 +424,26 @@ function configConfirm(/* String */ mess
     return confirm(message);
 }
 
-function confirmDelete(/* String */ title, /* String */ location)
+function deleteConfig(/* String */ configId, /* String */ bundleLocation)
 {
-    return configConfirm(i18n.del_ask, title, location);
+    if ( configConfirm(i18n.del_ask, configId, bundleLocation) ) {
+	$.post(pluginRoot + '/' + configId + '?apply=1&delete=1', null, function() {
+	    document.location.href = pluginRoot;
+	}, 'json');
+	return true;
+    }
+    return false;
 }
 
-function confirmUnbind(/* String */ title, /* String */ location)
+function unbindConfig(/* String */ configId, /* String */ bundleLocation)
 {
-    return configConfirm(i18n.unbind_ask, title, location);
+    if ( configConfirm(i18n.unbind_ask, configId, bundleLocation) ) {
+	$.post(pluginRoot + '/' + configId + '?unbind=1', null, function() {
+	    document.location.href = pluginRoot + '/' + configId;
+	}, 'json');
+	return true;
+    }
+    return false;
 }
 
 function addConfig(conf) {
@@ -454,19 +468,13 @@ function addConfig(conf) {
 		configure(conf.id);
 	});
 	tr.find('li:eq(2)').click(function() { // delete
-		if ( confirmDelete(conf.id, conf.bundle_name) ) {
-			$.post(pluginRoot + '/' + conf.id + '?apply=1&delete=1', null, function() {
-				document.location.href = pluginRoot;
-			}, 'json');
-		}
+	    	deleteConfig(conf.id, conf.bundle_name);
 	});
-	if (conf.bundle) tr.find('li:eq(1)').click(function() { // unbind
-		if ( confirmUnbind(conf.id, conf.bundle_name) ) {
-			$.post(pluginRoot + '/' + conf.id + '?apply=1&delete=1', null, function() {
-				document.location.href = pluginRoot + '/' + conf.id;
-			}, 'json');
-		}
-	}).removeClass('ui-state-disabled');
+	if (conf.bundle) {
+	    	tr.find('li:eq(1)').click(function() { // unbind
+        		unbindConfig(conf.id, conf.bundle_name);
+        	}).removeClass('ui-state-disabled');
+	}
 }
 
 function addFactoryConfig(conf) {
@@ -518,9 +526,18 @@ $(document).ready(function() {
 		var form = document.getElementById('editorForm');
 		if (form) form.reset();
 	}
+	_buttons[i18n.del] = function() {
+	    	if (deleteConfig($(this).attr('__pid'), $(this).attr('__location'))) {
+			$(this).dialog('close');
+	    	}
+	}
+	_buttons[i18n.unbind_btn] = function() {
+	    	unbindConfig($(this).attr('__pid'), $(this).attr('__location'));
+	}
 	_buttons[i18n.save] = function() {
 		$.post(pluginRoot + '/' + $(this).attr('__pid') + '?' + $(this).find('form').serialize());
 		$(this).dialog('close');
+		document.location.href = pluginRoot;
 	}
 	// prepare editor, but don't open yet!
 	editor = $('#editor').dialog({