couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [2/2] git commit: updated refs/heads/route-events to a35cea1
Date Thu, 25 Apr 2013 15:25:03 GMT
added rerenderView to route object to get documents working with views


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a35cea1b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a35cea1b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a35cea1b

Branch: refs/heads/route-events
Commit: a35cea1be7fe4afa836eb31b9bdea6454c9b0a1d
Parents: 08cb780
Author: Garren Smith <garren.smith@gmail.com>
Authored: Thu Apr 25 17:24:43 2013 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Thu Apr 25 17:24:43 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/api.js                      |    8 ++-
 src/fauxton/app/modules/documents/routes.js |  101 ++++++++++++++++++++--
 2 files changed, 100 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a35cea1b/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index c6c3c69..09fad0b 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -146,8 +146,8 @@ function(app, Fauxton) {
 
     renderWith: function(route, masterLayout, args) {
       var routeObject = this;
-      //this.route.apply(this, args);
 
+      this.masterLayout = masterLayout;
       masterLayout.setTemplate(this.layout);
       masterLayout.clearBreadcrumbs();
       var crumbs = this.get('crumbs');
@@ -227,6 +227,12 @@ function(app, Fauxton) {
       return view;
     },
 
+    rerenderView: function(selector) {
+      var view = this._views[selector];
+      this.masterLayout.setView(selector, view);
+      this.masterLayout.renderView(selector);
+    },
+
     getViews: function() {
       return this._views;
     },

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a35cea1b/src/fauxton/app/modules/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js
index f2eaf8b..fa6164c 100644
--- a/src/fauxton/app/modules/documents/routes.js
+++ b/src/fauxton/app/modules/documents/routes.js
@@ -189,7 +189,7 @@ function(app, FauxtonAPI, Documents, Databases) {
       ];
     },
 
-    routes: ["database/:database/_all_docs(:extra)"],
+    routes: ["database/:database/_all_docs(:extra)", "database/:database/_design/:ddoc/_view/:view"],
 
     apiUrl: function() {
       return this.data.database.allDocs.url();
@@ -197,12 +197,74 @@ function(app, FauxtonAPI, Documents, Databases) {
 
     route: function(route, params) {
       this.databaseName = params[0];
+
+      if (params.length > 2) {
+        this.view = params[2].replace(/\?.*$/,'');
+        this.ddoc = params[1];
+      } else {
+        delete this.view;
+        delete this.ddoc;
+      }
+    },
+
+    // this works for now, but it might be work considering having a renderWith function

+    // that only renders a specific view and setups up that views establish beforehand.
+    rerender: function () {
+      var self = this,
+          options = app.getParams();
+
+      options.include_docs = true;
+      this.data.database.buildAllDocs(options);
+
+      this.updateDashboardView();
+
+      //this.documentsView.collection = this.data.database.allDocs;
+
+      $.when.apply(null, this.documentsView.establish()).then(function () {
+        //self.documentsView.render();
+        self.rerenderView('#dashboard-content');
+      });
+    },
+
+    updateDashboardView: function () {
+      var options = app.getParams();
+
+      if (this.view) {
+        var ddocInfo = {
+        id: "_design/" + this.ddoc,
+          currView: this.view,
+          designDocs: this.data.designDocs
+        };
+
+        this.data.indexedDocs = new Documents.IndexCollection(null, {
+          database: this.data.database,
+          design: this.ddoc,
+          view: this.view,
+          params: options
+        });
+
+        this.documentsView = this.setView('#dashboard-content',new Documents.Views.AllDocsList({
+            collection: this.data.indexedDocs,
+            nestedView: Documents.Views.Row,
+            viewList: true,
+            ddocInfo: ddocInfo,
+            params: options
+          }));
+
+      } else {
+
+        this.documentsView = this.setView("#dashboard-content", new Documents.Views.AllDocsList({
+          collection: this.data.database.allDocs
+        }));
+      }
+      
     },
 
     views: function () {
       this.data = {
         database: new Databases.Model({id:this.databaseName})
       };
+
       this.data.designDocs = new Documents.AllDocs(null, {
         database: this.data.database,
         params: {startkey: '"_design"',
@@ -210,14 +272,41 @@ function(app, FauxtonAPI, Documents, Databases) {
           include_docs: true}
       });
 
+
       var options = app.getParams();
       options.include_docs = true;
       this.data.database.buildAllDocs(options);
 
-      this.setView("#dashboard-content", new Documents.Views.AllDocsList({
-        collection: this.data.database.allDocs
-      }));
+      if (this.view) {
+        var ddocInfo = {
+        id: "_design/" + this.ddoc,
+          currView: this.view,
+          designDocs: this.data.designDocs
+        };
+
+        this.data.indexedDocs = new Documents.IndexCollection(null, {
+          database: this.data.database,
+          design: this.ddoc,
+          view: this.view,
+          params: options
+        });
+
+        this.documentsView = this.setView('#dashboard-content',new Documents.Views.AllDocsList({
+            collection: this.data.indexedDocs,
+            nestedView: Documents.Views.Row,
+            viewList: true,
+            ddocInfo: ddocInfo,
+            params: options
+          }));
 
+      } else {
+
+        this.documentsView = this.setView("#dashboard-content", new Documents.Views.AllDocsList({
+          collection: this.data.database.allDocs
+        }));
+      }
+
+      
       this.setView("#sidebar-content", new Documents.Views.Sidebar({
         collection: this.data.designDocs
       }));
@@ -226,8 +315,6 @@ function(app, FauxtonAPI, Documents, Databases) {
         collection: this.data.designDocs,
         database: this.data.database
       }));
-
-      return {};
     }
   });
 
@@ -270,8 +357,6 @@ function(app, FauxtonAPI, Documents, Databases) {
         database: this.database,
         active_id: 'changes'
       }));
-
-      return {};
     }
 
   });


Mime
View raw message