瀏覽代碼

User editable dashboards... implementation in progress

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2036 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 年之前
父節點
當前提交
be14972a00
共有 2 個文件被更改,包括 42 次插入28 次删除
  1. 0 4
      js/dashboard.js
  2. 42 24
      js/property_field.js

+ 0 - 4
js/dashboard.js

@@ -66,10 +66,6 @@ $(function()
 		{
 		{
 			// in 1.9 would use _super
 			// in 1.9 would use _super
 			$.Widget.prototype._setOption.call( this, key, value );
 			$.Widget.prototype._setOption.call( this, key, value );
-			if (key == 'layout')
-			{
-				_refresh();
-			}
 		},
 		},
 		_get_state: function(oMergeInto)
 		_get_state: function(oMergeInto)
 		{
 		{

+ 42 - 24
js/property_field.js

@@ -10,7 +10,9 @@ $(function()
 		{
 		{
 			field_id: '',
 			field_id: '',
 			submit_to: 'index.php',
 			submit_to: 'index.php',
-			submit_parameters: {operation: 'async_action'}
+			submit_parameters: {operation: 'async_action'},
+			do_apply: null,
+			do_cancel: null
 			
 			
 		},
 		},
 	
 	
@@ -98,41 +100,57 @@ $(function()
 		},
 		},
 		_do_apply: function()
 		_do_apply: function()
 		{
 		{
-			// Validate the field
-			sFormId = this.element.closest('form').attr('id');
-			var oField = $('#'+this.options.field_id);
-			oField.trigger('validate');
-			if ( $.inArray(this.options.field_id, oFormValidation[sFormId]) == -1)
+			if (this.options.do_apply)
 			{
 			{
-				this.bModified = false;
-				this.previous_value = this.value;
-				this.value = this._get_field_value();
-				this._do_submit();
-				this._refresh();
+				// specific behavior...
+				this.options.do_apply();
+			}
+			else
+			{
+				// Validate the field
+				sFormId = this.element.closest('form').attr('id');
+				var oField = $('#'+this.options.field_id);
+				oField.trigger('validate');
+				if ( $.inArray(this.options.field_id, oFormValidation[sFormId]) == -1)
+				{
+					this.bModified = false;
+					this.previous_value = this.value;
+					this.value = this._get_field_value();
+					this._do_submit();
+					this._refresh();
+				}
 			}
 			}
 		},
 		},
 		_do_cancel: function()
 		_do_cancel: function()
 		{
 		{
-			this.bModified = false;
-			var oField = $('#'+this.options.field_id);
-			if (oField.attr('type') == 'checkbox')
+			if (this.options.do_cancel)
 			{
 			{
-				if (this.value)
+				// specific behavior...
+				this.options.do_cancel();
+			}
+			else
+			{
+				this.bModified = false;
+				var oField = $('#'+this.options.field_id);
+				if (oField.attr('type') == 'checkbox')
 				{
 				{
-					oField.attr('checked', true);					
+					if (this.value)
+					{
+						oField.attr('checked', true);					
+					}
+					else
+					{
+						oField.removeAttr('checked');										
+					}
 				}
 				}
 				else
 				else
 				{
 				{
-					oField.removeAttr('checked');										
+					oField.val(this.value);				
 				}
 				}
+				this._refresh();
+				oField.trigger('reverted', {type: 'designer', previous_value: this.value });
+				oField.trigger('validate');
 			}
 			}
-			else
-			{
-				oField.val(this.value);				
-			}
-			this._refresh();
-			oField.trigger('reverted', {type: 'designer', previous_value: this.value });
-			oField.trigger('validate');
 		},
 		},
 		_do_submit: function()
 		_do_submit: function()
 		{
 		{