Author: jmorliaguet
Date: Mon Mar  6 23:05:58 2006
New Revision: 2551

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
Log:

- fix: setting new data should not erase existing fields if they are not
  specified in the data to set (as a side-effect this caused views to be
  redrawn more often than required)



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Mon Mar  6 
23:05:58 2006
@@ -1203,11 +1203,14 @@
     // filter out fields with the wrong data type
     var schema = this.model.schema;
     var new_data = new Object();
+    var current_data = this.read();
     schema.each(function(f) {
       var field = f.key;
       var value = data[field];
-      if (value != null && typeof value == f.value) {
+      if (typeof value == f.value) {
         new_data[field] = value;
+      } else {
+        new_data[field] = current_data[field];
       }
     });
     if (!this.model.hasData() || !this._compareData(this.read(), new_data)) {;

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    Mon Mar  6 23:05:58 2006
@@ -444,17 +444,19 @@
 
       // setData cannot set undefined fields
       model_e2.setData({"a": "2", "new1": true});
-      assertEqual(inspect({"a": "2"}), inspect(model_e2.getData()));
+      assertEqual(inspect({"a": "2", "b": "2", "c": true}), 
inspect(model_e2.getData()));
 
       // setData cannot change field types
       model_e2.setData({"a": 5});
-      assertEqual(inspect({}), inspect(model_e2.getData()));
+      assertEqual(inspect({"a": "2", "b": "2", "c": true}), 
inspect(model_e2.getData()));
 
       model_e2.setData({"c": false});
-      assertEqual(inspect({"c": false}), inspect(model_e2.getData()));
+      assertEqual(inspect({"a": "2", "b": "2", "c": false}),
+                  inspect(model_e2.getData()));
 
       model_e2.setData({"a": "3", "b": true});
-      assertEqual(inspect({"a": "3"}), inspect(model_e2.getData()));
+      assertEqual(inspect({"a": "3", "b": "2", "c": false}),
+                  inspect(model_e2.getData()));
     }},
 
     testUpdateData: function() { with(this) {
@@ -465,7 +467,8 @@
                   inspect(model_e2.getData()));
 
       model_e2.updateData({"a": "2", "b": 4, "c":true, "d": 1});
-      assertEqual(inspect({"a": "2", "c":true}), inspect(model_e2.getData()));
+      assertEqual(inspect({"a": "2", "b": "2", "c":true}),
+                  inspect(model_e2.getData()));
     }},
 
     testUnifiedStoragesGetData: function() { with(this) {
@@ -496,7 +499,7 @@
       model_c1.setData({"a": 4});
       assertEqual(inspect({"a": 4, "b": 1}), inspect(model_c1.getData()));
       assertEqual(inspect({"a": 4}), inspect(model_m1.getData()));
-      assertEqual(inspect({}), inspect(model_m2.getData()));
+      assertEqual(inspect({"b": 1}), inspect(model_m2.getData()));
 
     }},
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to