From commits-return-9940-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Mon Feb 11 11:12:25 2013 Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D9807E8B8 for ; Mon, 11 Feb 2013 11:12:25 +0000 (UTC) Received: (qmail 52213 invoked by uid 500); 11 Feb 2013 11:12:24 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 52091 invoked by uid 500); 11 Feb 2013 11:12:24 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 48387 invoked by uid 99); 11 Feb 2013 11:12:15 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 11:12:15 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CE8203C748; Mon, 11 Feb 2013 11:12:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [30/50] [abbrv] git commit: Initial view filter constraints Message-Id: <20130211111214.CE8203C748@tyr.zones.apache.org> Date: Mon, 11 Feb 2013 11:12:14 +0000 (UTC) Initial view filter constraints Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f25958be Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f25958be Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f25958be Branch: refs/heads/fauxton Commit: f25958be0589248a6656810ebee188314ff6ede2 Parents: 73e69b3 Author: Russell Branca Authored: Tue Jan 29 12:19:56 2013 -0800 Committer: Russell Branca Committed: Tue Jan 29 12:19:56 2013 -0800 ---------------------------------------------------------------------- src/fauxton/app/modules/documents/views.js | 39 ++++++++++++++- .../app/templates/documents/all_docs_list.html | 6 +- 2 files changed, 40 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/f25958be/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 f6ce4e9..c4107c4 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -216,6 +216,8 @@ function(app, FauxtonAPI, Codemirror, JSHint) { events: { "click button.all": "selectAll", "click button.bulk-delete": "bulkDelete", + "change form.view-query-update input": "updateFilters", + "change form.view-query-update select": "updateFilters", "submit form.view-query-update": "updateView" }, @@ -288,6 +290,34 @@ function(app, FauxtonAPI, Codemirror, JSHint) { FauxtonAPI.navigate(fragment); }, + updateFilters: function(event) { + event.preventDefault(); + var $ele = $(event.currentTarget); + var name = $ele.attr('name'); + this.updateFiltersFor(name, $ele); + }, + + updateFiltersFor: function(name, $ele) { + var $form = $ele.parents("form.view-query-update:first"); + switch (name) { + // Reduce constraints + // - Can't include_docs for reduce=true + // - can't include group_level for reduce=false + case "reduce": + if ($ele.prop('checked') === true) { + $form.find("input[name=include_docs]").prop("checked", false); + $form.find("input[name=include_docs]").prop("disabled", true); + $form.find("select[name=group_level]").prop("disabled", false); + } else { + $form.find("select[name=group_level]").prop("disabled", true); + $form.find("input[name=include_docs]").prop("disabled", false); + } + break; + case "include_docs": + break; + } + }, + /* * TODO: this should be reconsidered * This currently performs delete operations on the model level, @@ -335,22 +365,27 @@ function(app, FauxtonAPI, Codemirror, JSHint) { if (this.params) { var $form = this.$el.find("form.view-query-update"); _.each(this.params, function(val, key) { + var $ele; switch (key) { case "limit": case "group_level": $form.find("select[name='"+key+"']").val(val); break; case "include_docs": + $form.find("input[name='"+key+"']").prop('checked', true); + break; case "reduce": + $ele = $form.find("input[name='"+key+"']"); if (val == "true") { - $form.find("input[name='"+key+"']").prop('checked', true); + $ele.prop('checked', true); } + this.updateFiltersFor(key, $ele); break; default: $form.find("input[name='"+key+"']").val(val); break; } - }); + }, this); } } }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/f25958be/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 e987dff..a3536e0 100644 --- a/src/fauxton/app/templates/documents/all_docs_list.html +++ b/src/fauxton/app/templates/documents/all_docs_list.html @@ -33,15 +33,15 @@ <% if (hasReduce) { %>