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