From dae1b82ff0077b6ad3365c34d53e34ea5e7adbf5 Mon Sep 17 00:00:00 2001
From: Scott Baker <smbaker@gmail.com>
Date: Mon, 12 Jan 2015 12:56:25 -0800
Subject: [PATCH] afterDelete working in tenant view

---
 planetstack/core/xoslib/static/js/xosTenant.js        | 7 ++++++-
 planetstack/core/xoslib/static/js/xoslib/xosHelper.js | 2 ++
 planetstack/core/xoslib/templates/xosAdmin.html       | 8 +++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js
index 6f73046..5a548ed 100644
--- a/planetstack/core/xoslib/static/js/xosTenant.js
+++ b/planetstack/core/xoslib/static/js/xosTenant.js
@@ -42,7 +42,7 @@ XOSTenantButtonView = Marionette.ItemView.extend({
                      },
 
             deleteClicked: function(e) {
-                     this.options.linkedView.deleteClicked.call(this.options.linkedView, e);
+                     XOSTenantApp.deleteSlice(this.options.linkedView.model);
                      },
 
             addUserClicked: function(e) {
@@ -156,6 +156,11 @@ XOSTenantApp.addSlice = function() {
     $("#tenant-addslice-dialog").dialog("open");
 };
 
+XOSTenantApp.deleteSlice = function(model) {
+    var app=this;
+    app.deleteDialog(model, function() { console.log("afterDelete"); app.viewSlice(undefined); });
+};
+
 XOSTenantApp.viewSlice = function(model) {
     if (!model && xos.slicesPlus.models.length > 0) {
         model = xos.slicesPlus.models[0];
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index 4ec75a6..9f9964c 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -400,6 +400,8 @@ XOSApplication = Marionette.Application.extend({
             that.destroyModel(model);
             if (afterDelete=="list") {
                 that.navigate("list", modelName);
+            } else if (afterDelete) {
+                afterDelete();
             }
         });
     },
diff --git a/planetstack/core/xoslib/templates/xosAdmin.html b/planetstack/core/xoslib/templates/xosAdmin.html
index ac90e94..53b9fe6 100644
--- a/planetstack/core/xoslib/templates/xosAdmin.html
+++ b/planetstack/core/xoslib/templates/xosAdmin.html
@@ -228,11 +228,17 @@
   </div>
 </script>
 
-<script type="text/template" id="xos-datatable-spinner-template">
+<script type="text/template" id="xos-datatable-spinner-template-old">
     <!-- arguments: value, id, collectionName, fieldName -->
     <%= value %> <a href='#increase/<%= collectionName %>/<%= id %>/<%= fieldName %>'>more</a> <a href='#decrease/<%= collectionName %>/<%= id %>/<%= fieldName %>'>less</a>
 </script>
 
+<script type="text/template" id="xos-datatable-spinner-template">
+    <!-- arguments: value, id, collectionName, fieldName -->
+    <%= value %> <a href="javascript:undefined" onclick='<%= app.varName %>.adjustCollectionField("<%= collectionName %>", <%= id %>, "<%= fieldName %>", 1)'> more </a>
+                 <a href="javascript:undefined" onclick='<%= app.varName %>.adjustCollectionField("<%= collectionName %>", <%= id %>, "<%= fieldName %>", -1)'> less </a>
+</script>
+
 <script type="text/template" id="xos-spinner-template">
     <!-- arguments: fieldName, id, value -->
     <input name="<%= fieldName %>" class="xos-spinner" id="<%= id %>">
-- 
2.47.0