Merge Request #24
← To merge requests
From
hide-paragraph-button
into
master
Hide button to side comments when there is no comments to display and article doesn't accept comments anymore
Commits (1)
Showing
3 changed files
Show diff stats
src/lib/ng-noosfero-api/interfaces/article.ts
src/plugins/comment_paragraph/allow-comment/allow-comment.component.spec.ts
| @@ -74,5 +74,17 @@ describe("Components", () => { | @@ -74,5 +74,17 @@ describe("Components", () => { | ||
| 74 | functionToggleCommentParagraph({ id: 2 }); | 74 | functionToggleCommentParagraph({ id: 2 }); |
| 75 | expect(helper.component.article.id).toEqual(2); | 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,7 +32,9 @@ export class AllowCommentComponent { | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | isActivated() { | 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 | showParagraphComments() { | 40 | showParagraphComments() { |
-
mentioned in commit 9849cd64d16cc5ddc6e18264061eb5d8b66f1d43