mark record dirty if cf's changes
authorCornelius Weiß <c.weiss@metaways.de>
Fri, 14 Jul 2017 11:22:02 +0000 (13:22 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Fri, 14 Jul 2017 11:51:33 +0000 (13:51 +0200)
Change-Id: Ibacf101ac2e4745de82ffaed8b04f977ca9c7979
Reviewed-on: http://gerrit.tine20.com/customers/5173
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Tinebase/js/data/Record.js

index 00decb1..84c0a8b 100644 (file)
@@ -123,10 +123,22 @@ Ext.extend(Tine.Tinebase.data.Record, Ext.data.Record, {
         if (this.modified[name] === undefined) {
             this.modified[name] = current;
         }
-        
+        if (encode(value) == encode(this.modified[name])) {
+            delete this.modified[name];
+        }
+        if (Object.keys(this.modified).length === 0) {
+            this.dirty = false;
+        }
         if (cfName = String(name).match(this.cfExp)) {
-            this.data.customfields = this.data.customfields || {};
-            this.data.customfields[cfName[1]] = value;
+            var oldValueJSON = JSON.stringify(this.get('customfields') || {}),
+                valueObject = JSON.parse(oldValueJSON);
+
+            Tine.Tinebase.common.assertComparable(valueObject);
+            valueObject[cfName[1]] = value;
+
+            if (JSON.stringify(valueObject) != oldValueJSON) {
+                this.set('customfields', valueObject);
+            }
         } else {
             this.data[name] = value;
         }