Commit d56bc4d47f5421ce9b3c6b4faa67dffdcd0fbc44

Authored by Victor Costa
1 parent 6b394e0b

Do now show comment form when article doesn't accept comments

src/app/article/comment/comment.html
... ... @@ -18,7 +18,7 @@
18 18 <div class="title">{{ctrl.comment.title}}</div>
19 19 <div class="body">{{ctrl.comment.body}}</div>
20 20 <div class="actions" ng-if="ctrl.displayActions">
21   - <a href="#" (click)="ctrl.reply()" class="small text-muted">
  21 + <a href="#" (click)="ctrl.reply()" class="small text-muted" ng-if="ctrl.article.accept_comments">
22 22 {{"comment.reply" | translate}}
23 23 </a>
24 24 </div>
... ...
src/app/article/comment/comments.scss 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +.comments {
  2 + border-top: 2px solid #F3F3F3;
  3 + .comments {
  4 + border-top: 0;
  5 + }
  6 +}
... ...
src/app/article/comment/post-comment/post-comment.component.spec.ts
... ... @@ -7,6 +7,8 @@ const htmlTemplate: string = &#39;&lt;noosfero-post-comment [article]=&quot;ctrl.article&quot; [r
7 7 describe("Components", () => {
8 8 describe("Post Comment Component", () => {
9 9  
  10 + let properties = { article: { id: 1, accept_comments: true } };
  11 +
10 12 beforeEach(angular.mock.module("templates"));
11 13  
12 14 let commentService = jasmine.createSpyObj("commentService", ["createInArticle"]);
... ... @@ -19,7 +21,7 @@ describe(&quot;Components&quot;, () =&gt; {
19 21  
20 22 @Component({ selector: 'test-container-component', directives: [PostCommentComponent], template: htmlTemplate, providers: providers })
21 23 class ContainerComponent {
22   - article = { id: 1 };
  24 + article = properties['article'];
23 25 comment = { id: 2 };
24 26 }
25 27  
... ... @@ -30,6 +32,14 @@ describe(&quot;Components&quot;, () =&gt; {
30 32 });
31 33 });
32 34  
  35 + it("not render the post comment form when article doesn't accept comments", done => {
  36 + properties['article'].accept_comments = false;
  37 + helpers.createComponentFromClass(ContainerComponent).then(fixture => {
  38 + expect(fixture.debugElement.queryAll("form").length).toEqual(0);
  39 + done();
  40 + });
  41 + });
  42 +
33 43 it("emit an event when create comment", done => {
34 44 helpers.createComponentFromClass(ContainerComponent).then(fixture => {
35 45 let component: PostCommentComponent = fixture.debugElement.componentViewChildren[0].componentInstance;
... ...
src/app/article/comment/post-comment/post-comment.html
1   -<form class="clearfix post-comment">
  1 +<form class="clearfix post-comment" ng-if="ctrl.article.accept_comments">
2 2 <div class="form-group">
3 3 <div class="comment media">
4 4 <div class="media-left">
... ...
src/app/article/comment/post-comment/post-comment.scss
1 1 .comments {
2 2 .post-comment {
3 3 .media {
4   - border-top: 2px solid #F3F3F3;
5 4 padding-top: 10px;
6 5 .media-left {
7 6 padding: 10px 0;
... ...
src/plugins/comment_paragraph/side-comments/side-comments.scss
1 1 comment-paragraph-side-comments {
2 2 .comments {
  3 + min-height: 20px;
  4 + border-top: 0;
3 5 .comment {
4 6 margin: 0;
5 7 &.media {
... ...