You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/05/21 15:10:51 UTC
[3/4] couchdb commit: updated refs/heads/Update-Sidebar-Ui to 1cccd0b
Add dropdown menu component
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a4f9085b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a4f9085b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a4f9085b
Branch: refs/heads/Update-Sidebar-Ui
Commit: a4f9085bdb9f7f1a9e96a1e517d297e31e8fbdc5
Parents: 8f042e6
Author: Garren Smith <ga...@gmail.com>
Authored: Tue May 20 16:35:01 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue May 20 16:35:01 2014 +0200
----------------------------------------------------------------------
.../app/addons/documents/sidebarviews.js | 51 +++++++++++---------
.../templates/add_new_ddoc_fn_dropdown.html | 28 -----------
src/fauxton/app/addons/fauxton/components.js | 16 ++++++
.../addons/fauxton/templates/menu_dropdown.html | 33 +++++++++++++
4 files changed, 77 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a4f9085b/src/fauxton/app/addons/documents/sidebarviews.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/sidebarviews.js b/src/fauxton/app/addons/documents/sidebarviews.js
index 9e8ecec..f732fc2 100644
--- a/src/fauxton/app/addons/documents/sidebarviews.js
+++ b/src/fauxton/app/addons/documents/sidebarviews.js
@@ -142,8 +142,9 @@ function(app, FauxtonAPI, Components, Documents, Databases) {
};
},
beforeRender: function(manage) {
- var ddocDocs = this.model.get("doc");
- var ddocName = this.model.id.replace(/^_design\//,"");
+ var ddocDocs = this.model.get("doc"),
+ ddocName = this.model.id.replace(/^_design\//,""),
+ sideBarMenuLinks = [];
var sidebarListTypes = FauxtonAPI.getExtensions('sidebar:list');
if (ddocDocs){
@@ -160,7 +161,31 @@ function(app, FauxtonAPI, Components, Documents, Databases) {
this.buildIndexList(ddocDocs, type);
},this);
}
- this.insertView(".new-button", new Views.NewMenuDropdown({
+
+ var docSafe = app.utils.safeURLName(ddocName),
+ database = this.collection.database,
+ links = _.reduce(FauxtonAPI.getExtensions('sidebar:links'), function (menuLinks, link) {
+
+ menuLinks.push({
+ title: link.title,
+ url: "#" + database.url('app') + "/" + link.url + "/" + docSafe,
+ icon: 'fonticon-circle-plus'
+ });
+
+ return menuLinks;
+ }, [{
+ title: 'Secondary View',
+ url: "#" + database.url('app') + "/new_view/" + docSafe,
+ icon: 'fonticon-circle-plus'
+ }]);
+
+ sideBarMenuLinks.push({
+ title: 'Add new',
+ links: links
+ });
+
+ this.insertView(".new-button", new Components.MenuDropDown({
+ links: sideBarMenuLinks,
database: this.collection.database,
ddocSafeName: app.utils.safeURLName(ddocName),
fullMenu: false
@@ -169,26 +194,6 @@ function(app, FauxtonAPI, Components, Documents, Databases) {
}
});
- Views.NewMenuDropdown = FauxtonAPI.View.extend({
- template: "addons/documents/templates/add_new_ddoc_fn_dropdown",
- tagName: "div",
- className: "dropdown",
- initialize: function(options){
- this.database = options.database;
- this.fullMenu = options.fullMenu;
- this.ddocSafeName = options.ddocSafeName || "";
- },
- serialize: function(){
- var sidebarItem = FauxtonAPI.getExtensions('sidebar:links');
- return {
- extensionLinks: sidebarItem,
- database: this.database,
- ddocSafe: this.ddocSafeName,
- full: this.fullMenu
- };
- }
- });
-
Views.IndexItem = FauxtonAPI.View.extend({
template: "addons/documents/templates/index_menu_item",
tagName: "li",
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a4f9085b/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html b/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html
deleted file mode 100644
index beb5e62..0000000
--- a/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-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.
--->
-
-<div class="dropdown">
- <a class="dropdown-toggle icon fonticon-circle-plus" data-toggle="dropdown" href="#" data-bypass="true"></a>
- <ul class="dropdown-menu arrow" role="menu" aria-labelledby="dLabel">
- <% if (full){ %>
- <li><a class="icon fonticon-replication" href="#replicate/<%=database.id%>">Replicate</a><li>
- <li><a class="icon fonticon-trash" href="#" data-bypass="true">Delete</a><li>
- <%}%>
- <li class="header-label">Add new</li>
- <li><a class="icon fonticon-circle-plus" href="#<%= database.url('app') %>/new_view/<%=ddocSafe%>">Secondary View</a><li>
- <% _.each(extensionLinks, function(link) { %>
- <li><a class="icon fonticon-circle-plus" href="#<%= database.url('app') %>/<%-link.url%>/<%=ddocSafe%>"><%- link.title %></a><li>
- <%});%>
- </ul>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a4f9085b/src/fauxton/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/components.js b/src/fauxton/app/addons/fauxton/components.js
index 52e7e8b..ff9608c 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -529,6 +529,22 @@ function(app, FauxtonAPI, ace, spin) {
});
+ Components.MenuDropDown = FauxtonAPI.View.extend({
+ template: "addons/fauxton/templates/menu_dropdown",
+ className: "dropdown",
+ initialize: function(options){
+ this.links = options.links;
+ },
+ serialize: function(){
+ var sidebarItem = FauxtonAPI.getExtensions('sidebar:links');
+ console.log('linls', this.links);
+ return {
+ links: this.links
+ };
+ }
+ });
+
+
//need to make this into a backbone view...
var routeObjectSpinner;
FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a4f9085b/src/fauxton/app/addons/fauxton/templates/menu_dropdown.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/templates/menu_dropdown.html b/src/fauxton/app/addons/fauxton/templates/menu_dropdown.html
new file mode 100644
index 0000000..f662e60
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/templates/menu_dropdown.html
@@ -0,0 +1,33 @@
+<!--
+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.
+-->
+
+<a class="dropdown-toggle icon fonticon-circle-plus" data-toggle="dropdown" href="#" data-bypass="true"></a>
+<ul class="dropdown-menu arrow" role="menu" aria-labelledby="dLabel">
+ <% _.each(links, function (linkSection) { %>
+ <% if (linkSection.title) { %>
+ <li class="header-label"> <%- linkSection.title %> </li>
+ <% } %>
+ <% _.each(linkSection.links, function (link) { %>
+ <li>
+ <a
+ <% if (link.icon) { %>
+ class="icon <%- link.icon %>"
+ <% } %>
+ href="<%- link.url %>">
+ <%- link.title %>
+ </a>
+ <li>
+ <%});%>
+ <%});%>
+ </ul>