瀏覽代碼

More events from the property_field widgets to inform the enclosing form of the state changes.

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

+ 19 - 0
js/property_field.js

@@ -97,6 +97,7 @@ $(function()
 			if (this._equals(new_value, this.value))
 			{
 				this.bModified = false;
+				this._notify_as_clean(true);
 			}
 			else
 			{
@@ -105,6 +106,10 @@ $(function()
 				{
 					this._do_apply();
 				}
+				else
+				{
+					this._notify_as_dirty();
+				}
 			}
 			this._refresh();
 			if (this.options.parent_selector)
@@ -112,6 +117,14 @@ $(function()
 				$(this.options.parent_selector).trigger('subitem_changed');
 			}
 		},
+		_notify_as_dirty: function()
+		{
+			this.element.closest('form').trigger('property_field_dirty', { id: this.options.field_id, reason: 'modified' });
+		},
+		_notify_as_clean: function(bRevert)
+		{
+			this.element.closest('form').trigger('property_field_clean', { id: this.options.field_id, reason: (bRevert ? 'revert' :  'apply') });			
+		},
 		_equals: function( value1, value2 )
 		{
 			if (this.options.equals === null)
@@ -142,6 +155,10 @@ $(function()
 				return this.options.get_field_value();
 			}			
 		},
+		get_field_value: function()
+		{
+			return this._get_field_value();
+		},
 		get_field_name: function()
 		{
 			return $('#'+this.options.field_id, this.element).attr('name');
@@ -186,6 +203,7 @@ $(function()
 					this._refresh();
 				}
 			}
+			this._notify_as_clean(false);
 		},
 		_do_cancel: function()
 		{
@@ -221,6 +239,7 @@ $(function()
 					$(this.options.parent_selector).trigger('subitem_changed');
 				}
 			}
+			this._notify_as_clean(true);
 		},
 		_do_submit: function()
 		{