2020-05-12 19:16:23 +02:00
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
2023-03-15 16:33:30 +01:00
|
|
|
import { MatLegacyDialogConfig as MatDialogConfig } from '@angular/material/legacy-dialog';
|
2020-05-12 19:16:23 +02:00
|
|
|
|
2020-06-12 19:17:39 +02:00
|
|
|
import { Answer } from '../../../core/enums/answer.enum';
|
2020-05-12 19:16:23 +02:00
|
|
|
import { Choice } from '../../../core/models/choice.model';
|
|
|
|
import { Poll } from '../../../core/models/poll.model';
|
|
|
|
import { ModalService } from '../../../core/services/modal.service';
|
2020-06-16 18:40:48 +02:00
|
|
|
import { ChoiceDetailsComponent } from '../../../shared/components/choice-details/choice-details.component';
|
2021-04-28 12:15:49 +02:00
|
|
|
import { StorageService } from '../../../core/services/storage.service';
|
2020-05-12 19:16:23 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-poll-results-compact',
|
|
|
|
templateUrl: './poll-results-compact.component.html',
|
|
|
|
styleUrls: ['./poll-results-compact.component.scss'],
|
|
|
|
})
|
|
|
|
export class PollResultsCompactComponent implements OnInit {
|
|
|
|
@Input() public poll: Poll;
|
2020-06-12 19:17:39 +02:00
|
|
|
public answerEnum = Answer;
|
2021-04-28 12:15:49 +02:00
|
|
|
constructor(private modalService: ModalService, private storageService: StorageService) {}
|
2020-05-12 19:16:23 +02:00
|
|
|
|
2021-04-24 12:31:34 +02:00
|
|
|
ngOnInit(): void {
|
|
|
|
console.log('this.poll', this.poll);
|
|
|
|
}
|
2020-05-12 19:16:23 +02:00
|
|
|
|
2021-04-27 12:38:12 +02:00
|
|
|
public openModal(poll: Poll, choice: Choice): void {
|
|
|
|
const config: MatDialogConfig<any> = { data: choice };
|
2020-06-16 18:40:48 +02:00
|
|
|
this.modalService.openModal<ChoiceDetailsComponent, Choice>(ChoiceDetailsComponent, config);
|
2020-05-12 19:16:23 +02:00
|
|
|
}
|
2021-04-28 12:15:49 +02:00
|
|
|
|
|
|
|
toggleAnswer(choice_id: number, value: string) {
|
|
|
|
this.storageService.toggleAnswer(choice_id, value);
|
|
|
|
}
|
2021-05-20 12:51:25 +02:00
|
|
|
|
|
|
|
showAsDate(date_string: string) {
|
|
|
|
return new Date(date_string);
|
|
|
|
}
|
2021-05-20 13:25:45 +02:00
|
|
|
|
|
|
|
toggleAllOfChoice(groupe: any) {
|
|
|
|
console.log('groupe', groupe);
|
|
|
|
|
|
|
|
if (!groupe.subSetToYes) {
|
|
|
|
this.storageService.setAllSubchoicesTo(groupe, 'yes');
|
|
|
|
groupe.subSetToYes = true;
|
|
|
|
} else {
|
|
|
|
this.storageService.setAllSubchoicesTo(groupe, '');
|
|
|
|
groupe.subSetToYes = false;
|
|
|
|
}
|
|
|
|
// savoir si on a déjà tout mis en "yes"
|
|
|
|
// si oui, on enlève toutes les réponses
|
|
|
|
// autrement on met tout à "yes"
|
|
|
|
}
|
2020-05-12 19:16:23 +02:00
|
|
|
}
|