diff options
author | Garren Smith <garren.smith@gmail.com> | 2013-04-24 15:57:15 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2013-05-15 10:26:27 +0200 |
commit | 4a849dc02a7ab5cf1380e53212542f3ff42eb440 (patch) | |
tree | 8316c356542c03168498d31238ad75c467330b31 /src/fauxton/app/addons/logs | |
parent | 61419957cfb00dbf83f49458ed611bc75d2611fb (diff) | |
download | couchdb-4a849dc02a7ab5cf1380e53212542f3ff42eb440.tar.gz |
Get Route Event api working with modules and addons
Diffstat (limited to 'src/fauxton/app/addons/logs')
-rw-r--r-- | src/fauxton/app/addons/logs/resources.js | 5 | ||||
-rw-r--r-- | src/fauxton/app/addons/logs/routes.js | 57 |
2 files changed, 39 insertions, 23 deletions
diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js index d1e6d2079..91a9bcbb2 100644 --- a/src/fauxton/app/addons/logs/resources.js +++ b/src/fauxton/app/addons/logs/resources.js @@ -98,11 +98,16 @@ function (app, FauxtonAPI, Backbone) { this.filters = []; this.filteredCollection = new Log.Collection(this.collection.toJSON()); + this.collection.on("add", function () { this.createFilteredCollection(); }, this); }, + establish: function () { + return [this.collection.fetch()]; + }, + serialize: function () { return { logs: this.filteredCollection}; }, diff --git a/src/fauxton/app/addons/logs/routes.js b/src/fauxton/app/addons/logs/routes.js index 4e04d0843..9bd8f6589 100644 --- a/src/fauxton/app/addons/logs/routes.js +++ b/src/fauxton/app/addons/logs/routes.js @@ -11,37 +11,48 @@ // the License. define([ - "app", + "app", - "api", + "api", - // Modules - "addons/logs/resources" + // Modules + "addons/logs/resources" ], function(app, FauxtonAPI, Log) { - Log.Routes = { - "_log": function() { - var logs = new Log.Collection(); - - return { - layout: "with_sidebar", - crumbs: [ - {"name": "Logs", "link": "_log"} - ], - views: { - "#dashboard-content": new Log.Views.View({collection: logs}), - "#sidebar-content": new Log.Views.FilterView({}) - }, - apiUrl: logs.url(), - establish: function() { - return [logs.fetch()]; - } - }; + var LogRouteObject = FauxtonAPI.RouteObject.extend({ + layout: "with_sidebar", + + crumbs: [ + {"name": "Logs", "link": "_log"} + ], + + routes: ["_log"], + + defaultRoute: "showLog", + + apiUrl: function() { + return this.logs.url(); + }, + + initialize: function () { + this.logs = new Log.Collection(); + this.setView("#sidebar-content", new Log.Views.FilterView({})); + }, + + showLog: function (event) { + this.setView("#dashboard-content", new Log.Views.View({collection: this.logs})); + }, + + e1stablish: function() { + return [this.logs.fetch()]; } - }; + }); + + Log.RouteObjects = [LogRouteObject]; return Log; }); + |