summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2013-10-23 17:46:28 +0200
committerGarren Smith <garren.smith@gmail.com>2013-10-23 17:48:51 +0200
commitff3fd64d93041d2cc3063b53d29eaaf3e1215716 (patch)
tree9d9a444d693306fdf52ed8a774b770b7faf6888e
parent308b9937de3a1a46705e2be3ea31828722b1db1b (diff)
downloadcouchdb-fauxton-expand-collapse.tar.gz
Fauxton: Added expand/collapse to all docsfauxton-expand-collapse
-rw-r--r--src/fauxton/app/modules/documents/resources.js50
-rw-r--r--src/fauxton/app/modules/documents/views.js22
-rw-r--r--src/fauxton/app/templates/documents/all_docs_list.html5
3 files changed, 75 insertions, 2 deletions
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
index 5512add18..75df7d113 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});
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index cf5dd3539..55ca40569 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
}));
diff --git a/src/fauxton/app/templates/documents/all_docs_list.html b/src/fauxton/app/templates/documents/all_docs_list.html
index dcb8ddad6..335b040b8 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>
<% } %>