import {Component, Input, Inject, bundleStore} 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"; import {CommentService} from "../../../lib/ng-noosfero-api/http/comment.service"; import {PostCommentComponent} from '../../../app/article/comment/post-comment/post-comment.component'; @Component({ selector: "comment-paragraph-plugin-allow-comment", templateUrl: "plugins/comment_paragraph/allow-comment/allow-comment.html", directives: [SideCommentsComponent] }) @Inject("$scope", CommentParagraphEventService, CommentParagraphService, CommentService) 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, private commentService: CommentService) { } 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; }); this.commentService.onSave.subscribe((comment: noosfero.Comment) => { this.commentsCount++; }); } isActivated() { return this.article && this.article.setting && this.article.setting.comment_paragraph_plugin_activate; } showParagraphComments() { this.display = true; } hideParagraphComments() { this.display = false; } }