Prechádzať zdrojové kódy

Merge pull request #718 from cmho/702-confirm-deletion

[702] Add confirmation check to post deletion function
daniel 6 rokov pred
rodič
commit
b7f866441c
1 zmenil súbory, kde vykonal 14 pridanie a 11 odobranie
  1. 14 11
      resources/assets/js/components/PostComponent.vue

+ 14 - 11
resources/assets/js/components/PostComponent.vue

@@ -496,18 +496,21 @@ export default {
       },
       },
 
 
       deletePost() {
       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');
-        });
       }
       }
     }
     }
 }
 }