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);
}
},
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;
},
});
+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
submitAddAnotherClicked: function(e) {
console.log("saveAnother");
+ console.log(this);
e.preventDefault();
var that=this;
this.afterSave = function() {
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) {
<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());