From fa8ab928a5f73614d7ec79ae8798709181692130 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Tue, 9 Dec 2014 18:38:13 -0800 Subject: [PATCH] button panels done right --- .../xoslib/dashboards/xosAdminDashboard.html | 6 ++ .../core/xoslib/static/js/xosAdminSite.js | 4 +- .../core/xoslib/static/js/xoslib/xosHelper.js | 55 +++++++++++++++++-- .../core/xoslib/templates/xosAdmin.html | 16 ++++++ 4 files changed, 74 insertions(+), 7 deletions(-) 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. --> + +
+ + +
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 @@ XOSAdminApp.addRegions({ 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 @@ XOSApplication = Marionette.Application.extend({ 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 @@ XOSApplication = Marionette.Application.extend({ 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 @@ XOSApplication = Marionette.Application.extend({ }, }); +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 @@ XOSDetailView = Marionette.ItemView.extend({ submitAddAnotherClicked: function(e) { console.log("saveAnother"); + console.log(this); e.preventDefault(); var that=this; this.afterSave = function() { @@ -499,7 +542,7 @@ XOSDetailView = Marionette.ItemView.extend({ 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 @@ + + + +
<%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %>