Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master b0f30178d -> aae7b7c72


Added sidebar to permissions page

N.B. I stumbled across an old bug while working on this ticket
where the page content wouldn't scroll. That's why there were a
few markup/CSS changes in this ticket as well.

Closes COUCHDB-2546


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

Branch: refs/heads/master
Commit: d8d5df740d058505fa1ca598d156d041ab850315
Parents: b0f3017
Author: Benjamin Keen <[email protected]>
Authored: Fri Jan 16 13:58:38 2015 -0800
Committer: Ben Keen <[email protected]>
Committed: Wed Jan 21 18:31:53 2015 -0800

----------------------------------------------------------------------
 .../permissions/assets/less/permissions.less    |  4 ++
 app/addons/permissions/routes.js                | 72 +++++++++++++++-----
 .../permissions/templates/permissions.html      |  8 ++-
 app/addons/permissions/templates/section.html   |  4 +-
 4 files changed, 66 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d8d5df74/app/addons/permissions/assets/less/permissions.less
----------------------------------------------------------------------
diff --git a/app/addons/permissions/assets/less/permissions.less 
b/app/addons/permissions/assets/less/permissions.less
index 83f270c..3c52906 100644
--- a/app/addons/permissions/assets/less/permissions.less
+++ b/app/addons/permissions/assets/less/permissions.less
@@ -25,3 +25,7 @@
     }
   }
 }
+
+#dashboard-content div.permissions-page {
+  padding: 10px 20px;
+}

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d8d5df74/app/addons/permissions/routes.js
----------------------------------------------------------------------
diff --git a/app/addons/permissions/routes.js b/app/addons/permissions/routes.js
index 0e9fa52..fc4bc83 100644
--- a/app/addons/permissions/routes.js
+++ b/app/addons/permissions/routes.js
@@ -11,17 +11,15 @@
 // the License.
 
 define([
-       "app",
-       "api",
-       "addons/databases/base",
-       "addons/permissions/views"
+  'app',
+  'api',
+  'addons/databases/base',
+  'addons/permissions/views',
+  'addons/documents/shared-routes'
 ],
-function (app, FauxtonAPI, Databases, Permissions) {
-  
-  var PermissionsRouteObject = FauxtonAPI.RouteObject.extend({
-    layout: 'one_pane',
-    selectedHeader: 'Databases',
+function (app, FauxtonAPI, Databases, Permissions, BaseRoute) {
 
+  var PermissionsRouteObject = BaseRoute.extend({
     routes: {
       'database/:database/permissions': 'permissions'
     },
@@ -30,34 +28,74 @@ function (app, FauxtonAPI, Databases, Permissions) {
       var docOptions = app.getParams();
       docOptions.include_docs = true;
 
-      this.databaseName = options[0];
-      this.database = new Databases.Model({id:this.databaseName});
+      this.initViews(options[0]);
+      this.listenToLookaheadTray();
+    },
+
+    initViews: function (databaseName) {
+      this.database = new Databases.Model({ id: databaseName });
       this.security = new Permissions.Security(null, {
         database: this.database
       });
+      this.allDatabases = new Databases.List();
+
+      this.createDesignDocsCollection();
+      this.addLeftHeader();
+      this.addSidebar('permissions');
     },
 
     establish: function () {
-      return [this.database.fetch(), this.security.fetch()];
+      return [
+        this.database.fetch(),
+        this.security.fetch(),
+        this.designDocs.fetch({reset: true}),
+        this.allDatabases.fetchOnce()
+      ];
+    },
+
+    listenToLookaheadTray: function () {
+      this.listenTo(FauxtonAPI.Events, 'lookaheadTray:update', 
this.onSelectDatabase);
+    },
+
+    onSelectDatabase: function (dbName) {
+      this.cleanup();
+      this.initViews(dbName);
+
+      FauxtonAPI.navigate('/database/' + app.utils.safeURLName(dbName) + 
'/permissions', {
+        trigger: true
+      });
+      this.listenToLookaheadTray();
     },
 
     permissions: function () {
-      this.setView('#dashboard-content', new Permissions.Permissions({
+      this.pageContent = this.setView('#dashboard-content', new 
Permissions.Permissions({
         database: this.database,
         model: this.security
       }));
-
     },
 
     crumbs: function () {
       return [
-        {"name": this.database.id, "link": 
Databases.databaseUrl(this.database)},
-        {"name": "Permissions", "link": "/permissions"}
+        { name: this.database.id, link: Databases.databaseUrl(this.database)},
+        { name: 'Permissions', link: '/permissions' }
       ];
     },
 
+    cleanup: function () {
+      if (this.pageContent) {
+        this.removeView('#dashboard-content');
+      }
+      if (this.leftheader) {
+        this.removeView('#breadcrumbs');
+      }
+      if (this.sidebar) {
+        this.removeView('#sidebar');
+      }
+      this.stopListening(FauxtonAPI.Events, 'lookaheadTray:update', 
this.onSelectDatabase);
+    }
   });
-  
+
   Permissions.RouteObjects = [PermissionsRouteObject];
+
   return Permissions;
 });

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d8d5df74/app/addons/permissions/templates/permissions.html
----------------------------------------------------------------------
diff --git a/app/addons/permissions/templates/permissions.html 
b/app/addons/permissions/templates/permissions.html
index 99c9ff5..c3c9ab7 100644
--- a/app/addons/permissions/templates/permissions.html
+++ b/app/addons/permissions/templates/permissions.html
@@ -1,4 +1,4 @@
-<!--
+<% /*
 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
@@ -10,6 +10,8 @@ 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 id="sections"> </div>
+<div class="scrollable permissions-page">
+  <div id="sections"> </div>
+</div>

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d8d5df74/app/addons/permissions/templates/section.html
----------------------------------------------------------------------
diff --git a/app/addons/permissions/templates/section.html 
b/app/addons/permissions/templates/section.html
index ff3a435..83c5398 100644
--- a/app/addons/permissions/templates/section.html
+++ b/app/addons/permissions/templates/section.html
@@ -1,4 +1,4 @@
-<!--
+<% /*
 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
@@ -10,7 +10,7 @@ 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.
--->
+*/ %>
 <header class="page-header">
 <h3> <%- section %> </h3>
 <p class="help"> <%- help %> <a class="help-link" data-bypass="true" 
href="<%-getDocUrl('DB_PERMISSION')%>" target="_blank"><i 
class="icon-question-sign"> </i> </a></p>

Reply via email to