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/10/28 17:13:58 UTC
[41/50] git commit: updated refs/heads/1853-fauxton-route-events to
b70b7ae
Fauxton: Added expand/collapse to all docs
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ff3fd64d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ff3fd64d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ff3fd64d
Branch: refs/heads/1853-fauxton-route-events
Commit: ff3fd64d93041d2cc3063b53d29eaaf3e1215716
Parents: 308b993
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Oct 23 17:46:28 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Oct 23 17:48:51 2013 +0200
----------------------------------------------------------------------
src/fauxton/app/modules/documents/resources.js | 50 ++++++++++++++++++++
src/fauxton/app/modules/documents/views.js | 22 ++++++++-
.../app/templates/documents/all_docs_list.html | 5 ++
3 files changed, 75 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ff3fd64d/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
index 5512add..75df7d1 100644
--- a/src/fauxton/app/modules/documents/resources.js
+++ b/src/fauxton/app/modules/documents/resources.js
@@ -282,6 +282,20 @@ function(app, FauxtonAPI) {
return app.host + "/" + this.database.id + "/_all_docs" + query;
},
+ simple: function () {
+ var docs = this.map(function (item) {
+ return {
+ _id: item.id,
+ _rev: item.get('_rev'),
+ };
+ });
+
+ return new Documents.AllDocs(docs, {
+ database: this.database,
+ params: this.params
+ });
+ },
+
urlNextPage: function (num, lastId) {
if (!lastId) {
var doc = this.last();
@@ -438,6 +452,23 @@ function(app, FauxtonAPI) {
return this.viewMeta.update_seq || false;
},
+ simple: function () {
+ var docs = this.map(function (item) {
+ return {
+ _id: item.id,
+ key: item.get('key'),
+ value: item.get('value')
+ };
+ });
+
+ return new Documents.IndexCollection(docs, {
+ database: this.database,
+ params: this.params,
+ view: this.view,
+ design: this.design
+ });
+ },
+
parse: function(resp) {
var rows = resp.rows;
this.endTime = new Date().getTime();
@@ -529,6 +560,25 @@ function(app, FauxtonAPI) {
return '';
},
+ simple: function () {
+ var docs = this.map(function (item) {
+ return {
+ _id: item.id,
+ key: item.get('key'),
+ value: item.get('value')
+ };
+ });
+
+ return new Documents.PouchIndexCollection(docs, {
+ database: this.database,
+ params: this.params,
+ view: this.view,
+ design: this.design,
+ rows: this.rows
+ });
+
+ },
+
fetch: function() {
var deferred = FauxtonAPI.Deferred();
this.reset(this.rows, {silent: true});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ff3fd64d/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index cf5dd35..55ca405 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -539,6 +539,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
events: {
"click button.all": "selectAll",
"click button.bulk-delete": "bulkDelete",
+ "click #collapse": "collapse",
"change .row-select":"toggleTrash"
},
@@ -560,6 +561,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
this.ddocID = options.ddocInfo.id;
}
this.newView = options.newView || false;
+ this.expandDocs = true;
this.addPagination();
},
@@ -586,10 +588,23 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
return {
viewList: this.viewList,
- requestDuration: requestDuration
+ requestDuration: requestDuration,
+ expandDocs: this.expandDocs
};
},
+ collapse: function (event) {
+ event.preventDefault();
+
+ if (this.expandDocs) {
+ this.expandDocs = false;
+ } else {
+ this.expandDocs = true;
+ }
+
+ this.render();
+ },
+
/*
* TODO: this should be reconsidered
* This currently performs delete operations on the model level,
@@ -667,7 +682,10 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
}));
this.insertView('#documents-pagination', this.pagination);
- this.collection.each(function(doc) {
+ var docs = this.expandDocs ? this.collection : this.collection.simple();
+ console.log('docs', docs);
+
+ docs.each(function(doc) {
this.rows[doc.id] = this.insertView("table.all-docs tbody", new this.nestedView({
model: doc
}));
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ff3fd64d/src/fauxton/app/templates/documents/all_docs_list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_list.html b/src/fauxton/app/templates/documents/all_docs_list.html
index dcb8dda..335b040 100644
--- a/src/fauxton/app/templates/documents/all_docs_list.html
+++ b/src/fauxton/app/templates/documents/all_docs_list.html
@@ -18,6 +18,11 @@ the License.
<div class="btn-toolbar span6">
<button type="button" class="btn all" data-toggle="button">✓ All</button>
<button class="btn btn-small disabled bulk-delete"><i class="icon-trash"></i></button>
+ <% if (expandDocs) { %>
+ <button id="collapse" class="btn"><i class="icon-minus"></i> Collapse</button>
+ <% } else { %>
+ <button id="collapse" class="btn"><i class="icon-plus"></i> Expand</button>
+ <% } %>
</div>
</div>
<% } %>