couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deathb...@apache.org
Subject fauxton commit: updated refs/heads/secondary-indexes to 0ff0185
Date Mon, 11 Aug 2014 18:19:44 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/secondary-indexes bf49f5a93 -> 0ff0185c0


Adding the dropdown menu in all_docs


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/0ff0185c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/0ff0185c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/0ff0185c

Branch: refs/heads/secondary-indexes
Commit: 0ff0185c004d768fb15633977b2e2364af86ad4b
Parents: bf49f5a
Author: deathbearbrown <deathbearbrown@gmail.com>
Authored: Mon Aug 11 14:19:49 2014 -0400
Committer: deathbearbrown <deathbearbrown@gmail.com>
Committed: Mon Aug 11 14:19:49 2014 -0400

----------------------------------------------------------------------
 app/addons/documents/routes.js   | 59 +++++++++++++++++++++++++++++------
 app/addons/fauxton/components.js | 20 ++++++++++++
 2 files changed, 69 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ff0185c/app/addons/documents/routes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes.js b/app/addons/documents/routes.js
index 52b8ea9..65b3740 100644
--- a/app/addons/documents/routes.js
+++ b/app/addons/documents/routes.js
@@ -192,19 +192,10 @@ function(app, FauxtonAPI, Components, Documents, Changes, DocEditor,
Databases,
         {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}
       ];
 
-      var dropdown = [{
-        links: [{
-          title: 'Duplicate Index',
-          icon: 'fonticon-documents'
-        },{
-          title: 'Delete',
-          icon: 'fonticon-trash'
-        }]
-      }];
 
       this.leftheader = this.setView("#breadcrumbs", new Components.LeftHeader({
         crumbs: crumbs,
-        dropdownMenu: dropdown
+        dropdownMenu: this.setUpDropdown()
       }));
 
       /* --------------------------------------------------
@@ -224,6 +215,54 @@ function(app, FauxtonAPI, Components, Documents, Changes, DocEditor,
Databases,
       }));
     },
 
+    setUpDropdown: function(){
+      var defaultMenuLinks = [{
+        links: [{
+          title: 'Replicate Database',
+          icon: 'fonticon-replicate',
+          url: '#/replication/'+this.databaseName
+        },{
+          title: 'Delete',
+          icon: 'fonticon-trash',
+          trigger: 'database:delete'
+        }]
+      }];
+
+      defaultMenuLinks.push({
+        title: 'Add new',
+        links: this.getExtensionLinks()
+      });
+
+      return defaultMenuLinks;
+    },
+
+    getExtensionLinks: function () {
+      var database = this.data.database,
+          newurlPrefix = "#" + database.url('app');
+
+      var menuLinks = [{
+          title: 'New Doc',
+          url: newurlPrefix + '/new',
+          icon: 'fonticon-plus-circled'
+        },{
+          title: 'New Design Doc',
+          url: newurlPrefix + '/new_view',
+          icon: 'fonticon-plus-circled'
+      }];
+
+      return _.reduce(FauxtonAPI.getExtensions('sidebar:links'), function (menuLinks, link)
{
+
+        menuLinks.push({
+          title: link.title,
+          url: newurlPrefix + "/" + link.url,
+          icon: 'fonticon-plus-circled'
+        });
+
+        return menuLinks;
+     }, menuLinks);
+
+    },
+
     resetAllDocsHeader: function(){
       if (this.changesHeader){
         this.headerRight = this.setView("#api-navbar", new Documents.Views.RightAllDocsHeader({

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ff0185c/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/components.js b/app/addons/fauxton/components.js
index 9540252..ed8ee57 100644
--- a/app/addons/fauxton/components.js
+++ b/app/addons/fauxton/components.js
@@ -40,6 +40,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
     className: "header-left",
     template: "addons/fauxton/templates/header_left",
     initialize:function(options){
+      this.dropdownEvents = options.dropdownEvents;
       this.dropdownMenuLinks = options.dropdownMenu;
       this.crumbs = options.crumbs || [];
     },
@@ -63,6 +64,7 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
         this.dropdown = this.insertView("#header-dropdown-menu", new Components.MenuDropDown({
           icon: 'fonticon-cog',
           links: this.dropdownMenuLinks,
+          events: this.dropdownEvents
         }));
       }
     }
@@ -743,6 +745,24 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
     initialize: function(options){
       this.links = options.links;
       this.icon = options.icon || "fonticon-plus-circled2";
+      _.bindAll(this);
+      this.setUpEvents();
+    },
+    setUpEvents: function(){
+      this.events = {};
+      var parentLinkObj = this.links;
+      for (var i=0; i< parentLinkObj.length; i++){
+        for (var x=0; x< parentLinkObj[i].links.length; x++){
+          if(parentLinkObj[i].links[x].trigger){
+            this.events['click .'+parentLinkObj[i].links[x].icon] = "triggerEvent";
+          }
+        }
+      }
+    },
+    triggerEvent: function(e){
+      e.preventDefault();
+
+      console.log('works');
     },
     update: function(links){
       this.links = links;


Mime
View raw message