Repository: couchdb Updated Branches: refs/heads/Update-Sidebar-Ui [created] f364947e0
Make Sidebar show all design doc functions Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f364947e Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f364947e Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f364947e Branch: refs/heads/Update-Sidebar-Ui Commit: f364947e0bc8a1a820cee0b1596207057d724601 Parents: bef40dc Author: suelockwood <[email protected]> Authored: Wed Mar 19 14:32:44 2014 -0400 Committer: suelockwood <[email protected]> Committed: Wed Mar 19 16:20:09 2014 -0400 ---------------------------------------------------------------------- src/fauxton/app/addons/documents/routes.js | 2 +- .../documents/templates/attachments_footer.html | 20 +++++ .../documents/templates/design_doc_menu.html | 14 ++++ .../documents/templates/index_menu_item.html | 4 +- .../app/addons/documents/templates/sidebar.html | 30 +++----- src/fauxton/app/addons/documents/views.js | 80 +++++++++++++++++--- 6 files changed, 114 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/f364947e/src/fauxton/app/addons/documents/routes.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js index 699a496..a43cbe5 100644 --- a/src/fauxton/app/addons/documents/routes.js +++ b/src/fauxton/app/addons/documents/routes.js @@ -144,7 +144,7 @@ function(app, FauxtonAPI, Documents, Databases) { selectedHeader: "Databases", routes: { "database/:database/_all_docs(:extra)": "allDocs", - "database/:database/_design/:ddoc/_view/:view": { + "database/:database/_design/:ddoc/_views/:view": { route: "viewFn", roles: ['_admin'] }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/f364947e/src/fauxton/app/addons/documents/templates/attachments_footer.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/attachments_footer.html b/src/fauxton/app/addons/documents/templates/attachments_footer.html new file mode 100644 index 0000000..31bd5a5 --- /dev/null +++ b/src/fauxton/app/addons/documents/templates/attachments_footer.html @@ -0,0 +1,20 @@ +<!-- +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. +--> + +<ul> + <li> attachment 1</li> + <li> attachment 2 </li> + <li> attachment 3</li> + <li> attachment 4</li> +</ul> http://git-wip-us.apache.org/repos/asf/couchdb/blob/f364947e/src/fauxton/app/addons/documents/templates/design_doc_menu.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/design_doc_menu.html b/src/fauxton/app/addons/documents/templates/design_doc_menu.html new file mode 100644 index 0000000..d5ea257 --- /dev/null +++ b/src/fauxton/app/addons/documents/templates/design_doc_menu.html @@ -0,0 +1,14 @@ +<!-- +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. +--> +<li class="nav-header"><%= designDoc%></li> http://git-wip-us.apache.org/repos/asf/couchdb/blob/f364947e/src/fauxton/app/addons/documents/templates/index_menu_item.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/index_menu_item.html b/src/fauxton/app/addons/documents/templates/index_menu_item.html index 7ca9012..b56d975 100644 --- a/src/fauxton/app/addons/documents/templates/index_menu_item.html +++ b/src/fauxton/app/addons/documents/templates/index_menu_item.html @@ -12,6 +12,6 @@ License for the specific language governing permissions and limitations under the License. --> -<a id="<%= ddoc_clean %>_<%= index_clean %>" href="#database/<%= database_encoded %>/_design/<%= ddoc_encoded %>/_view/<%= index_encoded %>" class="toggle-view"> - <%= ddoc %><span class="divider">/</span><%= index %> +<a id="<%= ddoc_clean %>_<%= index_clean %>" href="#database/<%= database_encoded %>/_design/<%= ddoc_encoded %>/_<%=type%>/<%= index_encoded %>" class="toggle-view"><%= type %> + <%= index %> </a> http://git-wip-us.apache.org/repos/asf/couchdb/blob/f364947e/src/fauxton/app/addons/documents/templates/sidebar.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/sidebar.html b/src/fauxton/app/addons/documents/templates/sidebar.html index 750cd30..8da8822 100644 --- a/src/fauxton/app/addons/documents/templates/sidebar.html +++ b/src/fauxton/app/addons/documents/templates/sidebar.html @@ -15,25 +15,10 @@ the License. <div id="sidenav"> <header class="row-fluid"> <div class="span12"> - <div class="btn-group"> - <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown"> - Docs - <span class="caret"></span> - </button> - <ul class="dropdown-menu"> - <!-- dropdown menu links --> - <li><a href="<%= db_url %>"><i class="icon icon-file"></i> Docs</a></li> - <li><a href="<%= permissions_url %>"><i class="icon icon-lock"></i> Permissions</a></li> - <li><a href="<%= changes_url %>"><i class="icon icon-forward"></i> Changes</a></li> - <% _.each(docLinks, function (link) { %> - <li><a href="<%= database_url + '/' + link.url %>"><i class="icon <%= link.icon %>"></i> <%= link.title %></a></li> - <% }); %> - </ul> - </div> <div class="btn-group"> <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown"> - New + Create New <span class="caret"></span> </button> <ul class="dropdown-menu"> @@ -55,14 +40,17 @@ the License. <nav> <ul class="nav nav-list"> + + <li><a id="changes" href="<%= permissions_url %>">Permissions</a><li> + <li><a id="changes" href="<%= changes_url %>">Changes</a><li> + <% _.each(docLinks, function (link) { %> + <li><a href="<%= database_url + '/' + link.url %>"><%= link.title %></a></li> + <% }); %> + <li class="active"><a id="all-docs" href="#<%= database.url('index') %>" class="toggle-view"> All documents</a></li> <li><a id="design-docs" href='#<%= database.url("index") %>?startkey="_design"&endkey="_e"' class="toggle-view"> All design docs</a></li> </ul> - <ul class="nav nav-list views"> - <li class="nav-header">Secondary Indexes</li> - <li><a id="new-view" href="#<%= database.url('app') %>/new_view" class="new"><i class="icon-plus"></i> New</a></li> - </ul> - <div id="extension-navs"></div> + </nav> <div id="delete-db-modal"> </div> </div> http://git-wip-us.apache.org/repos/asf/couchdb/blob/f364947e/src/fauxton/app/addons/documents/views.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js index f29ebaa..327b9c2 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -385,10 +385,12 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.ddoc = options.ddoc; this.database = options.database; this.selected = !! options.selected; + this.selector = options.selector; }, serialize: function() { return { + type: this.selector, index: this.index, ddoc: this.ddoc, database: this.database, @@ -1819,21 +1821,22 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum new Views.DeleteDBModal({database: this.database}) ); - var sidebarListViews = FauxtonAPI.getExtensions('sidebar:list'); - _.each(sidebarListViews, function (view) { - var extension = this.insertView('#extension-navs', view); - extension.update(this.database, this.collection, this.viewName); - extension.render(); - }, this); - this.collection.each(function(design) { if (design.has('doc')){ - var ddoc = design.id.replace(/^_design\//,""); - if (design.get('doc').views){ - this.buildIndexList(design.get('doc').views, "views", ddoc); - } + this.insertView("nav", new Views.DdocSidenav({ + model: design + })); } - }, this); + },this); + + // this.collection.each(function(design) { + // if (design.has('doc')){ + // this.insertView(new Views.DdocSidenav({ + // collection: design, + // database: this.collection.database.id + // })); + // } + // }, this); }, @@ -1850,6 +1853,59 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum } }); + + Views.DdocSidenav = FauxtonAPI.View.extend({ + tagName: "ul", + template: "addons/documents/templates/design_doc_menu", + initialize: function(){ + + }, + + buildIndexList: function(collection, selector){ + var design = this.model.id.replace(/^_design\//,""); + _.each(_.keys(collection[selector]), function(key){ + this.insertView(new Views.IndexItem({ + selector: selector, + ddoc: design, + index: key, + database: this.model.collection.database.id + })); + }, this); + }, + extensions: function(){ + //extensions + var sidebarListViews = FauxtonAPI.getExtensions('sidebar:list'); + _.each(sidebarListViews, function (view) { + var extension = this.insertView('#extension-navs', view); + extension.update(this.database, this.collection, this.viewName); + extension.render(); + }, this); + }, + serialize: function(){ + return{ + designDoc: this.model.id.replace(/^_design\//,"") + }; + }, + beforeRender: function(manage) { + + console.log("this model", this.model.get("doc")); + var ddocDocs = this.model.get("doc"); + + if (ddocDocs){ + + //Views + this.buildIndexList(ddocDocs, "views"); + //lists + this.buildIndexList(ddocDocs, "lists"); + //show + this.buildIndexList(ddocDocs, "show"); + //filters + this.buildIndexList(ddocDocs, "filters"); + //extensions + } + } + }); + Views.Indexed = FauxtonAPI.View.extend({}); Views.Changes = FauxtonAPI.View.extend({
