You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2014/07/17 19:14:21 UTC
[09/10] fauxton commit: updated refs/heads/2158-changes-filter to
b1121db
make deleted documents searchable
they are missing an explicit deleted flag
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/1275ec6d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/1275ec6d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/1275ec6d
Branch: refs/heads/2158-changes-filter
Commit: 1275ec6d6b87f323b1ad92b5861b3c7abcb21feb
Parents: 65a4a3f
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Thu May 29 16:33:12 2014 +0200
Committer: Robert Kowalski <ro...@kowalski.gd>
Committed: Thu Jul 17 19:13:37 2014 +0200
----------------------------------------------------------------------
app/addons/documents/tests/viewsSpec.js | 25 ++++++++++++++++++++++++-
app/addons/documents/views.js | 25 +++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1275ec6d/app/addons/documents/tests/viewsSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/viewsSpec.js b/app/addons/documents/tests/viewsSpec.js
index 8bc1397..6eaf802 100644
--- a/app/addons/documents/tests/viewsSpec.js
+++ b/app/addons/documents/tests/viewsSpec.js
@@ -11,8 +11,9 @@
// the License.
define([
'addons/documents/views',
+ 'addons/databases/base',
'testUtils'
-], function (Views, testUtils) {
+], function (Views, Databases, testUtils) {
var assert = testUtils.assert;
describe('DocumentsViews', function () {
@@ -20,4 +21,26 @@ define([
assert.equal(typeof Views.Views.Changes, 'function');
});
});
+
+ describe('Changes', function () {
+ var filteredView;
+ beforeEach(function () {
+ var database = new Databases.Model({id: 'bla'});
+ database.buildChanges({descending: 'true', limit: '100', include_docs: 'true'} );
+ filteredView = new Views.Views.Changes({
+ model: database
+ });
+ });
+
+ it('filter false in case of deleted documents in the changes feed', function () {
+ filteredView.filters = [false];
+ var res = filteredView.createFilteredData([
+ {id: 'LALA', bar: 'ENTE'},
+ {id: '1', bar: '1', deleted: true},
+ {id: '2', bar: '2'}
+ ]);
+
+ assert.equal(res.length, 2);
+ });
+ });
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1275ec6d/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views.js b/app/addons/documents/views.js
index 5095d0a..d769150 100644
--- a/app/addons/documents/views.js
+++ b/app/addons/documents/views.js
@@ -1967,12 +1967,37 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
serialize: function () {
var json = this.model.changes.toJSON(),
filteredData = this.createFilteredData(json);
+
return {
changes: filteredData,
database: this.model
};
},
+ createFilteredData: function (json) {
+ var that = this;
+
+ return _.reduce(this.filters, function (elements, filter) {
+
+ return _.filter(elements, function (element) {
+ var match = false;
+
+ // make deleted searchable
+ if (!element.deleted) {
+ element.deleted = false;
+ }
+ _.each(element, function (value) {
+ if (new RegExp(filter, 'i').test(value.toString())) {
+ match = true;
+ }
+ });
+ return match;
+ });
+
+
+ }, json, this);
+ },
+
afterRender: function(){
prettyPrint();
ZeroClipboard.config({ moviePath: "/assets/js/plugins/zeroclipboard/ZeroClipboard.swf" });