button panels done right
diff --git a/planetstack/core/xoslib/dashboards/xosAdminDashboard.html b/planetstack/core/xoslib/dashboards/xosAdminDashboard.html
index 2364b83..af9a0f4 100644
--- a/planetstack/core/xoslib/dashboards/xosAdminDashboard.html
+++ b/planetstack/core/xoslib/dashboards/xosAdminDashboard.html
@@ -43,6 +43,10 @@
handler for this Save button tells the save button inside the detail
form to click itself.
-->
+
+<div id="rightButtonPanel"></div>
+
+<!--
<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>
@@ -53,6 +57,8 @@
<button class="btn btn-high btn-primary btn-xos-contentButtonPanel" onclick="$('button.btn-xos-refresh').click()">Refresh</button>
<button class="btn btn-high btn-success btn-xos-contentButtonPanel" onclick="$('button.btn-xos-add').click()">Add</button>
</div>
+-->
+
<div class="box" id="logPanel">
<table id="logTable">
<tbody>
diff --git a/planetstack/core/xoslib/static/js/xosAdminSite.js b/planetstack/core/xoslib/static/js/xosAdminSite.js
index 5274a81..8ea8a44 100644
--- a/planetstack/core/xoslib/static/js/xosAdminSite.js
+++ b/planetstack/core/xoslib/static/js/xosAdminSite.js
@@ -21,7 +21,9 @@
linkedObjs3: "#linkedObjs3",
linkedObjs4: "#linkedObjs4",
- addChildDetail: "#xos-addchild-detail"
+ addChildDetail: "#xos-addchild-detail",
+
+ rightButtonPanel: "#rightButtonPanel"
});
XOSAdminApp.navigate = function(what, modelName, modelId) {
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index 46bc522..3bfd8fd 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -110,13 +110,15 @@
createListHandler: function(listViewName, collection_name, regionName, title) {
var app=this;
return function() {
- app[regionName].show(new app[listViewName]);
+ listView = new app[listViewName];
+ app[regionName].show(listView);
app.hideLinkedItems();
$("#contentTitle").html(templateFromId("#xos-title-list")({"title": title}));
$("#detail").show();
- $("#xos-listview-button-box").show();
$("#tabs").hide();
- $("#xos-detail-button-box").hide();
+
+ listButtons = new XOSListButtonView({linkedView: listView});
+ app["rightButtonPanel"].show(listButtons);
}
},
@@ -196,8 +198,11 @@
detailView = new detailViewClass({model: model});
app[regionName].show(detailView);
detailView.showLinkedItems();
- $("#xos-detail-button-box").show();
- $("#xos-listview-button-box").hide();
+ //$("#xos-detail-button-box").show();
+ //$("#xos-listview-button-box").hide();
+
+ detailButtons = new XOSDetailButtonView({linkedView: detailView});
+ app["rightButtonPanel"].show(detailButtons);
}
}
return showModelId;
@@ -344,6 +349,43 @@
},
});
+XOSButtonView = Marionette.ItemView.extend({
+ events: {"click button.btn-xos-save-continue": "submitContinueClicked",
+ "click button.btn-xos-save-leave": "submitLeaveClicked",
+ "click button.btn-xos-save-another": "submitAddAnotherClicked",
+ "click button.btn-xos-delete": "deleteClicked",
+ "click button.btn-xos-add": "addClicked",
+ "click button.btn-xos-refresh": "refreshClicked",
+ },
+
+ submitLeaveClicked: function(e) {
+ this.options.linkedView.submitLeaveClicked.call(this.options.linkedView, e);
+ },
+
+ submitContinueClicked: function(e) {
+ this.options.linkedView.submitContinueClicked.call(this.options.linkedView, e);
+ },
+
+ submitAddAnotherClicked: function(e) {
+ this.options.linkedView.submitAddAnotherClicked.call(this.options.linkedView, e);
+ },
+
+ submitDeleteClicked: function(e) {
+ this.options.linkedView.submitDeleteClicked.call(this.options.linkedView, e);
+ },
+
+ addClicked: function(e) {
+ this.options.linkedView.addClicked.call(this.options.linkedView, e);
+ },
+
+ refreshClicked: function(e) {
+ this.options.linkedView.refreshClicked.call(this.options.linkedView, e);
+ },
+ });
+
+XOSDetailButtonView = XOSButtonView.extend({ template: "#xos-savebuttons-template" });
+XOSListButtonView = XOSButtonView.extend({ template: "#xos-listbuttons-template" });
+
/* XOSDetailView
extend with:
app - MarionetteApplication
@@ -399,6 +441,7 @@
submitAddAnotherClicked: function(e) {
console.log("saveAnother");
+ console.log(this);
e.preventDefault();
var that=this;
this.afterSave = function() {
@@ -499,7 +542,7 @@
relatedListViewClassName = relatedName + "ListView";
assert(this.app[relatedListViewClassName] != undefined, relatedListViewClassName + " not found");
relatedListViewClass = this.app[relatedListViewClassName].extend({collection: xos[relatedName],
- filter: makeFilter(relatedField, relatedId), //function(model) { return model.attributes[relatedField]==relatedId; },
+ filter: makeFilter(relatedField, relatedId),
parentModel: this.model});
this.app[regionName].show(new relatedListViewClass());
if (this.app.hideTabsByDefault) {
diff --git a/planetstack/core/xoslib/templates/xosAdmin.html b/planetstack/core/xoslib/templates/xosAdmin.html
index 8047580..9a0e0f5 100644
--- a/planetstack/core/xoslib/templates/xosAdmin.html
+++ b/planetstack/core/xoslib/templates/xosAdmin.html
@@ -173,6 +173,22 @@
<td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
+<script type="text/template" id="xos-savebuttons-template">
+ <div class="box save-box">
+ <button class="btn btn-high btn-info btn-xos-contentButtonPanel btn-xos-save-leave">Save</button>
+ <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-continue">Save and continue editing</button>
+ <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-another">Save and add another</button>
+ <button class="btn btn-danger btn-xos-contentButtonPanel btn-xos-delete">Delete</button>
+ </div>
+</script>
+
+<script type="text/template" id="xos-listbuttons-template">
+ <div class="box save-box">
+ <button class="btn btn-high btn-primary btn-xos-contentButtonPanel btn-xos-refresh">Refresh</button>
+ <button class="btn btn-high btn-success btn-xos-contentButtonPanel btn-xos-add">Add</button>
+ </div>
+</script>
+
<script>
xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
xosListHeaderTemplate = _.template($("#xos-list-header-template").html());