Commit adad53f006d27d7636f9d98ac7a3b47d48ff633d

Authored by Victor Costa
1 parent c623e86c

Hide button to side comments when there is no comments to display

src/lib/ng-noosfero-api/interfaces/article.ts
... ... @@ -13,5 +13,6 @@ namespace noosfero {
13 13 setting: any;
14 14 start_date: string;
15 15 end_date: string;
  16 + accept_comments: boolean;
16 17 }
17 18 }
... ...
src/plugins/comment_paragraph/allow-comment/allow-comment.component.spec.ts
... ... @@ -74,5 +74,17 @@ describe("Components", () => {
74 74 functionToggleCommentParagraph({ id: 2 });
75 75 expect(helper.component.article.id).toEqual(2);
76 76 });
  77 +
  78 + it('not display button to side comments when comments was closed and there is no comment paragraph', () => {
  79 + helper.component.article.accept_comments = false;
  80 + helper.component.commentsCount = 0;
  81 + expect(helper.component.isActivated()).toBeFalsy();
  82 + });
  83 +
  84 + it('display button to side comments when comments was closed and there is some comments to display', () => {
  85 + helper.component.article.accept_comments = false;
  86 + helper.component.commentsCount = 2;
  87 + expect(helper.component.isActivated()).toBeTruthy();
  88 + });
77 89 });
78 90 });
... ...
src/plugins/comment_paragraph/allow-comment/allow-comment.component.ts
... ... @@ -32,7 +32,9 @@ export class AllowCommentComponent {
32 32 }
33 33  
34 34 isActivated() {
35   - return this.article && this.article.setting && this.article.setting.comment_paragraph_plugin_activate;
  35 + return this.article && this.article.setting &&
  36 + this.article.setting.comment_paragraph_plugin_activate &&
  37 + (this.article.accept_comments || this.commentsCount > 0);
36 38 }
37 39  
38 40 showParagraphComments() {
... ...