allow-comment.component.ts
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {Component, Input, Inject} from "ng-forward";
import {SideCommentsComponent} from "../side-comments/side-comments.component";
import {CommentParagraphEventService} from "../events/comment-paragraph-event.service";
import {CommentParagraphService} from "../http/comment-paragraph.service";
@Component({
selector: "comment-paragraph-plugin-allow-comment",
templateUrl: "plugins/comment_paragraph/allow-comment/allow-comment.html",
directives: [SideCommentsComponent]
})
@Inject("$scope", CommentParagraphEventService, CommentParagraphService)
export class AllowCommentComponent {
@Input() content: string;
@Input() paragraphUuid: string;
@Input() article: noosfero.Article;
commentsCount: number;
display = false;
constructor(private $scope: ng.IScope,
private commentParagraphEventService: CommentParagraphEventService,
private commentParagraphService: CommentParagraphService) { }
ngOnInit() {
this.commentParagraphEventService.subscribeToggleCommentParagraph((article: noosfero.Article) => {
this.article = article;
this.$scope.$apply();
});
this.commentParagraphService.commentParagraphCount(this.article, this.paragraphUuid).then((count: number) => {
this.commentsCount = count;
});
}
isActivated() {
return this.article && this.article.setting &&
this.article.setting.comment_paragraph_plugin_activate &&
(this.article.accept_comments || this.commentsCount > 0);
}
showParagraphComments() {
this.display = true;
}
hideParagraphComments() {
this.display = false;
}
}