Author: jmorliaguet
Date: Sat Feb  4 16:08:48 2006
New Revision: 2287

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- fixes, data changes were not propagated from the compound storage to the model



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 Sat Feb  4 
16:08:48 2006
@@ -644,8 +644,8 @@
     var model = this;
     // observers subscribes to events on the model
     CPSSkins.registerEventHandler('modified', view, function(event) {
-        var data = event.target.def.data;
-        event.subscriber.render(data);
+      var data = event.target.def.data;
+      event.subscriber.render(data);
     });
     CPSSkins.subscribe('modified', {'subscriber': view, 'target': model});
     // create a back-reference
@@ -677,13 +677,14 @@
       storage_def = {"type": "volatile"};
     }
     var model = this;
+    var storage = Storages[storage_def.type](this);
     // the model reacts to events on the storage and notifies observers
     CPSSkins.registerEventHandler('stored', model, function(event) {
       CPSSkins.notify('modified', model);
     });
 
-    CPSSkins.subscribe('stored', {'subscriber': model, 'target': 
this.storage});
-    return Storages[storage_def.type](this);
+    CPSSkins.subscribe('stored', {'subscriber': model, 'target': storage});
+    return storage;
   }
 
 }
@@ -761,6 +762,14 @@
   setup: function() {
     var models = $A([]);
     var storage = this;
+
+    // merge the data from all storages
+    CPSSkins.registerEventHandler('stored', storage, function(event) {
+      event.subscriber.merge(event.target.read());
+      // propagate the event
+      CPSSkins.notify('stored', storage);
+    });
+
     $A(this.model.def.storage.partitions).each(function(p) {
       var model = CPSSkins.getModelById(p);
       models.push(model);
@@ -769,12 +778,6 @@
       );
     });
     this.models = models;
-
-    // merge the data from all storages
-    CPSSkins.registerEventHandler('stored', storage, function(event) {
-      event.subscriber.merge(event.target.read());
-    });
-
   },
 
   requestData: function() {
@@ -822,7 +825,7 @@
     new Ajax.Request(url, {
       onComplete: function(req) {
         var data = JSON.parse(req.responseText);
-        this.write(data);
+        storage.write(data);
         CPSSkins.notify('stored', storage);
       }
     });
@@ -840,7 +843,7 @@
         }).toQueryString(),
       onComplete: function(req) {
         var data = JSON.parse(req.responseText);
-        this.write(data);
+        storage.write(data);
         CPSSkins.notify('stored', storage);
       }
     });
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to