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 E516110F49 for ; Tue, 17 Dec 2013 16:20:20 +0000 (UTC) Received: (qmail 95963 invoked by uid 500); 17 Dec 2013 16:17:59 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 95889 invoked by uid 500); 17 Dec 2013 16:17:52 -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 95101 invoked by uid 99); 17 Dec 2013 16:17:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Dec 2013 16:17:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0DD7C8BA358; Tue, 17 Dec 2013 16:17:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: garren@apache.org To: commits@couchdb.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/api-options to f911479 Date: Tue, 17 Dec 2013 16:17:45 +0000 (UTC) Updated Branches: refs/heads/api-options [created] f91147921 Working menu change Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f9114792 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f9114792 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f9114792 Branch: refs/heads/api-options Commit: f91147921c4f9049ea1d113cd67dcdfab40bc25d Parents: fe888d2 Author: Garren Smith Authored: Tue Dec 17 18:07:41 2013 +0200 Committer: Garren Smith Committed: Tue Dec 17 18:07:41 2013 +0200 ---------------------------------------------------------------------- src/fauxton/app/modules/documents/views.js | 97 +++++++++++++++++++- .../documents/advanced_options_menu.html | 34 +++++++ .../app/templates/documents/view_editor.html | 3 +- 3 files changed, 129 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/f9114792/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 faf3539..4cd23f6 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -969,6 +969,68 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum } }); + Views.AdvancedOptionsMenu = FauxtonAPI.View.extend({ + template: 'templates/documents/advanced_options_menu', + events: { + "click input": "updateRows", + 'change #group-level': 'updateRows', + 'click #query-nav': 'toggleMenu' + }, + + initialize: function (options) { + this.hasReduce = options.hasReduce; + this.eventer = options.eventer; + }, + + toggleMenu: function (event) { + this.$('.checkbox').toggle(); + }, + + updateRows: function (event) { + console.log('boom', event); + var $groupLevel = this.$('#group-level-label'), + params = { + include_docs: false, + reduce: false, + group_level: 0 + }; + + if (this.$('#include-docs').prop('checked')) { + params.include_docs = true; + } + + if (this.hasReduce && this.$('#reduce').prop('checked')) { + params.reduce = true; + params.group_level = this.$('#group-level option:selected').val(); + $groupLevel.show(); + } else { + $groupLevel.hide(); + } + + console.log(params); + this.eventer.trigger('options:param_update', params); + }, + + updateFromParams: function (params) { + if (params.reduce) { + var $reduce = this.$('#reduce'); + $reduce.prop("checked", true); + this.$('#group-level').show(); + + } else if (params.include_docs) { + var $include_docs = this.$('#include-docs'); + $include_docs.prop("checked", true); + } + }, + + serialize: function () { + return { + hasReduce: this.hasReduce + }; + } + + }); + Views.AdvancedOptions = FauxtonAPI.View.extend({ template: "templates/documents/advanced_options", className: "advanced-options well", @@ -979,7 +1041,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.viewName = options.viewName; this.updateViewFn = options.updateViewFn; this.previewFn = options.previewFn; - //this.hadReduce = options.hasReduce || true; + this.eventer = options.eventer; if (typeof(options.hasReduce) === 'undefined') { this.hasReduce = true; @@ -992,6 +1054,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum } else { this.showPreview = options.showPreview; } + + this.listenTo(this.eventer, 'options:param_update', this.optionsParamsUpdate); }, events: { @@ -1011,6 +1075,21 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum } }, + optionsParamsUpdate: function (params) { + var $form = this.$el.find("form.view-query-update"); + + if (params.reduce && params.group_level) { + $form.find("select[name='group_level']").val(params.group_level).removeAttr('disabled'); + delete params.group_level; + } else { + $form.find("select[name='group_level']").attr('disabled'); + } + _.each(params, function(val, key) { + $form.find("input[name='"+key+"']").prop('checked', val); + }); + this.$('form.view-query-update').submit(); + }, + renderOnUpdatehasReduce: function (hasReduce) { this.hasReduce = hasReduce; this.render(); @@ -1082,7 +1161,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum var $ele; switch (key) { case "limit": - case "group_level": + case "group_level": $form.find("select[name='"+key+"']").val(val); break; case "include_docs": @@ -1187,7 +1266,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum "click button.delete": "deleteView", "change select#reduce-function-selector": "updateReduce", "click button.preview": "previewView", - "click #db-views-tabs-nav": 'toggleIndexNav' + "click #db-views-tabs-nav": 'toggleIndexNav', + "click #query-options-wrapper": 'toggleIndexNav' }, langTemplates: { @@ -1538,6 +1618,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum ddocName: this.model.id, database: this.database })); + + this.eventer = _.extend({}, Backbone.Events); this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({ updateViewFn: this.updateView, @@ -1545,13 +1627,20 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum database: this.database, viewName: this.viewName, ddocName: this.model.id, - hasReduce: this.hasReduce() + hasReduce: this.hasReduce(), + eventer: this.eventer + })); + + this.advancedOptionsMenu = this.insertView('#query-options-wrapper', new Views.AdvancedOptionsMenu({ + hasReduce: this.hasReduce(), + eventer: this.eventer })); }, afterRender: function() { if (this.params) { this.advancedOptions.updateFromParams(this.params); + this.advancedOptionsMenu.updateFromParams(this.params); } this.designDocSelector.updateDesignDoc(); http://git-wip-us.apache.org/repos/asf/couchdb/blob/f9114792/src/fauxton/app/templates/documents/advanced_options_menu.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/templates/documents/advanced_options_menu.html b/src/fauxton/app/templates/documents/advanced_options_menu.html new file mode 100644 index 0000000..0bb501d --- /dev/null +++ b/src/fauxton/app/templates/documents/advanced_options_menu.html @@ -0,0 +1,34 @@ +
+
+
+
+ + +
+ <% if (hasReduce) { %> +
+ + + +
+ <% } %> + More query options +
+
+
+ http://git-wip-us.apache.org/repos/asf/couchdb/blob/f9114792/src/fauxton/app/templates/documents/view_editor.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html index cf6aa26..ace70d5 100644 --- a/src/fauxton/app/templates/documents/view_editor.html +++ b/src/fauxton/app/templates/documents/view_editor.html @@ -15,12 +15,13 @@ the License.
+