diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 19:08:52 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 19:08:52 +0100 |
| commit | 1d38c91fbc8aed5b909c0ce9f60014b219fe792a (patch) | |
| tree | 77bd83d30597e03c84805c17d8176b4c770cf88e /public/assets/js/lib/views | |
| parent | 64c4a75529db6c2129fbcde2b1b63a44d4a45fb4 (diff) | |
delete and reply
Diffstat (limited to 'public/assets/js/lib/views')
| -rw-r--r-- | public/assets/js/lib/views/mail/mailbox.js | 7 | ||||
| -rw-r--r-- | public/assets/js/lib/views/mail/message.js | 10 |
2 files changed, 12 insertions, 5 deletions
diff --git a/public/assets/js/lib/views/mail/mailbox.js b/public/assets/js/lib/views/mail/mailbox.js index 860d200..b7877f2 100644 --- a/public/assets/js/lib/views/mail/mailbox.js +++ b/public/assets/js/lib/views/mail/mailbox.js @@ -54,20 +54,23 @@ var MailboxView = View.extend({ .replace(/{{size_class}}/g, size[0] ) var $t = $(t) if (is_sender) { - $t.find('reply_link').remove() + $t.find('.reply_link').remove() } return $t }, discard: function(e){ var id = $(e.target).data('id') + var ok = confirm("Really delete this message?") + if (! ok) return $.ajax({ method: 'delete', url: '/api/message/' + id, + headers: { "csrf-token": csrf() }, + data: { _csrf: csrf() }, success: function(){ window.location.reload() }, error: function(){ window.location.reload() }, }) }, - }) diff --git a/public/assets/js/lib/views/mail/message.js b/public/assets/js/lib/views/mail/message.js index 400c11e..c765b0a 100644 --- a/public/assets/js/lib/views/mail/message.js +++ b/public/assets/js/lib/views/mail/message.js @@ -45,18 +45,22 @@ var MessageView = View.extend({ .replace(/{{body}}/g, tidy_urls(message.body) ) var $t = $(t) if (is_sender) { - $t.find('reply_link').remove() + $t.find('.reply_link').remove() } this.$el.empty().append($t) }, discard: function(e){ var id = $(e.target).data('id') + var ok = confirm("Really delete this message?") + if (! ok) return $.ajax({ method: 'delete', url: '/api/message/' + id, - success: function(){ window.location.reload() }, - error: function(){ window.location.reload() }, + headers: { "csrf-token": csrf() }, + data: { _csrf: csrf() }, + success: function(){ window.location.href = "/mail" }, + error: function(){ window.location.href = "/mail" }, }) }, |
