Author: jmorliaguet
Date: Sat Mar 18 16:51:08 2006
New Revision: 2655

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

- Perspective controllers now remember the current perspective
  (the initial perspective is used if there is no current perspective)

- added an 'update(view)' function to make it possible for a controller to 
  update the view.



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 Mar 18 
16:51:08 2006
@@ -448,6 +448,10 @@
 
   unregister: function(view) {
     /* to override */
+  },
+
+  update: function(view) {
+    /* to override */
   }
 }
 
@@ -857,14 +861,14 @@
 
   setup: function() {
     this._visible_views = {};
+    this._current = null;
     CPSSkins.registerEventHandler("parsed", this, function(event) {
-      var initial = this.def.initial;
-      if (initial) {
-        this.switchTo(initial);
+      var perspective = this._current || this.def.initial;
+      if (perspective) {
+        this.switchTo(perspective);
       }
     }.bind(this));
     CPSSkins.subscribe("parsed", {"subscriber": this, "publisher": this.node});
-    this._current = null;
   },
 
   register: function(view) {
@@ -875,15 +879,19 @@
       if (!(p in visible)) {
         visible[p] = [];
       }
-      if (!(view_id in visible[p])) {
+      if (visible[p].indexOf(view_id) < 0) {
         visible[p].push(view_id);
       }
-      if (p == current_perspective) {
-        CPSSkins.getViewById(view_id).show();
-      }
     });
   },
 
+  update: function(view) {
+    var current_perspective = this._current;
+    if ($A(view.def.perspectives).indexOf(current_perspective) >= 0) {
+      view.show();
+    }
+  },
+
   switchTo: function(perspective) {
     this._current = perspective;
     var to_show = this._visible_views[perspective] || [];
@@ -1657,6 +1665,7 @@
     controller.views.add(this.hash());
     controller.unregister(this);
     controller.register(this);
+    controller.update(this);
   },
 
   observe: function(model) {
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to