add AR lang 👽 and complete sections of consultation

This commit is contained in:
Tykayn 2022-02-07 13:58:23 +01:00 committed by tykayn
parent 4c9c691f4e
commit d8f2a718e4
15 changed files with 272 additions and 26 deletions

View File

@ -3,6 +3,7 @@
* Cette enum est utilisé dans le composant de sélection de langue. * Cette enum est utilisé dans le composant de sélection de langue.
*/ */
export enum LanguageEnum { export enum LanguageEnum {
ar = 'ar',
br = 'br', br = 'br',
ca = 'ca', ca = 'ca',
de = 'de', de = 'de',

View File

@ -1,6 +1,52 @@
<div class="step-info">
<div class="container">
<div class="columns">
<div class="column">
<a
class="logo-home-link navbar-item pull-left is-hidden-mobile"
[routerLink]="['/']"
routerLinkActive="active"
>
<img
class="stepper-app-logo logo"
*ngIf="environment.appLogo"
src="{{ environment.appLogo }}"
alt="accueil {{ environment.appTitle }}"
/>
</a>
<h1>
<span class="step-title-poll" *ngIf="pollService.step_current == 1">
{{ 'creation.title' | translate }}
</span>
<span *ngIf="pollService.step_current > 1">
<span class="step-title-poll poll-title-filled" *ngIf="pollService.form.value.title.length">
{{ pollService.form.value.title }}
</span>
<span class="step-title-poll poll-title-empty" *ngIf="!pollService.form.value.title.length">
{{ 'nav.no_title' | translate }}
</span>
</span>
</h1>
</div>
<div class="column has-text-right">
<app-language-selector class="nav-button"></app-language-selector>
<button
class="has-no-border nav-button cancel-button"
[routerLink]="'/'"
id="display_cancel_popup_button"
aria-haspopup="dialog"
>
{{ 'nav.leave' | translate }} <i class="fa fa-times"></i>
</button>
</div>
</div>
</div>
</div>
<section class="poll_loaded padded consultation" *ngIf="!fetching && poll"> <section class="poll_loaded padded consultation" *ngIf="!fetching && poll">
<div class="step"> <div class="step">
<div class="rounded-box"> <section class="main-title-poll rounded-block">
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<h2 class="title is-2"> <h2 class="title is-2">
@ -18,7 +64,51 @@
<p class="description"> <p class="description">
{{ poll.description }} {{ poll.description }}
</p> </p>
</div> <button class="vote-button is-primary button" [routerLink]="'/poll/' + poll.custom_url + '/vote'">
{{ 'participation.fav_title' | translate }}
</button>
</section>
<section class="favourite">
<h2 class="title is-3">
{{ 'participation.fav_choice' | translate }}
</h2>
<div class="rounded-block">
<div class="section no-votes">
<div class="message is-info" *ngIf="poll.stacks.length == 0">
<div class="message-body">
{{ 'participation.no_votes_yet' | translate }}
<br />
{{ 'participation.fav_description_not_exist' | translate }}
</div>
</div>
</div>
<div class="has-votes" *ngIf="poll.stacks.length !== 0">
{{ 'participation.fav_description_one' | translate: { maxYesCount: maxYesCount } }}
{{ 'participation.fav_description_several' | translate }}
</div>
</div>
</section>
<section class="poll-answers">
<h2 class="title is-3">
{{ 'participation.poll' | translate }}
</h2>
<div class="rounded-block">
<app-poll-results-dinum [poll]="poll"></app-poll-results-dinum>
</div>
</section>
<section class="poll-comments">
<h2 class="title is-3">
{{ 'participation.comments' | translate }}
</h2>
<div class="rounded-block">
<!-- *ngIf="poll.allow_comments"-->
<app-comments [poll]="poll" [vote_stack]="storageService.vote_stack"></app-comments>
<!-- <div class="alert has-background-info" *ngIf="!poll.allow_comments">-->
<!-- Ce sondage ne permet pas d'ajouter de commentaires-->
<!-- </div>-->
</div>
</section>
</div> </div>
</section> </section>
<section class="loadin_poll" *ngIf="fetching"> <section class="loadin_poll" *ngIf="fetching">

View File

@ -4,3 +4,12 @@
left: 1em; left: 1em;
z-index: 10; z-index: 10;
} }
.poll_loaded {
.title {
margin-bottom: 0;
}
.description {
min-height: 2rem;
}
}

View File

@ -8,6 +8,7 @@ import { PollUtilitiesService } from '../../core/services/poll.utilities.service
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 { ToastService } from '../../core/services/toast.service'; import { ToastService } from '../../core/services/toast.service';
import { environment } from 'src/environments/environment';
@Component({ @Component({
selector: 'app-consultation', selector: 'app-consultation',
@ -17,12 +18,14 @@ import { ToastService } from '../../core/services/toast.service';
export class ConsultationComponent implements OnInit, OnDestroy { export class ConsultationComponent implements OnInit, OnDestroy {
public fetching = true; public fetching = true;
public environment = environment;
private routeSubscription: Subscription; private routeSubscription: Subscription;
window: any; window: any;
private isArchived: boolean; private isArchived: boolean;
private poll: Poll; private poll: Poll;
private pollSlug: string; private pollSlug: string;
private pass_hash: string; private pass_hash: string;
maxYesCount: any = 1;
constructor( constructor(
private router: Router, private router: Router,

View File

@ -17,6 +17,7 @@ import { SuccessComponent } from './success/success.component';
import { AdministrationModule } from '../administration/administration.module'; import { AdministrationModule } from '../administration/administration.module';
import { EditComponent } from './edit/edit.component'; import { EditComponent } from './edit/edit.component';
import { ResultsRoundedComponent } from './results-rounded/results-rounded.component'; import { ResultsRoundedComponent } from './results-rounded/results-rounded.component';
import { PollResultsDinumComponent } from './poll-results-dinum/poll-results-dinum.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -30,6 +31,7 @@ import { ResultsRoundedComponent } from './results-rounded/results-rounded.compo
SuccessComponent, SuccessComponent,
EditComponent, EditComponent,
ResultsRoundedComponent, ResultsRoundedComponent,
PollResultsDinumComponent,
], ],
imports: [ imports: [
CommonModule, CommonModule,

View File

@ -6,6 +6,31 @@
<div class="date-choices" *ngIf="pollService.poll.kind == 'date'"> <div class="date-choices" *ngIf="pollService.poll.kind == 'date'">
<div class="box" *ngFor="let group of poll.choices_grouped"></div> <div class="box" *ngFor="let group of poll.choices_grouped"></div>
</div> </div>
<div class="rounded-block"></div> <div class="rounded-block">
<div class="time-slice-choice" *ngFor="let choice of group.choices">
<h4 class="title is-4 choice-label">
{{ choice.name }}
</h4>
<app-choice-button
[poll]="poll"
[choice]="choice"
[answerKind]="'YES'"
*ngIf="poll.allowed_answers.indexOf('yes') !== -1"
></app-choice-button>
<app-choice-button
[poll]="poll"
[choice]="choice"
[answerKind]="'MAYBE'"
*ngIf="poll.allowed_answers.indexOf('maybe') !== -1"
></app-choice-button>
<app-choice-button
[poll]="poll"
[choice]="choice"
[answerKind]="'NO'"
*ngIf="poll.allowed_answers.indexOf('no') !== -1"
></app-choice-button>
</div>
</div>
</div> </div>
<app-nav-steps [next_step_number]="2" [previous_step_number]="0"></app-nav-steps> <app-nav-steps [next_step_number]="2" [previous_step_number]="0"></app-nav-steps>

View File

@ -1,4 +1,3 @@
{{ poll.choices.length }} choix
<div class="date-choices" *ngIf="poll.kind == 'date'"> <div class="date-choices" *ngIf="poll.kind == 'date'">
<div class="box" *ngFor="let group of poll.choices_grouped"> <div class="box" *ngFor="let group of poll.choices_grouped">
<h3 class="title is-3"> <h3 class="title is-3">
@ -9,7 +8,7 @@
> >
<i class="fa fa-check-circle-o fa"></i> <i class="fa fa-check-circle-o fa"></i>
</button> </button>
{{ showAsDate(group.date_string) | date: 'fullDate':'Europe/Paris':'fr' }} {{ showAsDate(group.date_string) | date: 'fullDate':'Europe/Paris' }}
</h3> </h3>
<div class="time-slice-choice" *ngFor="let choice of group.choices"> <div class="time-slice-choice" *ngFor="let choice of group.choices">
<div class="columns is-vcentered is-mobile"> <div class="columns is-vcentered is-mobile">

View File

@ -0,0 +1,23 @@
<div class="date-choices" *ngIf="poll.kind == 'date'">
<div class="box" *ngFor="let group of poll.choices_grouped">
<h3 class="title is-3">
{{ showAsDate(group.date_string) | date: 'fullDate':'Europe/Paris' }}
</h3>
<div class="time-slice-choice" *ngFor="let choice of group.choices">
<h4 class="title is-4 choice-label">
{{ choice.name }}
</h4>
<div class="columns is-vcentered is-mobile">
<div class="column"></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">
<div class="buttons"></div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
.max_score {
color: green;
}

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PollResultsDinumComponent } from './poll-results-dinum.component';
describe('PollResultsDinumComponent', () => {
let component: PollResultsDinumComponent;
let fixture: ComponentFixture<PollResultsDinumComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [PollResultsDinumComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PollResultsDinumComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,26 @@
import { Component, Input, OnInit } from '@angular/core';
import { Poll } from '../../../core/models/poll.model';
import { Answer } from '../../../core/enums/answer.enum';
import { ModalService } from '../../../core/services/modal.service';
import { StorageService } from '../../../core/services/storage.service';
@Component({
selector: 'app-poll-results-dinum',
templateUrl: './poll-results-dinum.component.html',
styleUrls: ['./poll-results-dinum.component.scss'],
})
export class PollResultsDinumComponent implements OnInit {
@Input() public poll: Poll;
public answerEnum = Answer;
constructor(private modalService: ModalService, private storageService: StorageService) {}
ngOnInit(): void {}
toggleAnswer(choice_id: number, value: string) {
this.storageService.toggleAnswer(choice_id, value);
}
showAsDate(date_string: string) {
return new Date(date_string);
}
}

View File

@ -4,8 +4,8 @@
</div> </div>
<section class="comments-part" *ngIf="!poll.is_archived && poll.comments"> <section class="comments-part" *ngIf="!poll.is_archived && poll.comments">
<h2 class="title is-2"> <h2 class="title is-2">
<i class="fa fa-comment"></i> <!-- {{ poll.comments.length }}-->
{{ poll.comments.length }} Commentaires {{ 'participation.comments_new' | translate }}
</h2> </h2>
<article class="message" *ngFor="let comment of poll.comments"> <article class="message" *ngFor="let comment of poll.comments">
@ -14,9 +14,17 @@
<em class="cname"> {{ comment.pseudo }} </em>, <em class="cname"> {{ comment.pseudo }} </em>,
<span class="date date-days-ago"> <span class="date date-days-ago">
il y a {{
{{ calculateDaysAgoOfComment(comment.created_at) }} jours, le </span 'participation.dipslay_comments_delay'
><span class="date is-small"> | translate
: {
counter_delay: calculateDaysAgoOfComment(comment.created_at),
time_unit: 'participation.days' | translate
}
}}
{{ calculateDaysAgoOfComment(comment.created_at) }} ,
</span>
<span class="date is-small">
{{ comment.created_at | date: 'short':'Europe/Paris':'fr_FR' }} {{ comment.created_at | date: 'short':'Europe/Paris':'fr_FR' }}
</span> </span>
</p> </p>
@ -29,29 +37,31 @@
</article> </article>
</section> </section>
<section class="add-comment" *ngIf="!poll.is_archived && vote_stack.owner"> <section class="add-comment" *ngIf="!poll.is_archived && vote_stack.owner">
<h2 class="margin-top-x7">Laisser un commentaire</h2>
<article class="message"> <article class="message">
<div class="message-header"> <div class="message-header">
<div class="field"> <div class="field">
<span class="control has-icons-left has-icons-right"> <!-- <span class="control has-icons-left has-icons-right">-->
<input <!-- <input-->
type="email" <!-- type="email"-->
name="cremail" <!-- name="cremail"-->
id="email_comment" <!-- id="email_comment"-->
[(ngModel)]="vote_stack.owner.email" <!-- [(ngModel)]="vote_stack.owner.email"-->
required="required" <!-- required="required"-->
/> <!-- />-->
<span class="icon is-small is-left"> <!-- <span class="icon is-small is-left">-->
<i class="fa fa-envelope"></i> <!-- <i class="fa fa-envelope"></i>-->
</span> <!-- </span>-->
</span> <!-- </span>-->
<label for="comment_pseudo">
{{ 'participation.name_label' | translate }}
</label>
<span class="control has-icons-left"> <span class="control has-icons-left">
<input <input
type="text" type="text"
class="margin-btm-x3" class="margin-btm-x3"
name="crname" name="crname"
[(ngModel)]="vote_stack.pseudo" [(ngModel)]="vote_stack.pseudo"
id="crname" id="comment_pseudo"
required="required" required="required"
/> />
<span class="icon is-small is-left"> <span class="icon is-small is-left">
@ -65,14 +75,17 @@
<!-- <label for="cremail"><i class="fa fa-envelope" aria-hidden="true"></i> Votre email :</label>--> <!-- <label for="cremail"><i class="fa fa-envelope" aria-hidden="true"></i> Votre email :</label>-->
</div> </div>
<div class="message-body"> <div class="message-body">
<label for="comment">Votre commentaire :</label> <label for="comment">
{{ 'participation.content_label' | translate }}
</label>
<br /> <br />
<textarea name="comment" id="comment" [(ngModel)]="vote_stack.comment"> </textarea> <textarea name="comment" id="comment" [(ngModel)]="vote_stack.comment"> </textarea>
<input <input
type="submit" type="submit"
name="add-comment" name="add-comment"
class="btn btn--primary btn--outline" class="button is-primary is-fullwidth"
value="Ajouter mon commentaire ✉️" value="Ajouter mon commentaire ✉️"
(click)="addComment()" (click)="addComment()"
/> />

View File

@ -755,6 +755,7 @@
"your-vote-has-been-saved-but-please-note-you-need-to-keep-this-personalised-link-to-be-able-to-edit-": "Your vote has been saved, but please note: you need to keep this personalized link to be able to edit your vote." "your-vote-has-been-saved-but-please-note-you-need-to-keep-this-personalised-link-to-be-able-to-edit-": "Your vote has been saved, but please note: you need to keep this personalized link to be able to edit your vote."
}, },
"LANGUAGES": { "LANGUAGES": {
"AR": "Arabic",
"DE": "German", "DE": "German",
"FR": "French", "FR": "French",
"BR": "Breton", "BR": "Breton",
@ -771,6 +772,22 @@
"OC": "Occitan", "OC": "Occitan",
"SV": "Swedish" "SV": "Swedish"
}, },
"LANGUAGES_SHORT": {
"AR": "Ar",
"DE": "De",
"FR": "Fr",
"BR": "Br",
"CA": "Ca",
"EL": "el",
"ES": "Es",
"EN": "En",
"GL": "gl",
"HU": "hu",
"IT": "It",
"NL": "Nl",
"OC": "oc",
"SV": "sv"
},
"calendar_widget": { "calendar_widget": {
"startsWith": "Starts with", "startsWith": "Starts with",
"contains": "Contains", "contains": "Contains",

View File

@ -760,6 +760,7 @@
"your-vote-has-been-saved-but-please-note-you-need-to-keep-this-personalised-link-to-be-able-to-edit-": "Votre vote a bien été pris en compte, mais faites attention : ce sondage n'autorise l'édition de votre vote qu'avec le lien personnalisé suivant ; conservez-le précieusement" "your-vote-has-been-saved-but-please-note-you-need-to-keep-this-personalised-link-to-be-able-to-edit-": "Votre vote a bien été pris en compte, mais faites attention : ce sondage n'autorise l'édition de votre vote qu'avec le lien personnalisé suivant ; conservez-le précieusement"
}, },
"LANGUAGES": { "LANGUAGES": {
"AR": "Arabe",
"DE": "Allemand", "DE": "Allemand",
"FR": "Français", "FR": "Français",
"BR": "Breton", "BR": "Breton",
@ -777,6 +778,7 @@
"SV": "Suédois" "SV": "Suédois"
}, },
"LANGUAGES_SHORT": { "LANGUAGES_SHORT": {
"AR": "Ar",
"DE": "De", "DE": "De",
"FR": "Fr", "FR": "Fr",
"BR": "Br", "BR": "Br",

View File

@ -310,6 +310,15 @@ mat-checkbox {
.icon { .icon {
width: 1rem; width: 1rem;
} }
.columns {
margin-left: 0;
margin-right: 0;
margin-top: 0;
.column {
padding-left: 0;
}
}
} }
// resume de la création de sondage // resume de la création de sondage