浏览代码

Update PostComponent, hide edit button after 24 hours. Fixes #2188

Daniel Supernault 5 年之前
父节点
当前提交
a1fee6a26b
共有 1 个文件被更改,包括 11 次插入3 次删除
  1. 11 3
      resources/assets/js/components/PostComponent.vue

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

@@ -42,7 +42,7 @@
                   </div>
                   <div v-if="ownerOrAdmin()">
                     <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
-                    <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
+                    <a v-if="canEdit" class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
                     <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
                   </div>
                 </div>
@@ -108,7 +108,7 @@
                           </span>
                           <span v-if="ownerOrAdmin()">
                             <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
-                            <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
+                            <a v-if="canEdit" class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
                             <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost">Delete</a>
                           </span>
                         </div>
@@ -675,7 +675,8 @@ export default {
             ctxEmbedShowCaption: true,
             ctxEmbedShowLikes: false,
             ctxEmbedCompactMode: false,
-            layout: this.profileLayout
+            layout: this.profileLayout,
+            canEdit: false
           }
     },
     watch: {
@@ -773,6 +774,13 @@ export default {
                   self.showComments = true;
                   this.fetchComments();
                 }
+                if(this.ownerOrAdmin()) {
+                  let od = new Date(this.status.created_at).getTime() + (1 * 24 * 60 * 60 * 1000);
+                  let now = new Date().getTime();
+                  if(od > now) {
+                    this.canEdit = true;
+                  }
+                }
                 this.loaded = true;
             }).catch(error => {
               swal('Oops!', 'An error occured, please try refreshing the page.', 'error');