diff --git a/src/app/components/stream/status/poll/poll.component.html b/src/app/components/stream/status/poll/poll.component.html
index a7e25b38..02892c5d 100644
--- a/src/app/components/stream/status/poll/poll.component.html
+++ b/src/app/components/stream/status/poll/poll.component.html
@@ -1,16 +1,17 @@
-
\ No newline at end of file
diff --git a/src/app/components/stream/status/poll/poll.component.ts b/src/app/components/stream/status/poll/poll.component.ts
index 77409030..c62c7e5d 100644
--- a/src/app/components/stream/status/poll/poll.component.ts
+++ b/src/app/components/stream/status/poll/poll.component.ts
@@ -1,6 +1,7 @@
import { Component, OnInit, Input } from '@angular/core';
-import { Poll } from '../../../../services/models/mastodon.interfaces';
+import { Poll, PollOption } from '../../../../services/models/mastodon.interfaces';
+import { AccountInfo } from '../../../../states/accounts.state';
@Component({
selector: 'app-poll',
@@ -8,22 +9,66 @@ import { Poll } from '../../../../services/models/mastodon.interfaces';
styleUrls: ['./poll.component.scss']
})
export class PollComponent implements OnInit {
- pollName: string;
+ pollName: string;
+ choiceType: string;
- choiceType: string;// = 'radio';
- //choiceType: string = 'checkbox';
+ private pollSelection: number[] = [];
+ options: PollOptionWrapper[] = [];
@Input() poll: Poll;
+ @Input() provider: AccountInfo;
constructor() { }
ngOnInit() {
this.pollName = this.poll.id;
+
+ // this.poll.multiple = true;
+
if(this.poll.multiple){
this.choiceType = 'checkbox';
} else {
this.choiceType = 'radio';
}
+
+ let i = 0;
+ for(let opt of this.poll.options){
+ let optWrapper = new PollOptionWrapper(i, opt);
+ this.options.push(optWrapper);
+ i++;
+ }
+ }
+
+ vote(): boolean {
+ console.log(this.pollSelection);
+
+ return false;
+ }
+
+ onSelectionChange(entry: PollOptionWrapper){
+ let index = entry.id;
+ if(this.poll.multiple){
+ if(this.pollSelection.includes(index)){
+ this.pollSelection = this.pollSelection.filter(x => x !== index);
+ } else {
+ this.pollSelection.push(index);
+ }
+ } else {
+ this.pollSelection.length = 0;
+ this.pollSelection.push(index);
+ }
}
}
+
+class PollOptionWrapper implements PollOption {
+ constructor(index: number, option: PollOption){
+ this.id = index;
+ this.title = option.title;
+ this.votes_count = option.votes_count;
+ }
+
+ id: number;
+ title: string;
+ votes_count: number;
+}
\ No newline at end of file
diff --git a/src/app/components/stream/status/status.component.html b/src/app/components/stream/status/status.component.html
index 1dfa129b..f3ac3722 100644
--- a/src/app/components/stream/status/status.component.html
+++ b/src/app/components/stream/status/status.component.html
@@ -67,7 +67,8 @@
(accountSelected)="accountSelected($event)" (hashtagSelected)="hashtagSelected($event)"
(textSelected)="textSelected()">
-
+