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 @@
<button class="btn btn-high btn-xos-contentButtonPanel" onclick="$('button.btn-xos-save-another').click()">Save and add another</button>
</div>
<div class="box save-box" id="xos-listview-button-box">
-<button class="btn btn-high btn-success btn-xos-contentButtonPanel" onclick="">Add</button>
+<button class="btn btn-high btn-success btn-xos-contentButtonPanel" onclick="$('button.btn-xos-add').click()">Add</button>
</div>
</div> <!-- end contentButtonPanel -->
<div id="contentInner">
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 @@
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 @@
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 @@
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 @@
}
},
+ 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 @@
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 @@
</tr>
</script>
+<script type="text/template" id="xos-inline-list-buttons-template">
+ <button class="btn js-submit btn-xos-list btn-xos-add">Add</button>
+ </td>
+ </tr>
+</script>
+
<!-- Deployment -->
<script type="text/template" id="xosAdmin-deployment-list-template">
<h3 class="xos-list-title"><%= title %></h3>
+ <%= xosInlineListButtonsTemplate() %>
<table class="test-table">
<thead><tr>
<th>id</th>
@@ -690,4 +697,5 @@
<script>
xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
+xosInlineListButtonsTemplate = _.template($("#xos-inline-list-buttons-template").html());
</script>