import { Input, Inject, Component } from "ng-forward"; import {Hotspot} from "../../../app/hotspot/hotspot.decorator"; import {CommentParagraphService} from "../http/comment-paragraph.service"; import {CommentParagraphEventService} from "../events/comment-paragraph-event.service"; @Component({ selector: "comment-paragraph-article-button-hotspot", templateUrl: "plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html", }) @Inject("$scope", CommentParagraphService, CommentParagraphEventService) @Hotspot("article_extra_toolbar_buttons") export class CommentParagraphArticleButtonHotspotComponent { @Input() article: noosfero.Article; constructor(private $scope: ng.IScope, private commentParagraphService: CommentParagraphService, private commentParagraphEventService: CommentParagraphEventService) { } deactivateCommentParagraph() { this.toggleCommentParagraph(this.commentParagraphService.deactivateCommentParagraph(this.article)); } activateCommentParagraph() { this.toggleCommentParagraph(this.commentParagraphService.activateCommentParagraph(this.article)); } isActivated() { return this.article && this.article.setting && this.article.setting.comment_paragraph_plugin_activate; } private toggleCommentParagraph(promise: ng.IPromise>) { promise.then((result: noosfero.RestResult) => { this.article = result.data; this.commentParagraphEventService.toggleCommentParagraph(this.article); }); } }