You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2014/07/14 10:35:46 UTC
[10/13] fauxton commit: updated refs/heads/master to 0ec46e9
Fauxton: Add view filter
This allows a module to register an extension to filter out what views
should be displayed in the side bar.
An example of usage is to only display views that have
"language:javascript"
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/7d4f14e2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/7d4f14e2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/7d4f14e2
Branch: refs/heads/master
Commit: 7d4f14e2623515e12526c505865991f9960bf58f
Parents: adc99a4
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jul 1 14:31:12 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jul 2 10:06:45 2014 +0200
----------------------------------------------------------------------
app/addons/documents/resources.js | 8 ++++++++
app/addons/documents/views.js | 26 +++++++++++++++++++++++---
2 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/7d4f14e2/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/resources.js b/app/addons/documents/resources.js
index 21cdfdd..dc71153 100644
--- a/app/addons/documents/resources.js
+++ b/app/addons/documents/resources.js
@@ -482,6 +482,14 @@ function(app, FauxtonAPI, PagingCollection) {
});
return PagingCollection.prototype.parse.call(this, resp);
+ },
+
+ clone: function () {
+ return new this.constructor(this.models, {
+ database: this.database,
+ params: this.params,
+ paging: this.paging
+ });
}
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/7d4f14e2/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views.js b/app/addons/documents/views.js
index 4e7459a..6ccb733 100644
--- a/app/addons/documents/views.js
+++ b/app/addons/documents/views.js
@@ -26,7 +26,7 @@ define([
// Plugins
"plugins/beautify",
"plugins/prettify",
- // this should be never global available:
+ // this should never be global available:
// https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/security.md
"plugins/zeroclipboard/ZeroClipboard"
],
@@ -1710,8 +1710,19 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
this.reduceFunStr = this.model.viewHasReduce(this.viewName);
}
+ var viewFilters = FauxtonAPI.getExtensions('sidebar:viewFilters'),
+ filteredModels = this.ddocs.models,
+ designDocs = this.ddocs.clone();
+
+ if (!_.isEmpty(viewFilters)) {
+ _.each(viewFilters, function (filter) {
+ filteredModels = _.filter(filteredModels, filter);
+ });
+ designDocs.reset(filteredModels, {silent: true});
+ }
+
this.designDocSelector = this.setView('.design-doc-group', new Views.DesignDocSelector({
- collection: this.ddocs,
+ collection: designDocs,
ddocName: this.model.id,
database: this.database
}));
@@ -1874,7 +1885,16 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
extension.render();
}, this);
- this.collection.each(function(design) {
+ var viewFilters = FauxtonAPI.getExtensions('sidebar:viewFilters'),
+ collection = this.collection.models;
+
+ if (!_.isEmpty(viewFilters)) {
+ _.each(viewFilters, function (filter) {
+ collection = _.filter(collection, filter);
+ });
+ }
+
+ _.each(collection, function(design) {
if (design.has('doc')){
var ddoc = design.id.replace(/^_design\//,"");
if (design.get('doc').views){