mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
toast message on error send vote stack
This commit is contained in:
parent
9e4d5187b5
commit
765299e1c3
@ -171,39 +171,6 @@ export class PollService implements Resolve<Poll> {
|
|||||||
this.toastService.display('Les commentaires de ce sondage ont été supprimés.');
|
this.toastService.display('Les commentaires de ce sondage ont été supprimés.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public buildAnswersByChoiceLabelByPseudo(poll: Poll): Map<string, Map<string, Answer>> {
|
|
||||||
const pseudos: Set<string> = new Set();
|
|
||||||
poll.choices.forEach((choice: Choice) => {
|
|
||||||
// choice.voters.forEach((users: Set<Owner>) => {
|
|
||||||
// users.forEach((user: Owner) => {
|
|
||||||
// pseudos.add(user.pseudo);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
||||||
const list = new Map<string, Map<string, Answer>>();
|
|
||||||
pseudos.forEach((pseudo: string) => {
|
|
||||||
list.set(
|
|
||||||
pseudo,
|
|
||||||
new Map<string, Answer>(
|
|
||||||
poll.choices.map((choice: Choice) => {
|
|
||||||
return [choice.name, undefined];
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
poll.choices.forEach((choice: Choice) => {
|
|
||||||
choice.participants.forEach((users: Set<Owner>, answer: Answer) => {
|
|
||||||
users.forEach((user: Owner) => {
|
|
||||||
list.get(user.pseudo).set(choice.name, answer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
newPollFromForm(form: any): any {
|
newPollFromForm(form: any): any {
|
||||||
const newpoll = new Poll(
|
const newpoll = new Poll(
|
||||||
this.userService.getCurrentUser(),
|
this.userService.getCurrentUser(),
|
||||||
|
@ -6,12 +6,11 @@ import { ModalService } from '../../core/services/modal.service';
|
|||||||
import { PollService } from '../../core/services/poll.service';
|
import { PollService } from '../../core/services/poll.service';
|
||||||
import { DateService } from '../../core/services/date.service';
|
import { DateService } from '../../core/services/date.service';
|
||||||
import { PollUtilitiesService } from '../../core/services/poll.utilities.service';
|
import { PollUtilitiesService } from '../../core/services/poll.utilities.service';
|
||||||
import { Comment } from '../../core/models/comment.model';
|
|
||||||
import { StorageService } from '../../core/services/storage.service';
|
import { StorageService } from '../../core/services/storage.service';
|
||||||
import { ApiService } from '../../core/services/api.service';
|
import { ApiService } from '../../core/services/api.service';
|
||||||
import { Stack } from '../../core/models/stack.model';
|
import { Stack } from '../../core/models/stack.model';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { ToastService } from '../../core/services/toast.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-consultation',
|
selector: 'app-consultation',
|
||||||
@ -42,7 +41,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
public api: ApiService,
|
public api: ApiService,
|
||||||
public pollService: PollService,
|
public pollService: PollService,
|
||||||
public dateService: DateService,
|
public dateService: DateService,
|
||||||
private modalService: ModalService
|
public toastService: ToastService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -91,6 +90,8 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (resp) {
|
if (resp) {
|
||||||
this.api.getPollBySlug(this.poll.custom_url);
|
this.api.getPollBySlug(this.poll.custom_url);
|
||||||
|
} else {
|
||||||
|
this.toastService.display('erreur à la réception du nouveau vote', 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
Score
|
Score
|
||||||
</td>
|
</td>
|
||||||
<td *ngFor="let choice of poll.choices">
|
<td *ngFor="let choice of poll.choices">
|
||||||
<!-- {{choice.id}} )-->
|
|
||||||
{{ choice.score }}
|
{{ choice.score }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -9,24 +9,17 @@ import { PollService } from '../../../core/services/poll.service';
|
|||||||
templateUrl: './poll-results-detailed.component.html',
|
templateUrl: './poll-results-detailed.component.html',
|
||||||
styleUrls: ['./poll-results-detailed.component.scss'],
|
styleUrls: ['./poll-results-detailed.component.scss'],
|
||||||
})
|
})
|
||||||
export class PollResultsDetailedComponent implements OnInit {
|
export class PollResultsDetailedComponent {
|
||||||
@Input() public poll: Poll;
|
@Input() public poll: Poll;
|
||||||
|
|
||||||
constructor(private pollService: PollService) {}
|
constructor(private pollService: PollService) {}
|
||||||
|
|
||||||
ngOnInit(): void {}
|
|
||||||
|
|
||||||
public buildAnswersByChoiceLabelByPseudo(): Map<string, Map<string, Answer>> {
|
|
||||||
return this.pollService.buildAnswersByChoiceLabelByPseudo(this.poll);
|
|
||||||
}
|
|
||||||
|
|
||||||
stackHasVotesForChoice(stack, choice: any) {
|
stackHasVotesForChoice(stack, choice: any) {
|
||||||
return undefined !== stack.votes[choice];
|
return undefined !== stack.votes[choice];
|
||||||
}
|
}
|
||||||
|
|
||||||
getValue(stack, choice: any) {
|
getValue(stack, choice: any) {
|
||||||
if (this.stackHasVotesForChoice(stack, choice)) {
|
if (this.stackHasVotesForChoice(stack, choice)) {
|
||||||
console.log('stack.votes[choice.id]', stack.votes[choice]);
|
|
||||||
return stack.votes[choice].value;
|
return stack.votes[choice].value;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user