templateize detail inline button panel, add save/continue and save/another buttons...
[plstackapi.git] / planetstack / core / xoslib / static / js / xoslib / xosHelper.js
index 1dc3bf5..4a408e1 100644 (file)
@@ -113,7 +113,9 @@ XOSApplication = Marionette.Application.extend({
             app.hideLinkedItems();\r
             $("#contentTitle").html(templateFromId("#xos-title-list")({"title": title}));\r
             $("#detail").show();\r
+            $("#xos-listview-button-box").show();\r
             $("#tabs").hide();\r
+            $("#xos-detail-button-box").hide();\r
         }\r
     },\r
 \r
@@ -125,6 +127,8 @@ XOSApplication = Marionette.Application.extend({
                 detailView = new detailViewClass({model: model});\r
                 app[regionName].show(detailView);\r
                 detailView.showLinkedItems();\r
+                $("#xos-detail-button-box").show();\r
+                $("#xos-listview-button-box").hide();\r
             }\r
 \r
             $("#contentTitle").html(templateFromId("#xos-title-detail")({"title": title}));\r
@@ -167,7 +171,9 @@ XOSApplication = Marionette.Application.extend({
 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 @@ XOSDetailView = Marionette.ItemView.extend({
                 this.app.showSuccess(result);\r
             },
 
-            submitClicked: function(e) {
-                console.log("submit clicked");
-                this.app.hideError();\r
-                e.preventDefault();\r
+            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..."} );\r
                 var data = Backbone.Syphon.serialize(this);\r
                 var that = this;\r