group display of days

This commit is contained in:
Tykayn 2021-04-30 15:42:50 +02:00 committed by tykayn
parent 975997b767
commit 86c0ff815f
7 changed files with 88 additions and 48 deletions

View File

@ -51,7 +51,19 @@
Environnement de développement: voici des liens de démonstration issus des fixtures Doctrine de date-poll-api.
<div class="padded">
<div class="">
<a class="navbar-item" [routerLink]="['/poll/dessin-anime/consultation']" routerLinkActive="is-primary">
<a
class="navbar-item"
[routerLink]="['/poll/le-titre-de-demo-oh-oh/consultation']"
routerLinkActive="is-primary"
>
<em>
le-titre-de-demo-oh-oh
</em> </a
><a
class="navbar-item"
[routerLink]="['/poll/dessin-anime/consultation']"
routerLinkActive="is-primary"
>
<em>
dessin-anime
</em>

View File

@ -47,7 +47,7 @@ export class Poll {
public choices: Choice[] = [];
public choicesDateGrouped: ChoiceGroup[] = [];
public choices_grouped: ChoiceGroup[] = [];
public votes = [];

View File

@ -217,24 +217,12 @@ export class PollService implements Resolve<Poll> {
return newpoll;
}
/**
* regrouper les jours et périodes de temps
* @param choices
*/
public parseDateChoices(choices: Choice[]) {
const SEPARATOR_DATE_TIME_SLICE = ' >>> ';
const parsedChoices = [];
for (const c of choices) {
const time_list = [];
const choice = { name: c.name };
if (c.name.includes(SEPARATOR_DATE_TIME_SLICE)) {
const date_string = '';
const time_slice = '';
choice.name = time_slice;
}
parsedChoices.push({
date_string: choice,
choices: c,
});
}
console.log('parsedChoices', parsedChoices);
return [];
console.log('choices before', choices);
return choices;
}
}

View File

@ -30,7 +30,9 @@
Pour accéder au sondage et à tous ses paramètres :
<a href="{{ poll.custom_url }}">{{ poll.custom_url }} </a>
</p>
<app-copy-text [textToCopy]="poll.custom_url"></app-copy-text>
<app-copy-text
[textToCopy]="window.location.href + '/poll/' + poll.custom_url + '/consultation'"
></app-copy-text>
<a href="{{ poll.custom_url }}">
Voir le sondage coté administrateur·ice
</a>

View File

@ -116,9 +116,9 @@
</button>
</div>
<footer class="card-footer" *ngIf="!isArchived">
TODO links
</footer>
<!-- <footer class="card-footer" *ngIf="!isArchived">-->
<!-- TODO links-->
<!-- </footer>-->
</div>
</div>
</div>

View File

@ -53,7 +53,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
this.poll.is_archived = this.isArchived;
if (!environment.production) {
this.addVoteStack();
// this.addVoteStack();
}
}
});

View File

@ -1,27 +1,65 @@
{{ poll.choices.length }} choix
<div class="box" *ngFor="let choice of poll.choices">
<div class="columns is-vcentered is-mobile">
<div class="column">
<label class="label" *ngIf="poll.kind == 'text'">{{ choice.name }} </label>
<label class="label" *ngIf="poll.kind == 'date'">
{{ choice.name }} : {{ choice.name | date: 'short':'Europe/Paris':'fr_FR' }}
</label>
</div>
<div class="column is-narrow">
<span class="max_score" *ngIf="poll.max_score > 0 && choice.score == poll.max_score">
<i class="fa fa-star fa-2x"></i>
</span>
</div>
<div class="column is-narrow">
<button class="button is-white" (click)="openModal(poll, choice)">
<i class="fa fa-info-circle"></i>
</button>
</div>
<div class="column is-narrow">
<div class="buttons has-addons is-right">
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'YES'"></app-choice-button>
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'MAYBE'"></app-choice-button>
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'NO'"></app-choice-button>
<div class="date-choices" *ngIf="poll.kind == 'date'">
<div class="box" *ngFor="let group of poll.choices_grouped">
<h3 class="title is-3">
{{ group.date_string }}
</h3>
<div class="box" *ngFor="let choice of group.choices">
<div class="columns is-vcentered is-mobile">
<div class="column">
<label class="label" *ngIf="poll.kind == 'text'">{{ choice.name }} </label>
<label class="label" *ngIf="poll.kind == 'date'">
{{ choice.name }} : {{ choice.name | date: 'short':'Europe/Paris':'fr_FR' }}
</label>
</div>
<div class="column is-narrow">
<span class="max_score" *ngIf="poll.max_score > 0 && choice.score == poll.max_score">
<i class="fa fa-star fa-2x"></i>
</span>
</div>
<div class="column is-narrow">
<button class="button is-white" (click)="openModal(poll, choice)">
<i class="fa fa-info-circle"></i>
</button>
</div>
<div class="column is-narrow">
<div class="buttons has-addons is-right">
<!-- TODO limit answers possible with poll allowed_answers-->
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'YES'"></app-choice-button>
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'MAYBE'"></app-choice-button>
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'NO'"></app-choice-button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="texts" *ngIf="poll.kind == 'text'">
<div class="box" *ngFor="let choice of poll.choices">
<div class="columns is-vcentered is-mobile">
<div class="column">
<label class="label" *ngIf="poll.kind == 'text'">{{ choice.name }} </label>
<label class="label" *ngIf="poll.kind == 'date'">
{{ choice.name }} : {{ choice.name | date: 'short':'Europe/Paris':'fr_FR' }}
</label>
</div>
<div class="column is-narrow">
<span class="max_score" *ngIf="poll.max_score > 0 && choice.score == poll.max_score">
<i class="fa fa-star fa-2x"></i>
</span>
</div>
<div class="column is-narrow">
<button class="button is-white" (click)="openModal(poll, choice)">
<i class="fa fa-info-circle"></i>
</button>
</div>
<div class="column is-narrow">
<div class="buttons has-addons is-right">
<!-- TODO limit answers possible with poll allowed_answers-->
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'YES'"></app-choice-button>
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'MAYBE'"></app-choice-button>
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'NO'"></app-choice-button>
</div>
</div>
</div>
</div>