You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/05/09 16:01:42 UTC
[45/50] git commit: updated refs/heads/route-events to c33e390
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/cf534b68
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/cf534b68
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/cf534b68
Branch: refs/heads/route-events
Commit: cf534b682b419c27a12084acf43fcfaa9549feb0
Parents: d2ffad3
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Apr 25 17:24:43 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu May 9 09:59:59 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/cf534b68/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/cf534b68/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 {};
}
});