diff --git a/src/app/comments/comment/comment.component.html b/src/app/comments/comment/comment.component.html
index 2916269..3d6ce93 100644
--- a/src/app/comments/comment/comment.component.html
+++ b/src/app/comments/comment/comment.component.html
@@ -1,66 +1,75 @@
diff --git a/src/app/comments/comment/comment.component.scss b/src/app/comments/comment/comment.component.scss
index 9d1a44d..830c613 100644
--- a/src/app/comments/comment/comment.component.scss
+++ b/src/app/comments/comment/comment.component.scss
@@ -2,6 +2,7 @@
margin: 0.5em 0;
padding: 1em;
border: 1px solid gray;
+ display: flex;
}
.comment-content {
@@ -12,3 +13,11 @@
font-size: smaller;
color: gray;
}
+
+.vote-wrapper {
+ margin-right: 1em;
+}
+
+.body-wrapper {
+ flex: 1;
+}
diff --git a/src/app/comments/comment/comment.component.spec.ts b/src/app/comments/comment/comment.component.spec.ts
index 273b3d0..46b7e55 100644
--- a/src/app/comments/comment/comment.component.spec.ts
+++ b/src/app/comments/comment/comment.component.spec.ts
@@ -2,6 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MomentModule } from 'angular2-moment';
import { CommentComponent } from './comment.component';
+import { VoteStubComponent } from 'app/shared/vote/vote.component';
import { CommentFormStubComponent } from '../comment-form/comment-form.component';
import { EditorOutputComponent } from 'app/shared/editor-output/editor-output.component';
import { UserSmallStubComponent } from 'app/shared/user-small/user-small.component';
@@ -21,7 +22,8 @@ describe('CommentComponent', () => {
CommentComponent,
CommentFormStubComponent,
EditorOutputComponent,
- UserSmallStubComponent
+ UserSmallStubComponent,
+ VoteStubComponent
],
imports: [
MomentModule
diff --git a/src/app/comments/comment/comment.component.ts b/src/app/comments/comment/comment.component.ts
index 3a9e572..76790f9 100644
--- a/src/app/comments/comment/comment.component.ts
+++ b/src/app/comments/comment/comment.component.ts
@@ -105,6 +105,25 @@ export class CommentComponent implements OnInit {
_.pullAllBy(this.comment.reactions, [reaction], 'id');
}
+ async onVote(vote: number) {
+ // when vote doesn't exist, we add it
+ // when vote exists, we remove it
+ // and we update the comment.votes object
+ if (this.comment.votes.me === 0) {
+ // we add the vote
+ await this.model.vote({ to: { type: 'comments', id: this.comment.id }, value: vote });
+
+ if (vote === 1) { this.comment.votes.up += 1; }
+ if (vote === -1) { this.comment.votes.down += 1; }
+ this.comment.votes.me = vote;
+ } else {
+ // we remove the vote
+ await this.model.vote({ to: { type: 'comments', id: this.comment.id }, value: 0 });
+ if (this.comment.votes.me === 1) { this.comment.votes.up -= 1; }
+ if (this.comment.votes.me === -1) { this.comment.votes.down -= 1; }
+ this.comment.votes.me = 0;
+ }
+ }
}
/**
diff --git a/src/app/ideas/idea-form/idea-form.component.scss b/src/app/ideas/idea-form/idea-form.component.scss
index e69de29..8bd6bef 100644
--- a/src/app/ideas/idea-form/idea-form.component.scss
+++ b/src/app/ideas/idea-form/idea-form.component.scss
@@ -0,0 +1,3 @@
+input {
+ width: 100%;
+}
diff --git a/src/app/ideas/read-idea/read-idea.component.html b/src/app/ideas/read-idea/read-idea.component.html
index 7e0f747..f72b1ee 100644
--- a/src/app/ideas/read-idea/read-idea.component.html
+++ b/src/app/ideas/read-idea/read-idea.component.html
@@ -1,19 +1,28 @@
-
-
-lightbulb_outline {{idea.title}}
-
-
-
+
--
-
-
-
-+-
+
+
+
+