delete links working for deployments
diff --git a/planetstack/core/xoslib/static/js/xosAdminSite.js b/planetstack/core/xoslib/static/js/xosAdminSite.js
index ceb2589..36ffd0b 100644
--- a/planetstack/core/xoslib/static/js/xosAdminSite.js
+++ b/planetstack/core/xoslib/static/js/xosAdminSite.js
@@ -96,9 +96,7 @@
 };

 

 XOSAdminApp.initRouter = function() {

-    router = Marionette.AppRouter.extend({

-    });

-

+    router = XOSRouter;

     var api = {};

     var routes = {};

 

@@ -123,6 +121,11 @@
         api_command = "add" + firstCharUpper(name);

         api[api_command] = XOSAdminApp.addShower(detailViewName, collection_name, "detail", name);

         routes[nav_url] = api_command;

+

+        nav_url = "delete" + firstCharUpper(name) + "/:id";

+        api_command = "delete" + firstCharUpper(name);

+        api[api_command] = XOSAdminApp.deleteShower(collection_name, name);

+        routes[nav_url] = api_command;

     };

 

     XOSAdminApp.Router = new router({ appRoutes: routes, controller: api });

diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-util.js b/planetstack/core/xoslib/static/js/xoslib/xos-util.js
index 5e91a3d..c1f736e 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xos-util.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xos-util.js
@@ -1,5 +1,19 @@
 // misc utility functions
 
+function assert(outcome, description) {
+    if (!outcome) {
+        console.log(description);
+    }
+}
+
+function templateFromId(id) {
+    return _.template($(id).html());
+}
+
+function firstCharUpper(s) {
+    return s.charAt(0).toUpperCase() + s.slice(1);
+}
+
 // http://stackoverflow.com/questions/2117320/set-maximum-displayed-rows-count-for-html-table
 function limitTableRows(tableSelector, maxRows) {
     var table = $(tableSelector)[0] //document.getElementById(tableId);
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index ca7a5bf..eb8008c 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -1,23 +1,25 @@
-function assert(outcome, description) {
-    if (!outcome) {
-        console.log(description);
-    }
-}
-
-function templateFromId(id) {
-    return _.template($(id).html());
-}
-
-function firstCharUpper(s) {
-    return s.charAt(0).toUpperCase() + s.slice(1);
-}
-
 HTMLView = Marionette.ItemView.extend({
   render: function() {
       this.$el.append(this.options.html);
   },
 });
 
+XOSRouter = Marionette.AppRouter.extend({
+        initialize: function() {

+            this.routeStack=[];

+        },

+

+        onRoute: function(x,y,z) {

+             this.routeStack.push(Backbone.history.fragment);

+        },

+

+        prevPage: function() {

+             return this.routeStack.slice(-2)[0];
+        },
+    });

+
+
+
 XOSApplication = Marionette.Application.extend({
     detailBoxId: "#detailBox",
     errorBoxId: "#errorBox",
@@ -107,6 +109,17 @@
         }
     },
 
+    deleteShower: function(collection_name) {
+        var app=this;
+        return function(model_id) {
+            console.log("deleteCalled");
+            collection = xos[collection_name];
+            model = collection.get(model_id);
+            assert(model!=undefined, "failed to get model " + model_id + " from collection " + collection_name);
+            app.deleteDialog(model,"back");
+        }
+    },
+
     detailShower: function(detailName, collection_name, regionName, title) {
         var app=this;
         showModelId = function(model_id) {
@@ -217,9 +230,11 @@
 
     saveSuccess: function(model, result, xhr, infoMsgId, addToCollection) {
         console.log("saveSuccess");
-        if (addToCollection) {
-            addToCollection.add(model);
-            addToCollection.sort();
+        if (model.addToCollection) {
+            console.log("addToCollection");
+            model.addToCollection.add(model);
+            model.addToCollection.sort();
+            model.addToCollection = undefined;
         }
         result = {status: xhr.xhr.status, statusText: xhr.xhr.statusText};
         result["what"] = "save " + model.modelName + " " + model.attributes.humanReadableName;
@@ -251,15 +266,23 @@
                         success: function(model, result, xhr) { that.destroySuccess(model,result,xhr,infoMsgId);}});
     },
 
-    deleteDialog: function(model, navToListAfterDelete) {
+    deleteDialog: function(model, afterDelete) {
         var that=this;
+        console.log("XXX");
+        console.log(Backbone.history.fragment);
+        assert(model!=undefined, "deleteDialog's model is undefined");
         //console.log("deleteDialog"); console.log(model);
         this.confirmDialog(null, null, function() {
             //console.log("deleteConfirm"); console.log(model);
             modelName = model.modelName;
             that.destroyModel(model);
-            if (navToListAfterDelete) {
+            if (afterDelete=="list") {
                 that.navigate("list", modelName);
+            } else if (afterDelete=="back") {
+                prevPage = that.Router.prevPage();
+                if (prevPage) {
+                    that.Router.navigate("#"+prevPage, {trigger: false, replace: true} );
+                }
             }
 
         });
@@ -367,7 +390,7 @@
 
              deleteClicked: function(e) {
                  e.preventDefault();
-                 this.app.deleteDialog(this.model, true);
+                 this.app.deleteDialog(this.model, "list");
              },
 
             tabClick: function(tabId, regionName) {
diff --git a/planetstack/core/xoslib/templates/xosAdmin.html b/planetstack/core/xoslib/templates/xosAdmin.html
index b032e00..3d52676 100644
--- a/planetstack/core/xoslib/templates/xosAdmin.html
+++ b/planetstack/core/xoslib/templates/xosAdmin.html
@@ -91,11 +91,7 @@
 </script>
 
 <script type="text/template" id="xos-delete-button-template">
-    <a href="#delete?model=<%= modelName %>&id=<%= id %>">delete</a>
-</script>
-
-<script type="text/template" id="xos-delete-button-template">
-    <a href="#delete?model=<%= modelName %>&id=<%= id %>">delete</a>
+    <a href="#delete<%= firstCharUpper(modelName) %>/<%= id %>">delete</a>
 </script>
 
 <script type="text/template" id="xos-detail-link-template">