diff options
Diffstat (limited to 'public/assets/javascripts/ui/site/StaffView.js')
| -rw-r--r-- | public/assets/javascripts/ui/site/StaffView.js | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/public/assets/javascripts/ui/site/StaffView.js b/public/assets/javascripts/ui/site/StaffView.js index 8f677cb..fd173e5 100644 --- a/public/assets/javascripts/ui/site/StaffView.js +++ b/public/assets/javascripts/ui/site/StaffView.js @@ -7,7 +7,7 @@ var StaffView = View.extend({ initialize: function() { this.$toggleStaff = $("#toggle-staff") - if (this.$toggleStaff.data().isstaff) { + if (this.$toggleStaff.length && this.$toggleStaff.data().isstaff) { this.$toggleStaff.html("Is Staff") } }, @@ -22,20 +22,23 @@ var StaffView = View.extend({ toggleStaff: function(){ var state = ! this.$toggleStaff.data().isstaff - $.ajax({ - type: "put", - dataType: "json", - url: window.location.href + "/bless", - data: { - state: state, - _csrf: $("#_csrf").val(), - }, - success: function(data){ - this.$toggleStaff.data("isstaff", data.state) - this.$toggleStaff.html(data.state ? "Is Staff" : "Make Staff") - $("#is-staff").html(data.state ? "yes" : "no") - }.bind(this) - }) + var verb = state ? "promote this user to staff?" : "remove this user from staff?" + ConfirmModal.confirm("Are you sure you want to " + verb, function(){ + $.ajax({ + type: "put", + dataType: "json", + url: window.location.href + "/bless", + data: { + state: state, + _csrf: $("#_csrf").val(), + }, + success: function(data){ + this.$toggleStaff.data("isstaff", data.state) + this.$toggleStaff.html(data.state ? "Is Staff" : "Make Staff") + $("#is-staff").html(data.state ? "yes" : "no") + }.bind(this) + }) + }.bind(this)) }, }) |
