|
|
|
@ -7,7 +7,7 @@ |
|
|
|
</li> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<comment-form v-if="store.user.id && ! replyTo" :controller="controller"></comment-form> |
|
|
|
<comment-form v-if="$root.store.user.id && ! replyTo" :controller="controller"></comment-form> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
@ -25,7 +25,6 @@ |
|
|
|
replyTo: null, |
|
|
|
replyTo: null, |
|
|
|
nodes: [], |
|
|
|
nodes: [], |
|
|
|
controller: this, |
|
|
|
controller: this, |
|
|
|
store: window.VUE_STORE, |
|
|
|
|
|
|
|
flatComments: {}, |
|
|
|
flatComments: {}, |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -44,9 +43,9 @@ |
|
|
|
this.loading = true; |
|
|
|
this.loading = true; |
|
|
|
let request = api.addObjComment(this.objId, this.objType, { |
|
|
|
let request = api.addObjComment(this.objId, this.objType, { |
|
|
|
content: content, |
|
|
|
content: content, |
|
|
|
author: this.store.user.id, |
|
|
|
author: this.$root.store.user.id, |
|
|
|
parent: this.replyTo && this.replyTo.id, |
|
|
|
parent: this.replyTo && this.replyTo.id, |
|
|
|
}, this.store.accessToken); |
|
|
|
}); |
|
|
|
request.then((response) => { |
|
|
|
request.then((response) => { |
|
|
|
vm.loading = false; |
|
|
|
vm.loading = false; |
|
|
|
vm.onAdd(response.data); |
|
|
|
vm.onAdd(response.data); |
|
|
|
@ -63,7 +62,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
let vm = this; |
|
|
|
let vm = this; |
|
|
|
this.loading = true; |
|
|
|
this.loading = true; |
|
|
|
let request = api.removeObjComment(comment.id, this.store.accessToken); |
|
|
|
let request = api.removeObjComment(comment.id); |
|
|
|
request.then((response) => { |
|
|
|
request.then((response) => { |
|
|
|
vm.loading = false; |
|
|
|
vm.loading = false; |
|
|
|
vm.onRemove(comment); |
|
|
|
vm.onRemove(comment); |
|
|
|
@ -73,11 +72,12 @@ |
|
|
|
if(this.flatComments[comment.id]){ |
|
|
|
if(this.flatComments[comment.id]){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const method = this.isChat ? 'push' : 'unshift'; |
|
|
|
if(comment.parent){ |
|
|
|
if(comment.parent){ |
|
|
|
this.flatComments[comment.parent].children.unshift(comment); |
|
|
|
this.flatComments[comment.parent].children[method](comment); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
this.nodes.unshift(comment); |
|
|
|
this.nodes[method](comment); |
|
|
|
} |
|
|
|
} |
|
|
|
this.flatComments[comment.id] = comment; |
|
|
|
this.flatComments[comment.id] = comment; |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -114,7 +114,7 @@ |
|
|
|
mounted() { |
|
|
|
mounted() { |
|
|
|
let vm = this; |
|
|
|
let vm = this; |
|
|
|
this.loading = true; |
|
|
|
this.loading = true; |
|
|
|
let request = api.getObjComments(this.objId, this.objType, this.store.accessToken); |
|
|
|
let request = api.getObjComments(this.objId, this.objType, this.isChat ? 'update_at' : '-update_at'); |
|
|
|
request |
|
|
|
request |
|
|
|
.then((response) => { |
|
|
|
.then((response) => { |
|
|
|
vm.loading = false; |
|
|
|
vm.loading = false; |
|
|
|
|