templateize detail inline button panel, add save/continue and save/another buttons, add insert button
diff --git a/planetstack/core/xoslib/dashboards/xosAdminDashboard.html b/planetstack/core/xoslib/dashboards/xosAdminDashboard.html
index b3dca1a..f70f188 100644
--- a/planetstack/core/xoslib/dashboards/xosAdminDashboard.html
+++ b/planetstack/core/xoslib/dashboards/xosAdminDashboard.html
@@ -20,8 +20,15 @@
handler for this Save button tells the save button inside the detail
form to click itself.
-->
-<button class="btn js-submit btn-xos-contentButtonPanel" onclick="$('button.js-submit.btn-xos-detail').click()">Save</button>
+<div class="box save-box" id="xos-detail-button-box">
+<button class="btn btn-high btn-info btn-xos-contentButtonPanel" onclick="$('button.btn-xos-save-leave').click()">Save</button>
+<button class="btn btn-high btn-xos-contentButtonPanel" onclick="$('button.btn-xos-save-continue').click()">Save and continue editing</button>
+<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>
+</div>
+</div> <!-- end contentButtonPanel -->
<div id="contentInner">
<div id="tabs">
</div>
@@ -30,8 +37,8 @@
<div id="linkedObjs2"></div>
<div id="linkedObjs3"></div>
<div id="linkedObjs4"></div>
-</div>
-</div>
+</div> <!-- end contentInner -->
+</div> <!-- end contentPanel -->
<div id="logPanel">
<table id="logTable">
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index 1dc3bf5..4a408e1 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -113,7 +113,9 @@
app.hideLinkedItems();
$("#contentTitle").html(templateFromId("#xos-title-list")({"title": title}));
$("#detail").show();
+ $("#xos-listview-button-box").show();
$("#tabs").hide();
+ $("#xos-detail-button-box").hide();
}
},
@@ -125,6 +127,8 @@
detailView = new detailViewClass({model: model});
app[regionName].show(detailView);
detailView.showLinkedItems();
+ $("#xos-detail-button-box").show();
+ $("#xos-listview-button-box").hide();
}
$("#contentTitle").html(templateFromId("#xos-title-detail")({"title": title}));
@@ -167,7 +171,9 @@
XOSDetailView = Marionette.ItemView.extend({
tagName: "div",
- events: {"click button.js-submit": "submitClicked",
+ events: {"click button.btn-xos-save-continue": "submitContinueClicked",
+ "click button.btn-xos-save-leave": "submitLeaveClicked",
+ "click button.btn-xos-save-another": "submitAddAnotherClicked",
"change input": "inputChanged"},
/* inputChanged is watching the onChange events of the input controls. We
@@ -192,10 +198,26 @@
this.app.showSuccess(result);
},
- submitClicked: function(e) {
- console.log("submit clicked");
- this.app.hideError();
- e.preventDefault();
+ submitContinueClicked: function(e) {
+ console.log("saveContinue");
+ e.preventDefault();
+ this.save();
+ },
+
+ submitLeaveClicked: function(e) {
+ console.log("saveLeave");
+ e.preventDefault();
+ this.save();
+ },
+
+ submitAddAnotherClicked: function(e) {
+ console.log("saveAnother");
+ e.preventDefault();
+ this.save();
+ },
+
+ save: function() {
+ this.app.hideError();
var infoMsgId = this.app.showInformational( {what: "save " + this.model.__proto__.modelName, status: "", statusText: "in progress..."} );
var data = Backbone.Syphon.serialize(this);
var that = this;
diff --git a/planetstack/core/xoslib/templates/xosAdmin.html b/planetstack/core/xoslib/templates/xosAdmin.html
index 8e79904..94fb0f8 100644
--- a/planetstack/core/xoslib/templates/xosAdmin.html
+++ b/planetstack/core/xoslib/templates/xosAdmin.html
@@ -51,7 +51,6 @@
<h3><%= title %></h3>
</script>
-
<script type="text/template" id="xos-navbutton">
<li>
<a href="<%= routeUrl %>">
@@ -61,6 +60,15 @@
</li>
</script>
+<script type="text/template" id="xos-inline-detail-buttons-template">
+ <tr>
+ <td colspan=2><button class="btn js-submit btn-xos-detail btn-xos-save-leave">Save</button>
+ <button class="btn js-submit btn-xos-detail btn-xos-save-continue">Save and Continue Editing</button>
+ <button class="btn js-submit btn-xos-detail btn-xos-save-another">Save and Add Another</button>
+ </td>
+ </tr>
+</script>
+
<!-- Deployment -->
<script type="text/template" id="xosAdmin-deployment-list-template">
@@ -93,7 +101,7 @@
<tr><td>Name:</td><td><input type="text" name="name" value="<%= name %>"></td></tr>
<tr><td>Backend:</td><td><input type="text" name="backend_type" value="<%= backend_type %>"></td></tr>
<tr><td>Admin Tenant:</td><td><input type="text" name="admin_tenant" value="<%= admin_tenant %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -129,7 +137,7 @@
<tr><td>Name:</td><td><input type="text" name="name" value="<%= name %>"></td></tr>
<tr><td>Disk Format:</td><td><input type="text" name="backend_type" value="<%= disk_format %>"></td></tr>
<tr><td>Container Format:</td><td><input type="text" name="admin_tenant" value="<%= container_format %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -173,7 +181,7 @@
<tr><td>Translation:</td><td><input type="text" name="translation" value="<%= translation %>"></td></tr>
<tr><td>Shared Network Name:</td><td><input type="text" name="sharedNetworkName" value="<%= sharedNetworkName %>"></td></tr>
<tr><td>Shared Network Id:</td><td><input type="text" name="sharedNetworkId" value="<%= sharedNetworkId %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -213,7 +221,7 @@
<tr><td>Ports:</td><td><input type="text" name="ports" value="<%= ports %>"></td></tr>
<tr><td>Labels:</td><td><input type="text" name="labels" value="<%= labels %>"></td></tr>
<tr><td>Owner:</td><td><%= idToSelect("owner",owner,"slices","name") %></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -250,7 +258,7 @@
<tr><td>Sliver:</td><td><input type="text" name="sliver" value="<%= sliver %>"></td></tr>
<tr><td>Ip:</td><td><input type="text" name="ip" value="<%= ip %>"></td></tr>
<tr><td>Port_id:</td><td><input type="text" name="port_id" value="<%= port_id %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -284,7 +292,7 @@
<tr><td>Network:</td><td><input type="text" name="network" value="<%= network %>"></td></tr>
<tr><td>Sliver:</td><td><input type="text" name="deployment" value="<%= deployment %>"></td></tr>
<tr><td>Ip:</td><td><input type="text" name="net_id" value="<%= net_id %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -319,7 +327,7 @@
<tr><td>Name:</td><td><input type="text" name="name" value="<%= name %>"></td></tr>
<tr><td>Site:</td><td><%= idToSelect("site",site,"sites","name") %></td></tr>
<tr><td>Deployment:</td><td><%= idToSelect("deployment",deployment,"deployments","name") %></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -348,7 +356,7 @@
<form>
<table>
<tr><td>Role:</td><td><input type="text" name="role" value="<%= role %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -387,7 +395,7 @@
<tr><td>Name:</td><td><input type="text" name="name" value="<%= name %>"></td></tr>
<tr><td>description:</td><td><input type="text" name="description" value="<%= description %>"></td></tr>
<tr><td>Version Number:</td><td><input type="text" name="versionNumber" value="<%= versionNumber %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -430,7 +438,7 @@
<tr><td>Enabled:</td><td><input type="checkbox" name="enabled" <% if (enabled) print("checked"); %>></td></tr>
<tr><td>Is Public:</td><td><input type="checkbox" name="is_public" <% if (is_public) print("checked"); %>></td></tr>
<tr><td>login_base:</td><td><input type="text" name="login_base" value="<%= login_base %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -476,7 +484,7 @@
<tr><td>Description:</td><td><input type="text" name="description" value="<%= description %>"></td></tr>
<tr><td>Url:</td><td><input type="text" name="slice_url" value="<%= slice_url %>"></td></tr>
<tr><td>Max Slivers:</td><td><input type="text" name="max_slivers" value="<%= max_slivers %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -510,7 +518,7 @@
<tr><td>Slice:</td><td><input type="text" name="slice" value="<%= slice %>"></td></tr>
<tr><td>Deployment:</td><td><input type="text" name="deployment" value="<%= deployment %>"></td></tr>
<tr><td>Tenant Id:</td><td><input type="text" name="tenant_id" value="<%= tenant_id %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -544,7 +552,7 @@
<tr><td>User:</td><td><input type="text" name="user" value="<%= user %>"></td></tr>
<tr><td>Slice:</td><td><input type="text" name="slice" value="<%= slice %>"></td></tr>
<tr><td>Role:</td><td><input type="text" name="role" value="<%= role %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -597,7 +605,7 @@
<tr><td>Creator:</td><td><%= idToSelect("creator",creator,"users","username") %></td></tr>
<tr><td>Slice:</td><td><%= idToSelect("slice",slice,"slices","name") %></td></tr>
<tr><td>Deployment:</td><td><%= idToSelect("deploymentNetwork",deploymentNetwork,"deployments","name") %></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -641,7 +649,7 @@
<tr><td>Phone:</td><td><input type="text" name="phone" value="<%= phone %>"></td></tr>
<tr><td>Url:</td><td><input type="text" name="user_url" value="<%= user_url %>"></td></tr>
<tr><td>Site:</td><td><%= idToSelect("site",site,"sites","name") %></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
@@ -661,7 +669,6 @@
</table>
</script>
-
<script type="text/template" id="xosAdmin-userDeployment-listitem-template">
<td class="objectLink"><%= id %></td>
<td><%= idToName(user,"users","username") %></td>
@@ -676,7 +683,11 @@
<tr><td>User:</td><td><input type="text" name="user" value="<%= user %>"></td></tr>
<tr><td>Deployment:</td><td><input type="text" name="deployment" value="<%= deployment %>"></td></tr>
<tr><td>kuser_id:</td><td><input type="text" name="kuser_id" value="<%= kuser_id %>"></td></tr>
- <tr><td colspan=2><button class="btn js-submit btn-xos-detail">Save</button></td></tr>
+ <%= xosInlineDetailButtonsTemplate() %>
</table>
</form>
</script>
+
+<script>
+xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
+</script>