comment-paragraph-article-button.component.ts
1.57 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
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<noosfero.RestResult<noosfero.Article>>) {
promise.then((result: noosfero.RestResult<noosfero.Article>) => {
this.article = result.data;
this.commentParagraphEventService.toggleCommentParagraph(this.article);
});
}
}