Commit 1f246d3f4b9c329a60d9948b0d23ea574f72c9af
Committed by
Michel Felipe

1 parent
31b34a75
Exists in
master
and in
26 other branches
Load comments by paragraph
Showing
5 changed files
with
63 additions
and
5 deletions
Show diff stats
src/plugins/comment_paragraph/allow-comment/allow-comment.html
1 | <div class="paragraph-content" ng-bind-html="ctrl.content"></div> | 1 | <div class="paragraph-content" ng-bind-html="ctrl.content"></div> |
2 | <div class="actions"> | 2 | <div class="actions"> |
3 | - <a href="#" popover-placement="right" popover-trigger="outsideClick" uib-popover-template="'plugins/comment_paragraph/allow-comment/popover.html'" ng-click="ctrl.loadComments()"><i class="fa fa-fw fa-comments"></i></a> | 3 | + <a href="#" popover-placement="bottom" popover-trigger="outsideClick" uib-popover-template="'plugins/comment_paragraph/allow-comment/popover.html'" ng-click="ctrl.loadComments()"><i class="fa fa-fw fa-comments"></i></a> |
4 | </div> | 4 | </div> |
src/plugins/comment_paragraph/allow-comment/popover.html
src/plugins/comment_paragraph/http/comment-paragraph.service.ts
0 → 100644
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +import { Injectable, Inject } from "ng-forward"; | ||
2 | +import {RestangularService} from "../../../lib/ng-noosfero-api/http/restangular_service"; | ||
3 | +import {ArticleService} from "../../../lib/ng-noosfero-api/http/article.service"; | ||
4 | + | ||
5 | +@Injectable() | ||
6 | +@Inject("Restangular", "$q", "$log", ArticleService) | ||
7 | +export class CommentParagraphService extends RestangularService<noosfero.Comment> { | ||
8 | + | ||
9 | + constructor(Restangular: restangular.IService, $q: ng.IQService, $log: ng.ILogService, protected articleService: ArticleService) { | ||
10 | + super(Restangular, $q, $log); | ||
11 | + } | ||
12 | + | ||
13 | + getResourcePath() { | ||
14 | + return "comment_paragraph_plugin/comments"; | ||
15 | + } | ||
16 | + | ||
17 | + getDataKeys() { | ||
18 | + return { | ||
19 | + singular: 'comment', | ||
20 | + plural: 'comments' | ||
21 | + }; | ||
22 | + } | ||
23 | + | ||
24 | + getByArticle(article: noosfero.Article, params: any = {}): ng.IPromise<noosfero.RestResult<noosfero.Comment[]>> { | ||
25 | + params['without_reply'] = true; | ||
26 | + let articleElement = this.articleService.getElement(<number>article.id); | ||
27 | + return this.list(articleElement, params); | ||
28 | + } | ||
29 | + | ||
30 | + createInArticle(article: noosfero.Article, comment: noosfero.Comment): ng.IPromise<noosfero.RestResult<noosfero.Comment>> { | ||
31 | + let articleElement = this.articleService.getElement(<number>article.id); | ||
32 | + return this.create(comment, articleElement, null, { 'Content-Type': 'application/json' }, false); | ||
33 | + } | ||
34 | +} |
src/plugins/comment_paragraph/side-comments/side-comments.component.ts
1 | -import {Component} from "ng-forward"; | 1 | +import {Component, Inject, Input} from "ng-forward"; |
2 | +import {CommentsComponent} from "../../../app/article/comment/comments.component"; | ||
3 | +import {CommentService} from "../../../lib/ng-noosfero-api/http/comment.service"; | ||
4 | +import {CommentParagraphService} from "../http/comment-paragraph.service"; | ||
2 | 5 | ||
3 | @Component({ | 6 | @Component({ |
4 | selector: "comment-paragraph-side-comments", | 7 | selector: "comment-paragraph-side-comments", |
5 | - templateUrl: "plugins/comment_paragraph/side-comments/side-comments.html" | 8 | + templateUrl: 'app/article/comment/comments.html', |
6 | }) | 9 | }) |
7 | -export class SideCommentsComponent { | 10 | +@Inject(CommentService, "$rootScope", CommentParagraphService) |
11 | +export class SideCommentsComponent extends CommentsComponent { | ||
8 | 12 | ||
13 | + @Input() article: noosfero.Article; | ||
14 | + @Input() paragraphUuid: string; | ||
15 | + | ||
16 | + constructor(commentService: CommentService, $rootScope: ng.IScope, private commentParagraphService: CommentParagraphService) { | ||
17 | + super(commentService, $rootScope); | ||
18 | + } | ||
19 | + | ||
20 | + loadComments() { | ||
21 | + return this.commentParagraphService.getByArticle(this.article, { page: this.page, per_page: this.perPage, paragraph_uuid: this.paragraphUuid }); | ||
22 | + } | ||
9 | } | 23 | } |