fixes+improvements
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
|
||||
<p>{{entry.text}}</p>
|
||||
|
||||
<ui-commentform [target]="entry.id" [change]="boundRefresh"></ui-commentform>
|
||||
<ui-commentform [target]="entry.id" [change]="boundReplyCallback"></ui-commentform>
|
||||
|
||||
<ui-comments [target]="entry.id"></ui-comments>
|
||||
<ng-container *ngIf="entry.metadata.comments">
|
||||
<ui-comments [target]="entry.id"></ui-comments>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
@@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { EntriesService } from '../../services/entries.service';
|
||||
import { CommentService } from '../../services/comment.service';
|
||||
|
||||
@Component({
|
||||
selector: 'page-entry',
|
||||
@@ -14,13 +15,15 @@ export class PageEntry implements OnInit {
|
||||
entry: any;
|
||||
notfound: boolean = false;
|
||||
boundRefresh: Function;
|
||||
boundReplyCallback: Function;
|
||||
|
||||
constructor(private entriesService: EntriesService,
|
||||
constructor(private commentService: CommentService, private entriesService: EntriesService,
|
||||
private route: ActivatedRoute) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.id = +this.route.snapshot.paramMap.get('id');
|
||||
this.boundRefresh = this.refresh.bind(this);
|
||||
this.boundReplyCallback = this.replyCallback.bind(this);
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
@@ -34,4 +37,12 @@ export class PageEntry implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
replyCallback(): void {
|
||||
this.entry.metadata.reply = false;
|
||||
this.entry.metadata.comments = 0;
|
||||
this.commentService.count(this.entry.id).subscribe((data) => {
|
||||
this.entry.metadata.comments = +data;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user