Compare commits

...

2 Commits

Author SHA1 Message Date
19453978be put steppers in creation form 2021-10-15 10:37:38 +02:00
6c30872c0e reordering creation form 2021-10-15 09:39:51 +02:00
31 changed files with 37114 additions and 10548 deletions

26078
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ import { environment } from '../../../../environments/environment';
export class HeaderComponent implements OnInit {
public _user: Observable<User> = this.userService.user;
public env = environment;
@Input() public appTitle: string = 'FramaDate Funky';
@Input() public appTitle: string = environment.appTitle ? environment.appTitle : 'FramaDate';
@Input() public appLogo: string;
mobileMenuVisible = false;

View File

@ -2,12 +2,8 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AdministrationComponent } from './administration.component';
import { NamingComponent } from './naming/naming.component';
const routes: Routes = [
{ path: '', component: AdministrationComponent },
{ path: 'naming', component: NamingComponent },
];
const routes: Routes = [{ path: '', component: AdministrationComponent }];
@NgModule({
imports: [RouterModule.forChild(routes)],

View File

@ -7,12 +7,21 @@ import { SharedModule } from '../../shared/shared.module';
import { AdministrationRoutingModule } from './administration-routing.module';
import { AdministrationComponent } from './administration.component';
import { StepperComponent } from './stepper/stepper.component';
import { NamingComponent } from './naming/naming.component';
import { FormComponent } from './form/form.component';
import { DateValueAccessorModule } from 'angular-date-value-accessor';
import { ClassicChoicesComponent } from './form/classic-choices/classic-choices.component';
import { StepOneComponent } from './form/step-one/step-one.component';
import { StepTwoComponent } from './form/step-two/step-two.component';
@NgModule({
declarations: [AdministrationComponent, StepperComponent, NamingComponent, FormComponent],
declarations: [
AdministrationComponent,
StepperComponent,
FormComponent,
ClassicChoicesComponent,
StepOneComponent,
StepTwoComponent,
],
imports: [
AdministrationRoutingModule,
CommonModule,

View File

@ -0,0 +1,67 @@
<div class="form-field">
<!-- Choisir les propositions -->
<!-- sondage classique texte -->
<h2>
{{ 'choices.title' | translate }}
</h2>
{{ 'dates.add' | translate }}
<p>
<i>
{{ 'choices.helper' | translate }}
</i>
</p>
{{ 'choices.answer_preset_1' | translate }}
{{ 'choices.add' | translate }}
{{ 'choices.continue' | translate }}
<span>
<span class="columns">
<span class="column">
<button class="btn is-primary" (click)="addChoice()">
<i class="fa fa-plus"></i>
Ajouter un choix
</button>
</span>
<span class="column pull-right">
<button class="btn is-warning" (click)="reinitChoices()">
<i class="fa fa-recycle"></i>
Réinitialiser
</button>
</span>
</span>
<p class="hint">
{{ 'creation.choices_hint' | translate }}
</p>
<span *ngFor="let choice of choices.controls; let i = index">
<div class="form-row" [formGroup]="choice">
<div class="columns">
<div class="column">
<button class="btn btn-warning" (click)="deleteChoiceField(i)">
<i class="fa fa-times"></i>
</button>
{{ i * 1 + 1 }})
</div>
<div class="column">
<label [for]="'choice_label_' + i" class="hidden">label</label>
<input
formControlName="label"
[id]="'choice_label_' + i"
placeholder="Enter a choice description"
(keyup)="keyOnChoice($event, i)"
(keyup.backspace)="deleteChoiceField(i)"
/>
<br />
<label [for]="'image_url_' + i" class="hidden">image Url</label>
<input
formControlName="imageUrl"
[id]="'image_url_' + i"
placeholder="URL de l' image"
(keyup)="keyOnChoice($event, i)"
(keyup.backspace)="deleteChoiceField(i)"
/>
</div>
</div>
</div>
</span>
</span>
</div>

View File

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

View File

@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-classic-choices',
templateUrl: './classic-choices.component.html',
styleUrls: ['./classic-choices.component.scss'],
})
export class ClassicChoicesComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

View File

@ -2,160 +2,10 @@
<h1>
{{ 'creation.title' | translate }}
</h1>
<img src="assets/img/undraw_Moving_twwf.svg" alt="image WIP" />
<button class="btn btn--warning" (click)="askInitFormDefault()">
<i class="fa fa-refresh"></i>
Tout réinitialiser
</button>
<button class="btn is-success" (click)="createPoll()">
<i class="fa fa-save"></i>
Enregistrer le sondage
</button>
<button class="btn is-default" (click)="automaticSlug()">
<i class="fa fa-save"></i>
Slug automatique
</button>
<div class="well">
{{ poll.slug }}
</div>
<div class="has-background-danger" *ngIf="!form.valid">
le formulaire est invalide
<pre>
{{ form.errors | json }}
</pre
>
</div>
<div class="dates-list">
<div class="title">
<span class="count-dates">
{{ timeList.length }}
</span>
<span class="count-dates-txt">
{{ 'dates.count_time' | translate }}
(pour chaque jour)
</span>
</div>
<div class="actions">
<button
(click)="addTime()"
*ngIf="'false' === allowSeveralHours"
class="btn btn--primary"
id="add_time_button"
>
<i class="fa fa-plus" aria-hidden="true"></i>
{{ 'dates.add_time' | translate }}
</button>
<button
(click)="removeAllTimes()"
*ngIf="'false' === allowSeveralHours"
class="btn btn--warning"
id="remove_time_button"
>
<i class="fa fa-trash" aria-hidden="true"></i>
Aucune plage horaire
</button>
<button
(click)="resetTimes()"
*ngIf="'false' === allowSeveralHours"
class="btn btn--warning"
id="reset_time_button"
>
<i class="fa fa-refresh" aria-hidden="true"></i>
réinitialiser
</button>
</div>
<div *ngIf="'false' === allowSeveralHours" class="identical-dates">
<div cdkDropList class="example-list" (cdkDropListDropped)="drop($event)">
<div *ngFor="let time of timeList; index as id" class="time-choice" cdkDrag>
<label for="timeChoices_{{ id }}">
<i class="fa fa-clock-o" aria-hidden="true"></i>
</label>
<input
[(ngModel)]="time.literal"
name="timeChoices_{{ id }}"
type="text"
id="timeChoices_{{ id }}"
/>
<button (click)="time.timeList.splice(id, 1)" class="btn btn-warning">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
</div>
</div>
</div>
<hr />
<span class="count-dates title">
{{ dateList.length }}
</span>
<span>
{{ 'dates.count_dates' | translate }}
</span>
<button class="btn btn--primary" (click)="addChoice()">
{{ 'dates.add' | translate }}
</button>
<div *ngFor="let choice of dateList; index as id" class="date-choice">
{{ id }})
<input
[(ngModel)]="choice.date_object"
name="dateChoices_{{ id }}"
id="dateChoices_{{ id }}"
useValueAsDate
type="date"
/>
<button (click)="dateList.splice(id, 1)" class="btn btn-warning">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<button (click)="addTimeToDate(choice, id)" *ngIf="'true' === allowSeveralHours" class="btn btn--primary">
{{ 'dates.add_time' | translate }}
</button>
<div *ngIf="'true' === allowSeveralHours" class="several-times">
<div *ngFor="let timeItem of choice.timeList; index as idTime" class="time-choice">
<input
[(ngModel)]="timeItem.literal"
name="dateTime_{{ id }}_Choices_{{ idTime }}"
id="dateTime_{{ id }}_Choices_{{ idTime }}"
type="text"
/>
<button (click)="choice.timeList.splice(idTime, 1)" class="btn btn-warning">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
</div>
</div>
</div>
</div>
<hr />
<form [formGroup]="form">
<div class="form-field">
<span class="pre-selector">
{{ 'creation.want' | translate }}
</span>
<div class="kind-of-poll columns">
<div class="column">
<button
class="btn-block btn"
[ngClass]="{ 'is-primary': form.controls.isAboutDate.value }"
(click)="form.controls.isAboutDate.setValue(true)"
>
<i class="fa fa-calendar"></i>
{{ 'creation.kind.date' | translate }}
</button>
</div>
<div class="column">
<button
class="btn-block btn btn-default"
[ngClass]="{ 'is-primary': !form.controls.isAboutDate.value }"
(click)="form.controls.isAboutDate.setValue(false)"
>
<i class="fa fa-stats"></i>
{{ 'creation.kind.classic' | translate }}
</button>
</div>
</div>
<app-stepper [step_current]="step_current" [step_max]="step_max"></app-stepper>
<section class="poll-title">
<span>
{{ 'creation.choose_title' | translate }}
</span>
@ -180,11 +30,169 @@
>
<i class="fa fa-close"></i>
</button>
</section>
<div class="poll-description">
<label for="descr">Description (optionnel)</label>
<span class="rich-text-toggle">
mode de saisie avancée
<i class="fa fa-text"></i><input type="checkbox" formControlName="richTextMode" />
</span>
<textarea
#description
matInput
id="descr"
placeholder="Description"
formControlName="description"
required
></textarea>
<div class="text-info">
300 caractères maximum
</div>
<button
mat-button
*ngIf="description.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="description.value = ''"
>
<i class="fa fa-close"></i>
</button>
</div>
<fieldset class="date-kind">
<!-- choix spécialement pour les dates-->
</fieldset>
<hr />
<app-stepper [step_current]="2" [step_max]="step_max"></app-stepper>
<div class="form-field poll-kind">
<h2 class="title is-2">
{{ 'creation.want' | translate }}
</h2>
<div class="kind-of-poll columns">
<div class="column">
<button
class="btn-block btn"
[ngClass]="{ 'is-primary': form.controls.isAboutDate.value }"
(click)="form.controls.isAboutDate.setValue(true)"
>
<i class="fa fa-calendar"></i>
{{ 'creation.kind.date' | translate }}
</button>
</div>
<div class="column">
<button
class="btn-block btn btn-default"
[ngClass]="{ 'is-primary': !form.controls.isAboutDate.value }"
(click)="form.controls.isAboutDate.setValue(false)"
>
<i class="fa fa-list-ul"></i>
{{ 'creation.kind.classic' | translate }}
</button>
</div>
</div>
</div>
<!-- choix spécialement pour les dates-->
<div class="dates-list">
<div class="title">
<span class="count-dates">
{{ timeList.length }}
</span>
<span class="count-dates-txt">
{{ 'dates.count_time' | translate }}
(pour chaque jour)
</span>
</div>
<div class="actions">
<button
(click)="addTime()"
*ngIf="'false' === allowSeveralHours"
class="btn btn--primary"
id="add_time_button"
>
<i class="fa fa-plus" aria-hidden="true"></i>
{{ 'dates.add_time' | translate }}
</button>
<button
(click)="removeAllTimes()"
*ngIf="'false' === allowSeveralHours"
class="btn btn--warning"
id="remove_time_button"
>
<i class="fa fa-trash" aria-hidden="true"></i>
Aucune plage horaire
</button>
<button
(click)="resetTimes()"
*ngIf="'false' === allowSeveralHours"
class="btn btn--warning"
id="reset_time_button"
>
<i class="fa fa-refresh" aria-hidden="true"></i>
réinitialiser
</button>
</div>
<div *ngIf="'false' === allowSeveralHours" class="identical-dates">
<div cdkDropList class="example-list" (cdkDropListDropped)="drop($event)">
<div *ngFor="let time of timeList; index as id" class="time-choice" cdkDrag>
<label for="timeChoices_{{ id }}">
<i class="fa fa-clock-o" aria-hidden="true"></i>
</label>
<input
[(ngModel)]="time.literal"
name="timeChoices_{{ id }}"
type="text"
id="timeChoices_{{ id }}"
/>
<button (click)="time.timeList.splice(id, 1)" class="btn btn-warning">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
</div>
</div>
</div>
<hr />
<span class="count-dates title">
{{ dateList.length }}
</span>
<span>
{{ 'dates.count_dates' | translate }}
</span>
<button class="btn btn--primary" (click)="addChoice()">
{{ 'dates.add' | translate }}
</button>
<div *ngFor="let choice of dateList; index as id" class="date-choice">
<input
[(ngModel)]="choice.date_object"
name="dateChoices_{{ id }}"
id="dateChoices_{{ id }}"
useValueAsDate
type="date"
/>
<button (click)="dateList.splice(id, 1)" class="btn btn-warning">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<button
(click)="addTimeToDate(choice, id)"
*ngIf="'true' === allowSeveralHours"
class="btn btn--primary"
>
{{ 'dates.add_time' | translate }}
</button>
<div *ngIf="'true' === allowSeveralHours" class="several-times">
<div *ngFor="let timeItem of choice.timeList; index as idTime" class="time-choice">
<input
[(ngModel)]="timeItem.literal"
name="dateTime_{{ id }}_Choices_{{ idTime }}"
id="dateTime_{{ id }}_Choices_{{ idTime }}"
type="text"
/>
<button (click)="choice.timeList.splice(idTime, 1)" class="btn btn-warning">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
</div>
</div>
</div>
</div>
<button
(click)="showDateInterval = !showDateInterval"
@ -221,76 +229,11 @@
{{ intervalDays }}
{{ 'dates.interval_button_dates' | translate }}
</button>
<hr />
</section>
<div class="form-field">
<h2>
{{ 'choices.title' | translate }}
</h2>
{{ 'dates.add' | translate }}
<p>
<i>
{{ 'choices.helper' | translate }}
</i>
</p>
{{ 'choices.answer_preset_1' | translate }}
{{ 'choices.add' | translate }}
{{ 'choices.continue' | translate }}
<span>
<span class="columns">
<span class="column">
<button class="btn is-primary" (click)="addChoice()">
<i class="fa fa-plus"></i>
Ajouter un choix
</button>
</span>
<span class="column pull-right">
<button class="btn is-warning" (click)="reinitChoices()">
<i class="fa fa-recycle"></i>
Réinitialiser
</button>
</span>
</span>
<app-stepper [step_current]="3" [step_max]="step_max"></app-stepper>
<p class="hint">
{{ 'creation.choices_hint' | translate }}
</p>
<span *ngFor="let choice of choices.controls; let i = index">
<div class="form-row" [formGroup]="choice">
<div class="columns">
<div class="column">
<button class="btn btn-warning" (click)="deleteChoiceField(i)">
<i class="fa fa-times"></i>
</button>
{{ i * 1 + 1 }})
</div>
<div class="column">
<label [for]="'choice_label_' + i" class="hidden">label</label>
<input
formControlName="label"
[id]="'choice_label_' + i"
placeholder="Enter a choice description"
(keyup)="keyOnChoice($event, i)"
(keyup.backspace)="deleteChoiceField(i)"
/>
<br />
<label [for]="'image_url_' + i" class="hidden">image Url</label>
<input
formControlName="imageUrl"
[id]="'image_url_' + i"
placeholder="URL de l' image"
(keyup)="keyOnChoice($event, i)"
(keyup.backspace)="deleteChoiceField(i)"
/>
</div>
</div>
</div>
</span>
</span>
</div>
<div>
<div class="creator-infos">
<label class="" for="creatorEmail">
<span>
{{ 'creation.name' | translate }}
@ -312,110 +255,118 @@
/>
</div>
<br />
<button class="btn is-info" (click)="advancedDisplayEnabled = !advancedDisplayEnabled">
<i class="fa fa-save"></i>
{{ 'creation.advanced' | translate }}
</button>
<hr />
<app-stepper [step_current]="4" [step_max]="step_max"></app-stepper>
<fieldset class="complete well" *ngIf="advancedDisplayEnabled">
<h2>{{ 'creation.advanced' | translate }}</h2>
<label for="descr">Description (optionnel)</label>
<textarea
#description
matInput
id="descr"
placeholder="Description"
formControlName="description"
required
></textarea>
<button
mat-button
*ngIf="description.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="description.value = ''"
>
<i class="fa fa-close"></i>
<fieldset class="advanced-config">
<button class="btn is-info" (click)="advancedDisplayEnabled = !advancedDisplayEnabled">
<i class="fa fa-save"></i>
{{ 'creation.advanced' | translate }}
</button>
<fieldset class="complete well" *ngIf="advancedDisplayEnabled">
<h2>{{ 'creation.advanced' | translate }}</h2>
<br />
<br />
<label for="slug"
>Url pour les participants
<label for="slug">Url pour les participants </label>
<br />
<span
>{{ urlPrefix }} <strong> {{ form.controls.slug.value }} </strong>
</span>
<app-copy-text [textToCopy]="urlPrefix + form.controls.slug.value"></app-copy-text>
<i class="fa fa-close"></i>
</label>
<br />
<span
>{{ urlPrefix }}
<strong>
{{ form.controls.slug.value }}
</strong>
</span>
<app-copy-text [textToCopy]="form.controls.slug.value"></app-copy-text>
<button
mat-button
*ngIf="form.controls.slug.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="slug.value = ''"
></button>
<input #slug matInput id="slug" placeholder="Url" formControlName="slug" required />
<br />
<div appearance="outline" class="is-not-flex">
<mat-label>Nombre de jours avant expiration</mat-label>
<input
#expiracy
id="expiracy"
matInput
type="number"
placeholder="Nombre de jours avant expiration"
formControlName="expiracyNumberOfDays"
required
/>
<button
mat-button
*ngIf="expiracy.value"
*ngIf="form.controls.slug.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="expiracy.value = ''"
>
<i class="fa fa-close"></i>
</button>
</div>
<mat-checkbox class="is-not-flex" formControlName="areResultsPublic">
Les participants pourront consulter les résultats
</mat-checkbox>
<mat-checkbox class="is-not-flex" formControlName="isAboutDate">
Les choix possibles concerneront des dates
</mat-checkbox>
<mat-checkbox class="is-not-flex" formControlName="isProtectedByPassword">
Le sondage sera protégé par un mot de passe
</mat-checkbox>
<mat-checkbox class="is-not-flex" formControlName="isOwnerNotifiedByEmailOnNewVote">
Vous recevrez un mail à chaque nouvelle participation
</mat-checkbox>
<mat-checkbox class="is-not-flex" formControlName="isOwnerNotifiedByEmailOnNewComment">
Vous recevrez un mail à chaque nouveau commentaire
</mat-checkbox>
<mat-checkbox class="is-not-flex" formControlName="isMaybeAnswerAvailable">
La réponse « peut-être » sera disponible
</mat-checkbox>
(click)="slug.value = ''"
></button>
<input #slug matInput id="slug" placeholder="Url" formControlName="slug" required />
<br />
<div appearance="outline" class="is-not-flex">
<mat-label>Nombre de jours avant expiration</mat-label>
<input
#expiracy
id="expiracy"
matInput
type="number"
placeholder="Nombre de jours avant expiration"
formControlName="expiracyNumberOfDays"
required
/>
<button
mat-button
*ngIf="expiracy.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="expiracy.value = ''"
>
<i class="fa fa-close"></i>
</button>
</div>
<br />
<mat-checkbox class="is-not-flex" formControlName="areResultsPublic">
Les participants pourront consulter les résultats
</mat-checkbox>
<br />
<mat-checkbox class="is-not-flex" formControlName="isAboutDate">
Les choix possibles concerneront des dates
</mat-checkbox>
<br />
<mat-checkbox class="is-not-flex" formControlName="isProtectedByPassword">
Le sondage sera protégé par un mot de passe
</mat-checkbox>
<br />
<mat-checkbox class="is-not-flex" formControlName="isOwnerNotifiedByEmailOnNewVote">
Vous recevrez un mail à chaque nouvelle participation
</mat-checkbox>
<br />
<mat-checkbox class="is-not-flex" formControlName="isOwnerNotifiedByEmailOnNewComment">
Vous recevrez un mail à chaque nouveau commentaire
</mat-checkbox>
<br />
<mat-checkbox class="is-not-flex" formControlName="isMaybeAnswerAvailable">
La réponse « peut-être » sera disponible
</mat-checkbox>
</fieldset>
</fieldset>
<hr />
<app-stepper [step_current]="5" [step_max]="step_max"></app-stepper>
<div class="columns">
<div class="column"></div>
<div class="column">
<button class="btn is-success" (click)="createPoll()" [disabled]="!form.valid || !form.valid">
<button class="btn is-primary" (click)="createPoll()" [disabled]="!form.valid || !form.valid">
<i class="fa fa-save"></i>
Enregistrer le sondage
</button>
</div>
</div>
<section class="supplement">
<img src="assets/img/undraw_Moving_twwf.svg" alt="image WIP" />
<button class="btn btn--warning" (click)="askInitFormDefault()">
<i class="fa fa-refresh"></i>
Tout réinitialiser
</button>
<button class="btn is-success" (click)="createPoll()">
<i class="fa fa-save"></i>
Enregistrer le sondage
</button>
<button class="btn is-default" (click)="automaticSlug()">
<i class="fa fa-save"></i>
Slug automatique
</button>
<div class="well">
{{ poll.slug }}
</div>
<div class="has-background-danger" *ngIf="!form.valid">
le formulaire est invalide
<pre> {{ form.errors | json }}</pre>
</div>
</section>
</form>
</div>

View File

@ -1,12 +1,5 @@
@import '../../../../styles/variables';
:host {
input,
textarea {
padding: 0.5em;
border: solid #eee;
width: 90%;
}
.form-field {
display: block;
margin-top: 1em;
@ -14,11 +7,7 @@
.form-row {
margin-top: 0.5em;
margin-bottom: 0.25em;
border: solid 1px #ddd;
border-left: solid 3px $primary_color;
padding-left: 1em;
padding-top: 0.5em;
padding-bottom: 0.5em;
}
.fa {
margin-right: 1ch;
@ -75,12 +64,10 @@
.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder) {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
.ng-touched.ng-invalid {
border-left: $danger 3px solid;
padding-left: 1em;
}
.ng-touched.ng-valid {
border-left: $success 3px solid;
padding-left: 1em;
textarea {
border: solid 1px $border-color;
width: 100%;
display: block;
}
}

View File

@ -7,7 +7,7 @@ import { ToastService } from '../../../core/services/toast.service';
import { PollService } from '../../../core/services/poll.service';
import { DateUtilities } from '../../old-stuff/config/DateUtilities';
import { DOCUMENT } from '@angular/common';
import { DateChoice, otherDefaultDates } from '../../old-stuff/config/defaultConfigs';
import { DateChoice, defaultTimeOfDay, otherDefaultDates } from '../../old-stuff/config/defaultConfigs';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
@Component({
@ -22,14 +22,18 @@ export class FormComponent implements OnInit {
public urlPrefix: string = window.location.origin + '/participation/';
public advancedDisplayEnabled = false;
public showDateInterval = true;
public allowSeveralHours = true;
public showDateInterval = false;
public allowSeveralHours = false;
public richTextMode = false;
startDateInterval: string;
endDateInterval: string;
intervalDays: any;
intervalDaysDefault = 7;
dateList: any = otherDefaultDates; // sets of days as strings, config to set identical time for days in a special days poll
timeList: DateChoice[] = otherDefaultDates; // ranges of time expressed as strings
dateList: DateChoice[] = otherDefaultDates; // sets of days as strings, config to set identical time for days in a special days poll
timeList: any = defaultTimeOfDay; // ranges of time expressed as strings
step_current: number = 1;
step_max: number = 5;
public round: Function;
constructor(
private fb: FormBuilder,
@ -50,8 +54,6 @@ export class FormComponent implements OnInit {
ngOnInit(): void {
this.initFormDefault();
// TO remove after
// this.createPoll();
const pollsAvailable = this.pollService.getAllAvailablePolls();
console.log('pollsAvailable', pollsAvailable);
}
@ -61,14 +63,6 @@ export class FormComponent implements OnInit {
const newpoll = this.pollService.newPollFromForm(this.form);
console.log('newpoll', newpoll);
this.apiService.createPoll(newpoll);
// if (this.form.valid) {
// console.log('Le sondage est correctement rempli, prêt à enregistrer.');
// const newpoll = this.pollService.newPollFromForm(this.form);
// // TODO : save the poll
// this.apiService.createPoll(newpoll);
// } else {
// this.toastService.display('invalid form');
// }
}
public updateSlug(): void {
@ -131,6 +125,7 @@ export class FormComponent implements OnInit {
isOwnerNotifiedByEmailOnNewComment: [false, [Validators.required]],
isMaybeAnswerAvailable: [false, [Validators.required]],
areResultsPublic: [true, [Validators.required]],
richTextMode: [false, [Validators.required]],
expiracyNumberOfDays: [60, [Validators.required, Validators.min(0)]],
});
console.log('this.form ', this.form);
@ -180,6 +175,7 @@ export class FormComponent implements OnInit {
isOwnerNotifiedByEmailOnNewVote: false,
isOwnerNotifiedByEmailOnNewComment: false,
isMaybeAnswerAvailable: false,
richTextMode: false,
areResultsPublic: true,
expiracyNumberOfDays: 60,
});
@ -223,14 +219,6 @@ export class FormComponent implements OnInit {
this.showDateInterval = false;
this.form.patchValue({ choices: this.dateList });
// this.dateList.forEach(elem=>{
// const newControlGroup = this.fb.group({
// label: this.fb.control('', [Validators.required]),
// imageUrl: ['', [Validators.required]],
// });
//
// this.choices.push(newControlGroup);
// })
this.toastService.display(`les dates ont été ajoutées aux réponses possibles.`);
}

View File

@ -0,0 +1,3 @@
<div class="step">
Nom de sondage
</div>

View File

@ -1,19 +1,19 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NamingComponent } from './naming.component';
import { StepOneComponent } from './step-one.component';
describe('NamingComponent', () => {
let component: NamingComponent;
let fixture: ComponentFixture<NamingComponent>;
describe('StepOneComponent', () => {
let component: StepOneComponent;
let fixture: ComponentFixture<StepOneComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [NamingComponent],
declarations: [StepOneComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NamingComponent);
fixture = TestBed.createComponent(StepOneComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-step-one',
templateUrl: './step-one.component.html',
styleUrls: ['./step-one.component.scss'],
})
export class StepOneComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

View File

@ -0,0 +1 @@
<p>step-two works!</p>

View File

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

View File

@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-step-two',
templateUrl: './step-two.component.html',
styleUrls: ['./step-two.component.scss'],
})
export class StepTwoComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

View File

@ -1 +0,0 @@
<p>naming works!</p>

View File

@ -1,12 +0,0 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-naming',
templateUrl: './naming.component.html',
styleUrls: ['./naming.component.scss'],
})
export class NamingComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

View File

@ -1,114 +1,11 @@
<mat-vertical-stepper #stepper linear>
<mat-step [stepControl]="pollFormGroup" class="is-expanded">
<form [formGroup]="pollFormGroup">
<ng-template matStepLabel>Informations du sondage</ng-template>
<mat-form-field appearance="outline">
<mat-label>Titre</mat-label>
<input #title matInput placeholder="Question posée, sujet" formControlName="title" required />
</mat-form-field>
<mat-form-field appearance="outline" class="is-flex">
<mat-label>Description</mat-label>
<textarea
#description
matInput
placeholder="Description"
formControlName="description"
required
></textarea>
<button
mat-button
*ngIf="description.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="description.value = ''"
>
<i class="fa fa-close"></i>
</button>
</mat-form-field>
<mat-form-field appearance="outline" class="is-flex">
<mat-label>Url pour les participants</mat-label>
<span matPrefix>{{ urlPrefix }}</span>
<input #slug matInput placeholder="Url" formControlName="slug" required />
<button
mat-button
*ngIf="slug.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="slug.value = ''"
>
<i class="fa fa-close"></i>
</button>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step [stepControl]="configurationFormGroup">
<form [formGroup]="configurationFormGroup">
<ng-template matStepLabel>PollConfiguration du sondage</ng-template>
<mat-form-field appearance="outline" class="is-flex">
<mat-label>Nombre de jours avant expiration</mat-label>
<input
#expiracy
matInput
type="number"
placeholder="Nombre de jours avant expiration"
formControlName="expiracyNumberOfDays"
required
/>
<button
mat-button
*ngIf="expiracy.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="expiracy.value = ''"
>
<i class="fa fa-close"></i>
</button>
</mat-form-field>
<mat-checkbox class="is-flex" formControlName="areResultsPublic">
Les participants pourront consulter les résultats
</mat-checkbox>
<mat-checkbox class="is-flex" formControlName="isAboutDate">
Les choix possibles concerneront des dates
</mat-checkbox>
<mat-checkbox class="is-flex" formControlName="isProtectedByPassword">
Le sondage sera protégé par un mot de passe
</mat-checkbox>
<mat-checkbox class="is-flex" formControlName="isOwnerNotifiedByEmailOnNewVote">
Vous recevrez un mail à chaque nouvelle participation
</mat-checkbox>
<mat-checkbox class="is-flex" formControlName="isOwnerNotifiedByEmailOnNewComment">
Vous recevrez un mail à chaque nouveau commentaire
</mat-checkbox>
<mat-checkbox class="is-flex" formControlName="isMaybeAnswerAvailable">
La réponse « peut-être » sera disponible
</mat-checkbox>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step>
<ng-template matStepLabel>Done</ng-template>
<p>You are now done.</p>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
<div>
<button mat-button (click)="savePoll()" [disabled]="!pollFormGroup.valid || !configurationFormGroup.valid">
Enregistrer le sondage
</button>
</div>
</mat-step>
</mat-vertical-stepper>
<section class="creation-stepper">
<div class="step-info">
<h2 class="title is-2">
Étape {{ step_current }} /
{{ step_max }}
</h2>
</div>
<div class="step-bar-container" style="width: 100%;">
<div class="step-bar-progress" [ngStyle]="{ width: (step_current / step_max) * 100 + '%' }"></div>
</div>
</section>

View File

@ -0,0 +1,19 @@
@import '../../../../styles/variables';
.step-bar-container {
margin: 1em 0;
height: 0.5em;
display: inline-block;
min-width: 1px;
background: $grey-light;
width: 100%;
}
.step-bar-progress {
position: relative;
top: -0.6em;
left: 0;
height: 0.5em;
display: inline-block;
min-width: 1px;
background: $primary;
}

View File

@ -1,65 +1,13 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Poll } from '../../../core/models/poll.model';
import { UuidService } from '../../../core/services/uuid.service';
import { DateService } from '../../../core/services/date.service';
@Component({
selector: 'app-stepper',
templateUrl: './stepper.component.html',
styleUrls: ['./stepper.component.scss'],
})
export class StepperComponent implements OnInit {
export class StepperComponent {
@Input()
public poll?: Poll;
public pollFormGroup: FormGroup;
public configurationFormGroup: FormGroup;
public choicesFormGroup: FormGroup;
public urlPrefix: string = window.location.origin + '/participation/';
constructor(private fb: FormBuilder, private uuidService: UuidService) {}
ngOnInit(): void {
this.pollFormGroup = this.fb.group({
question: [this.poll ? this.poll.title : '', [Validators.required]],
slug: [this.poll ? this.poll.slug : this.uuidService.getUUID(), [Validators.required]],
description: [this.poll ? this.poll.description : ''],
});
this.configurationFormGroup = this.fb.group({
title: [this.poll ? this.poll.configuration : false, [Validators.required]],
isAboutDate: [this.poll ? this.poll.configuration.isAboutDate : false, [Validators.required]],
isProtectedByPassword: [
this.poll ? this.poll.configuration.isProtectedByPassword : false,
[Validators.required],
],
isOwnerNotifiedByEmailOnNewVote: [
this.poll ? this.poll.configuration.isOwnerNotifiedByEmailOnNewVote : false,
[Validators.required],
],
isOwnerNotifiedByEmailOnNewComment: [
this.poll ? this.poll.configuration.isOwnerNotifiedByEmailOnNewComment : false,
[Validators.required],
],
isMaybeAnswerAvailable: [
this.poll ? this.poll.configuration.isMaybeAnswerAvailable : false,
[Validators.required],
],
areResultsPublic: [this.poll ? this.poll.configuration.areResultsPublic : true, [Validators.required]],
expiracyNumberOfDays: [
this.poll ? DateService.diffInDays(new Date(), this.poll.configuration.expires) : 60,
[Validators.required],
],
});
}
public savePoll(): void {
if (this.pollFormGroup.valid && this.configurationFormGroup.valid) {
console.log('Le sondage est correctement rempli, prêt à enregistrer.');
// TODO : save the poll
}
}
public step_current: number = 1;
@Input()
public step_max: number = 5;
}

View File

@ -1,10 +1,10 @@
export interface DateChoice {
literal: string;
timeList: TimeSlices[];
timeList: TimeChoice[];
date_object: Date;
}
export interface TimeSlices {
export interface TimeChoice {
literal: string;
}
@ -15,27 +15,27 @@ export interface PollAnswer {
file: string;
literal: string;
date_object: Date;
timeList: TimeSlices[];
timeList: TimeChoice[];
}
const currentYear = new Date().getFullYear();
const currentMonth = new Date().getMonth();
const currentDay = new Date().getDate();
export const basicSlicesOfDay: TimeSlices[] = [{ literal: 'matin' }, { literal: 'midi' }, { literal: 'soir' }];
export const otherSlicesOfDay: TimeSlices[] = [
export const basicSlicesOfDay: TimeChoice[] = [{ literal: 'matin' }, { literal: 'midi' }, { literal: 'soir' }];
export const otherSlicesOfDay: TimeChoice[] = [
{ literal: 'aux aurores' },
{ literal: 'au petit dej' },
{ literal: 'au deuxième petit dej des hobbits' },
];
export const defaultTimeOfDay: TimeSlices[] = (() => {
export const defaultTimeOfDay: TimeChoice[] = (() => {
return [...basicSlicesOfDay];
})();
export const otherTimeOfDay: TimeSlices[] = (() => {
export const otherTimeOfDay: TimeChoice[] = (() => {
return [...otherSlicesOfDay];
})();
export const moreTimeOfDay: TimeSlices[] = (() => {
export const moreTimeOfDay: TimeChoice[] = (() => {
return [...otherSlicesOfDay];
})();
export const defaultDates: DateChoice[] = [

View File

@ -16,7 +16,7 @@ const apiV1 = {
export const environment = {
production: false,
appTitle: 'FramaDate Funky',
appTitle: 'FramaDate',
appVersion: '2.0.0',
appLogo: 'assets/img/logo.png',
api: {

View File

@ -11,3 +11,62 @@ $body-background-color: $black;
$control-border-width: 2px;
$input-border-color: transparent;
$input-shadow: none;
// bulma css override
$colors: mergeColorMaps(
(
'white': (
$white,
$black,
),
'black': (
$black,
$white,
),
'light': (
$light,
$light-invert,
),
'dark': (
$dark,
$dark-invert,
),
'primary': (
$primary,
$primary-invert,
$primary-light,
$primary-dark,
),
'link': (
$link,
$link-invert,
$link-light,
$link-dark,
),
'info': (
$info,
$info-invert,
$info-light,
$info-dark,
),
'success': (
$success,
$success-invert,
$success-light,
$success-dark,
),
'warning': (
$warning,
$warning-invert,
$warning-light,
$warning-dark,
),
'danger': (
$danger,
$danger-invert,
$danger-light,
$danger-dark,
),
),
$custom-colors
);

View File

@ -3,7 +3,6 @@ select,
textarea {
@extend .clickable;
margin-bottom: 0.25rem;
border-bottom: 2px solid $primary_color;
padding: 0.5rem;
&:active,
@ -13,44 +12,10 @@ textarea {
}
}
select,
option {
-webkit-appearance: none;
-moz-appearance: none;
border-radius: 0;
background-color: transparent;
background-image: url('/assets/img/fleche_bas.svg');
padding-right: 2.5rem;
background-repeat: no-repeat;
background-size: 9px 8px;
background-position: right 1rem center;
background-clip: border-box;
min-width: 10rem;
}
select {
@extend .select, .input;
}
#multi_hours select {
min-width: 300px !important;
}
input {
@extend .input, .text-ellipsis;
}
label {
margin-top: 0.5rem;
}
textarea {
min-height: 3em;
width: 100%;
max-width: 100%;
min-height: 213px;
padding: 0.5em 1em;
margin-bottom: 1em;
border-left: 3px solid $primary_color;
display: block;
}
.comment {

View File

@ -30,9 +30,9 @@ input {
input,
select,
textarea {
width: 100%;
padding: 1rem;
border: 1px solid $secondary_color;
border-bottom: 3px solid $primary_color;
border: 1px solid $border-color;
}
input,
@ -71,3 +71,8 @@ li {
button[type='submit'] {
margin-top: 2em;
}
hr {
margin: 4em 0;
border: solid 3px $primary;
}

View File

@ -48,8 +48,9 @@ $logo_color_2: $d-primary-intense;
$legend_color: $d-info-text;
$legend_color_2: $d-info;
$choice_select_border_color: $d-info;
$hover-color: $warm-grey;
$grey-dark: $warm-grey;
$hover-color: $d-neutral;
$border-color: $d-neutral;
$grey-dark: $d-primary;
$grey-light: $beige-light;
$clicked-color: $d-primary;
$mini-button-color: $d-primary-intense;
@ -57,6 +58,5 @@ $warning: $d-warning;
$danger: $d-error;
$success: $d-success;
// FONT
$default_font: 'pt_sans';
$title_font: 'proza_libre', 'Brie Light', 'Arial', 'DejaVu Sans Mono';

20426
yarn.lock

File diff suppressed because it is too large Load Diff