Fixed  FELIX-3449 Event plugin cannto send events without properties
https://issues.apache.org/jira/browse/FELIX-3449

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1310250 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle.properties
index e9a94b0..3490075 100644
--- a/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -44,3 +44,4 @@
 post=Post Event

 send=Send Event

 close=Close

+reset=Reset

diff --git a/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle_bg.properties b/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
index 72a0490..c16660d 100644
--- a/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
+++ b/webconsole-plugins/event/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
@@ -44,4 +44,5 @@
 post=Прати

 send=Прати веднага

 close=Затваряне

+reset=Ресет

 

diff --git a/webconsole-plugins/event/src/main/resources/res/events.html b/webconsole-plugins/event/src/main/resources/res/events.html
index 4f7b700..89bc616 100644
--- a/webconsole-plugins/event/src/main/resources/res/events.html
+++ b/webconsole-plugins/event/src/main/resources/res/events.html
@@ -6,6 +6,7 @@
 	displayTimeline: '${displayTimeline}',

 	displayList    : '${displayList}',

 	close          : '${close}',

+    reset          : '${reset}',

 	send           : '${send}',

 	post           : '${post}'

 }

@@ -58,9 +59,7 @@
 		</tr>

 		<tr>

 			<th>${properties}:</th>

-			<td>

-				<div id="sendProperties">&nbsp;</div>

-			</td>

+			<td id="sendProperties"></td>

 		</tr>

 	</tbody>

 	</table>

diff --git a/webconsole-plugins/event/src/main/resources/res/ui/events.css b/webconsole-plugins/event/src/main/resources/res/ui/events.css
index ea62a6b..a8dbe20 100644
--- a/webconsole-plugins/event/src/main/resources/res/ui/events.css
+++ b/webconsole-plugins/event/src/main/resources/res/ui/events.css
@@ -31,6 +31,6 @@
 .addremove button { width: 16px; height: 16px; line-height: 10px; font-size: 10px; margin: 2px 2px }
 .addremove_inner { display: inline }
 .propeditor_entry select {	margin-left: 4px }
-#sendTopic { width: 100% }
+#sendTopic { width: 100%; margin-bottom: 1em }
 #sendDialog table { margin-left: auto; margin-right: auto }
 #sendDialog table th { text-align: right; font-weight: bold; padding-right: .5em }
diff --git a/webconsole-plugins/event/src/main/resources/res/ui/events.js b/webconsole-plugins/event/src/main/resources/res/ui/events.js
index 2cd1abd..89c835d 100644
--- a/webconsole-plugins/event/src/main/resources/res/ui/events.js
+++ b/webconsole-plugins/event/src/main/resources/res/ui/events.js
@@ -104,10 +104,10 @@
 		if (topicOk) {
 			sendTopic.removeClass('ui-state-error');
 		} else {
-			addTopic.removeClass('ui-state-error');
+			sendTopic.addClass('ui-state-error');
 		}
 		var data = sendProperties.propeditor('serialize');
-		if (topicOk && data != false) {
+		if (topicOk && typeof data != 'boolean') {
 			$.post(pluginRoot,
 				data.concat([
 					{name : 'action', value : action},
@@ -125,6 +125,9 @@
 	sendButtons[i18n.close] = function() {
 		$(this).dialog("close");
 	}
+	sendButtons[i18n.reset] = function() {
+		sendProperties.propeditor('reset');
+	}
 	sendButtons[i18n.send] = function() {
 		sendData('send');
 	}
@@ -137,8 +140,8 @@
 		width   : '40%',
 		buttons : sendButtons,
 		open    : function() {
-			sendTopic.val('');
-			sendProperties.propeditor('reset');
+			//sendTopic.val('');
+			//sendProperties.propeditor('reset');
 		}
 	});
 	var sendTopic = $('#sendTopic');
diff --git a/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js b/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js
index 51f47d7..9cfd895 100644
--- a/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js
+++ b/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js
@@ -21,22 +21,22 @@
 	
 	Options:
 	validator : function(keyInputField, valInputField, type)
+	types     : ['byte', 'int', 'long', 'float', 'double', 'string', 'char', 'hex', 'base64', 'sha1']
 */
 (function( $ ){
-	var TYPES = ['byte', 'int', 'long', 'float', 'double', 'string', 'char', 'hex', 'base64', 'sha1'];
-
 	var methods = {
 		init : function(options) {
 			return this.each( function() {
 				// If options exist, lets merge them with our default settings
 				var settings = {
 					validator  : false,
+					types      : ['byte', 'int', 'long', 'float', 'double', 'string', 'char', 'hex', 'base64', 'sha1']
 				};
 				if (options) settings = $.extend(settings, options);
 
 				var _this = $(this);
 				_this.data('propeditor_settings', settings);
-				_this.append(_entry());
+				_this.append(_entry(settings.types));
 				_this.addremove(settings);
 			})
 		},
@@ -56,15 +56,13 @@
 			if (entries.size() == 1) {
 				var k = entries.find('.key').removeClass('ui-state-error').val();
 				var v = entries.find('.val').removeClass('ui-state-error').val();
-				if (k != '' || v != '') {
+				if (k || v) {
 					var data = _check_entry( entries, validator );
-					//if ( data == false ) ok = false; else result.push(data);
 					if ( data == false ) ok = false; else result = data;
 				}
 			} else {
 				entries.each(function() {
 					var data = _check_entry( $(this), validator );
-					//if ( data == false ) ok = false; else result.push(data);
 					if ( data == false ) ok = false; else result = result.concat(data);
 				});
 			}
@@ -102,7 +100,7 @@
 		return ret;
 	}
 
-	var _entry = function() {
+	var _entry = function(TYPES) {
 		var sel = _el('select', 'typ');
 		for(var i in TYPES) {
 			sel.append( _el('option').text( TYPES[i] ) );