From ebbe8424165caf984f38608debbadbd9f3536a15 Mon Sep 17 00:00:00 2001 From: Carly Ho Date: Sat, 29 Dec 2018 16:55:47 -0600 Subject: [PATCH] Add confirmation check to post deletion function --- .../assets/js/components/PostComponent.vue | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index c3b9f6258..cf6665a95 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -56,11 +56,11 @@
-
+
- +
@@ -164,10 +164,10 @@
-
@@ -195,10 +195,10 @@
-
@@ -281,7 +281,7 @@ export default { $('head title').text(title); } }, - + methods: { authCheck() { let authed = $('body').hasClass('loggedIn'); @@ -495,19 +495,22 @@ export default { }, deletePost() { - if($('body').hasClass('loggedIn') == false) { - return; - } + var result = confirm('Are you sure you want to delete this post?'); + if (result) { + if($('body').hasClass('loggedIn') == false) { + return; + } - axios.post('/i/delete', { - type: 'status', - item: this.status.id - }).then(res => { - swal('Success', 'You have successfully deleted this post', 'success'); - }).catch(err => { - swal('Error', 'Something went wrong. Please try again later.', 'error'); - }); + axios.post('/i/delete', { + type: 'status', + item: this.status.id + }).then(res => { + swal('Success', 'You have successfully deleted this post', 'success'); + }).catch(err => { + swal('Error', 'Something went wrong. Please try again later.', 'error'); + }); + } } } } - \ No newline at end of file +