From: Scott Baker Date: Sat, 8 Nov 2014 00:40:30 +0000 (-0800) Subject: add button plumbed through to router X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=cd87052b764d6a0df177c68b439707b33837bd61;p=plstackapi.git add button plumbed through to router --- diff --git a/planetstack/core/xoslib/dashboards/xosAdminDashboard.html b/planetstack/core/xoslib/dashboards/xosAdminDashboard.html index f70f188..8b64877 100644 --- a/planetstack/core/xoslib/dashboards/xosAdminDashboard.html +++ b/planetstack/core/xoslib/dashboards/xosAdminDashboard.html @@ -26,7 +26,7 @@
- +
diff --git a/planetstack/core/xoslib/static/css/xosAdminDashboard.css b/planetstack/core/xoslib/static/css/xosAdminDashboard.css index b2d4740..ff54fee 100644 --- a/planetstack/core/xoslib/static/css/xosAdminDashboard.css +++ b/planetstack/core/xoslib/static/css/xosAdminDashboard.css @@ -6,6 +6,10 @@ display: none; } +.btn-xos-list { + display: none; +} + #logPanel { display: none; } diff --git a/planetstack/core/xoslib/static/js/xosAdminSite.js b/planetstack/core/xoslib/static/js/xosAdminSite.js index 6fb46a0..99cf851 100644 --- a/planetstack/core/xoslib/static/js/xosAdminSite.js +++ b/planetstack/core/xoslib/static/js/xosAdminSite.js @@ -95,7 +95,7 @@ XOSAdminApp.initRouter = function() { name = OBJS[index]; collection_name = name + "s"; nav_url = collection_name; - api_command = "list" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1); + api_command = "list" + firstCharUpper(collection_name); listViewName = collection_name + "ListView"; detailViewName = collection_name + "DetailView"; @@ -103,10 +103,15 @@ XOSAdminApp.initRouter = function() { routes[nav_url] = api_command; nav_url = collection_name + "/:id"; - api_command = "detail" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1); + api_command = "detail" + firstCharUpper(collection_name); api[api_command] = XOSAdminApp.detailShower(detailViewName, collection_name, "detail", name); routes[nav_url] = api_command; + + nav_url = "add" + firstCharUpper(name); + api_command = "add" + firstCharUpper(name); + api[api_command] = XOSAdminApp.addShower(detailViewName, collection_name, "detail", name); + routes[nav_url] = api_command; }; XOSAdminApp.Router = new router({ appRoutes: routes, controller: api }); diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js index 4a408e1..11d97d6 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js +++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js @@ -8,6 +8,10 @@ function templateFromId(id) { return _.template($(id).html()); } +function firstCharUpper(s) { + return s.charAt(0).toUpperCase() + s.slice(1); +} + HTMLView = Marionette.ItemView.extend({ render: function() { this.$el.append(this.options.html); @@ -119,6 +123,15 @@ XOSApplication = Marionette.Application.extend({ } }, + addShower: function(detailName, collection_name, regionName, title) { + var app=this; + return function() { + detailViewClass = app[detailName]; + detailView = new detailViewClass(); + app[regionName].show(detailView); + } + }, + detailShower: function(detailName, collection_name, regionName, title) { var app=this; showModelId = function(model_id) { @@ -322,6 +335,15 @@ XOSItemView = Marionette.ItemView.extend({ XOSListView = Marionette.CompositeView.extend({ childViewContainer: 'tbody', + events: {"click button.btn-xos-add": "addClicked", + }, + + addClicked: function(e) { + console.log("add"); + e.preventDefault(); + this.app.Router.navigate("add" + firstCharUpper(this.collection.modelName)); + }, + initialize: function() { this.listenTo(this.collection, 'change', this._renderChildren) diff --git a/planetstack/core/xoslib/templates/xosAdmin.html b/planetstack/core/xoslib/templates/xosAdmin.html index 94fb0f8..7eb43d1 100644 --- a/planetstack/core/xoslib/templates/xosAdmin.html +++ b/planetstack/core/xoslib/templates/xosAdmin.html @@ -69,10 +69,17 @@ + +