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 8657B1069E for ; Tue, 22 Oct 2013 15:24:45 +0000 (UTC) Received: (qmail 32351 invoked by uid 500); 22 Oct 2013 15:24:24 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 32251 invoked by uid 500); 22 Oct 2013 15:24:22 -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 31719 invoked by uid 99); 22 Oct 2013 15:24:12 -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, 22 Oct 2013 15:24:12 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 45E4F50A44; Tue, 22 Oct 2013 15:24:12 +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 Date: Tue, 22 Oct 2013 15:24:19 -0000 Message-Id: In-Reply-To: <2337c76df97a4764baf0b0ea5f0b46e7@git.apache.org> References: <2337c76df97a4764baf0b0ea5f0b46e7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/15] git commit: updated refs/heads/1809-compact-and-clean to 489a6c2 Fauxton: Fix issue cannot delete new view Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e1f5d8db Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e1f5d8db Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e1f5d8db Branch: refs/heads/1809-compact-and-clean Commit: e1f5d8dbce37460419f406bf87284dbd7712f82b Parents: 309a569 Author: Garren Smith Authored: Mon Oct 21 16:09:09 2013 +0200 Committer: Garren Smith Committed: Mon Oct 21 16:09:09 2013 +0200 ---------------------------------------------------------------------- src/fauxton/app/modules/documents/resources.js | 1 - src/fauxton/app/modules/documents/views.js | 98 +++++++++++++------- .../documents/design_doc_selector.html | 35 +++++++ .../app/templates/documents/view_editor.html | 22 ----- 4 files changed, 100 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/e1f5d8db/src/fauxton/app/modules/documents/resources.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js index 8df2e6f..5512add 100644 --- a/src/fauxton/app/modules/documents/resources.js +++ b/src/fauxton/app/modules/documents/resources.js @@ -167,7 +167,6 @@ function(app, FauxtonAPI) { if (resp.ok) { delete resp.ok; } - return resp; }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/e1f5d8db/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 8cd1384..5122921 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -1099,7 +1099,60 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re } }); - //TODO split this into two smaller views, one for advance query options and other for index editing + Views.DesignDocSelector = FauxtonAPI.View.extend({ + template: "templates/documents/design_doc_selector", + + events: { + "change select#ddoc": "updateDesignDoc" + }, + + initialize: function (options) { + this.ddocName = options.ddocName; + this.database = options.database; + this.listenTo(this.collection, 'add', this.ddocAdded); + }, + + ddocAdded: function (ddoc) { + this.ddocName = ddoc.id; + this.render(); + }, + + serialize: function () { + return { + ddocName: this.ddocName, + ddocs: this.collection + }; + }, + + updateDesignDoc: function () { + if (this.$('#ddoc :selected').prop('id') === 'new-doc') { + this.$('#new-ddoc-section').show(); + } else { + this.$('#new-ddoc-section').hide(); + } + }, + + newDesignDoc: function () { + return this.$('#ddoc :selected').prop('id') === 'new-doc'; + }, + + getCurrentDesignDoc: function () { + if (this.newDesignDoc()) { + var doc = { + _id: '_design/' + this.$('#new-ddoc').val(), + views: {}, + language: "javascript" + }; + return new Documents.Doc(doc, {database: this.database}); + } else { + var ddocName = this.$('#ddoc').val(); + return this.collection.find(function (ddoc) { + return ddoc.id === ddocName; + }).dDocModel(); + } + } + }); + Views.ViewEditor = FauxtonAPI.View.extend({ template: "templates/documents/view_editor", builtinReduces: ['_sum', '_count', '_stats'], @@ -1108,7 +1161,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re "click button.save": "saveView", "click button.delete": "deleteView", "change select#reduce-function-selector": "updateReduce", - "change select#ddoc": "updateDesignDoc", + "click #db-views-tabs-nav": 'toggleIndexNav' }, @@ -1143,17 +1196,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re } }, - updateDesignDoc: function () { - - if (this.$('#ddoc :selected').prop('id') === 'new-doc') { - this.$('#new-ddoc-section').show(); - - } else { - this.$('#new-ddoc-section').hide(); - } - - }, - + updateValues: function() { var notification; if (this.model.changedAttributes()) { @@ -1335,26 +1378,9 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re }, getCurrentDesignDoc: function () { - if (this.newDesignDoc()) { - var doc = { - _id: '_design/' + this.$('#new-ddoc').val(), - views: {}, - language: "javascript" - }; - return new Documents.Doc(doc, {database: this.database}); - } else { - var ddocName = this.$('#ddoc').val(); - return this.ddocs.find(function (ddoc) { - return ddoc.id === ddocName; - }).dDocModel(); - } - + return this.designDocSelector.getCurrentDesignDoc(); }, - - newDesignDoc: function () { - return this.$('#ddoc :selected').prop('id') === 'new-doc'; - }, - + isCustomReduceEnabled: function() { return $("#reduce-function-selector").val() == "CUSTOM"; }, @@ -1461,6 +1487,12 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo })); } + this.designDocSelector = this.setView('.design-doc-group', new Views.DesignDocSelector({ + collection: this.ddocs, + ddocName: this.model.id, + database: this.database + })); + this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({ updateViewFn: this.updateView, previewFn: this.previewView @@ -1480,7 +1512,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re this.$('#index-nav').parent().removeClass('active'); } - this.updateDesignDoc(); + this.designDocSelector.updateDesignDoc(); // This is a hack around a bug in backbone.layoutmanager with grunt dev // When in grunt dev mode we load templates asynchronously // and this can cause a double render which then gives us two http://git-wip-us.apache.org/repos/asf/couchdb/blob/e1f5d8db/src/fauxton/app/templates/documents/design_doc_selector.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/templates/documents/design_doc_selector.html b/src/fauxton/app/templates/documents/design_doc_selector.html new file mode 100644 index 0000000..0cd6bdf --- /dev/null +++ b/src/fauxton/app/templates/documents/design_doc_selector.html @@ -0,0 +1,35 @@ + +
+ + +
+ + http://git-wip-us.apache.org/repos/asf/couchdb/blob/e1f5d8db/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 f75edc5..76265e0 100644 --- a/src/fauxton/app/templates/documents/view_editor.html +++ b/src/fauxton/app/templates/documents/view_editor.html @@ -25,28 +25,6 @@ the License.
-
- - -
- -