Repository: couchdb-fauxton Updated Branches: refs/heads/master 17ccbe019 -> 6236556ea
Fix for compaction lookahead tray not redirecting This is a fix for the lookahead tray not redirecting properly on the Compaction page. It has to do a lot of cleanup before the redirect to ensure the new DOM is all correct. Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/6236556e Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/6236556e Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/6236556e Branch: refs/heads/master Commit: 6236556ea36d13eef5274f89803163759afaabff Parents: 17ccbe0 Author: Ben Keen <[email protected]> Authored: Wed Jan 21 18:44:13 2015 -0800 Committer: Ben Keen <[email protected]> Committed: Mon Jan 26 09:20:50 2015 -0800 ---------------------------------------------------------------------- app/addons/compaction/routes.js | 38 +++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/6236556e/app/addons/compaction/routes.js ---------------------------------------------------------------------- diff --git a/app/addons/compaction/routes.js b/app/addons/compaction/routes.js index 83740b0..2b7414c 100644 --- a/app/addons/compaction/routes.js +++ b/app/addons/compaction/routes.js @@ -28,8 +28,12 @@ function(app, FauxtonAPI, Compaction, Databases, BaseRoute) { }, initialize: function (route, masterLayout, options) { - var databaseName = options[0]; - this.database = this.database || new Databases.Model({ id: databaseName }); + this.initViews(options[0]); + this.listenToLookaheadTray(); + }, + + initViews: function (databaseName) { + this.database = new Databases.Model({ id: databaseName }); this.allDatabases = new Databases.List(); this.createDesignDocsCollection(); @@ -37,8 +41,21 @@ function(app, FauxtonAPI, Compaction, Databases, BaseRoute) { this.addSidebar('docLink_compact'); }, + onSelectDatabase: function (dbName) { + this.cleanup(); + this.initViews(dbName); + FauxtonAPI.navigate('/database/' + app.utils.safeURLName(dbName) + '/compact', { + trigger: true + }); + this.listenToLookaheadTray(); + }, + + listenToLookaheadTray: function () { + this.listenTo(FauxtonAPI.Events, 'lookaheadTray:update', this.onSelectDatabase); + }, + compaction: function () { - this.setView('#dashboard-content', new Compaction.Layout({model: this.database})); + this.pageContent = this.setView('#dashboard-content', new Compaction.Layout({model: this.database})); }, establish: function () { @@ -46,6 +63,21 @@ function(app, FauxtonAPI, Compaction, Databases, BaseRoute) { this.designDocs.fetch({reset: true}), this.allDatabases.fetchOnce() ]; + }, + + cleanup: function () { + if (this.pageContent) { + this.removeView('#dashboard-upper-content'); + } + if (this.leftheader) { + this.removeView('#breadcrumbs'); + } + if (this.sidebar) { + this.removeView('#sidebar'); + } + + // we're no longer interested in listening to the lookahead tray event on this route object + this.stopListening(FauxtonAPI.Events, 'lookaheadTray:update', this.onSelectDatabase); } });
