1
0
Эх сурвалжийг харах

Add confirmation check to post deletion function

Carly Ho 6 жил өмнө
parent
commit
ebbe842416

+ 24 - 21
resources/assets/js/components/PostComponent.vue

@@ -56,11 +56,11 @@
        </div>
        </div>
         <div class="col-12 col-md-8 px-0 mx-0">
         <div class="col-12 col-md-8 px-0 mx-0">
             <div class="postPresenterLoader text-center">
             <div class="postPresenterLoader text-center">
-              <div class="lds-ring"><div></div><div></div><div></div><div></div></div> 
+              <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
             </div>
             </div>
             <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center">
             <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center">
               <div v-if="status.pf_type === 'photo'" class="w-100">
               <div v-if="status.pf_type === 'photo'" class="w-100">
-                <photo-presenter :status="status"></photo-presenter>  
+                <photo-presenter :status="status"></photo-presenter>
               </div>
               </div>
 
 
               <div v-else-if="status.pf_type === 'video'" class="w-100">
               <div v-else-if="status.pf_type === 'video'" class="w-100">
@@ -164,10 +164,10 @@
     </div>
     </div>
   </div>
   </div>
 
 
-  <b-modal ref="likesModal" 
+  <b-modal ref="likesModal"
     id="l-modal"
     id="l-modal"
-    hide-footer 
-    centered 
+    hide-footer
+    centered
     title="Likes"
     title="Likes"
     body-class="list-group-flush p-0">
     body-class="list-group-flush p-0">
     <div class="list-group">
     <div class="list-group">
@@ -195,10 +195,10 @@
       </infinite-loading>
       </infinite-loading>
     </div>
     </div>
   </b-modal>
   </b-modal>
-  <b-modal ref="sharesModal" 
+  <b-modal ref="sharesModal"
     id="s-modal"
     id="s-modal"
-    hide-footer 
-    centered 
+    hide-footer
+    centered
     title="Shares"
     title="Shares"
     body-class="list-group-flush p-0">
     body-class="list-group-flush p-0">
     <div class="list-group">
     <div class="list-group">
@@ -281,7 +281,7 @@ export default {
         $('head title').text(title);
         $('head title').text(title);
       }
       }
     },
     },
-    
+
     methods: {
     methods: {
       authCheck() {
       authCheck() {
         let authed = $('body').hasClass('loggedIn');
         let authed = $('body').hasClass('loggedIn');
@@ -495,19 +495,22 @@ 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');
-        });
       }
       }
     }
     }
 }
 }
-</script>
+</script>