sync answers

This commit is contained in:
tykayn 2019-08-10 18:14:00 +02:00
parent 49f4b4c13b
commit d413774d3b
6 changed files with 88 additions and 68 deletions

View File

@ -20,17 +20,19 @@ export class PollConfig {
// date specific poll // date specific poll
allowSeveralHours = false; allowSeveralHours = false;
dateList: DateOption[] = []; dateList: DateOption[] = [];
answers: string[] = []; answers: any = [{
id: 0,
text: 'réponse de démo 1'
},
addAnswer() { {
this.answers.push(''); id: 1,
} text: 'réponse 2'
},
{
id: 2,
text: 'la réponse D'
}];
removeAnswer(answer: string) {
const indexFound = this.answers.indexOf(answer);
if (indexFound !== -1) {
this.answers.splice(indexFound);
}
}
} }

View File

@ -46,7 +46,7 @@
</div> </div>
<a <a
[routerLink]="'/step/kind'" [routerLink]="'/step/answers'"
class="btn striked" class="btn striked"
i18n="start_form"> i18n="start_form">
C'est parti C'est parti

View File

@ -1,15 +1,27 @@
<h1 i18n> <div class="answers">
Choisir les propositions
</h1> <h1 i18n>
<p class="subtitle" i18n> Choisir les propositions
vous pouvez utiliser la syntaxe markdown </h1>
</p> <p class="subtitle" i18n>
<ol vous pouvez utiliser la syntaxe markdown
*ngFor="let answer of config.answers" </p>
class="anwser"> <ol>
<li> <li #answers *ngFor="let answer of config.answers; index as i;trackBy trackFunction"
<input type="text" [(ngModel)]="answer" (keydown)="addWhenEnterKey($event)"> class="anwser">
<button (click)="config.removeAnswer(answer)">X</button> <input
</li> type="text"
</ol> [(ngModel)]="answer.text"
<a [routerLink]="'/step/recapitulatif'" class="btn btn-block">Voyons ce que ça donne</a> placeholder="réponse"
>
<button (click)="config.answers.splice(i,1)">X</button>
</li>
</ol>
<button
class="btn-outline btn-block"
(click)="config.answers.push({id:config.answers.length+1,text:''})">
Ajouter
</button>
<a [routerLink]="'/step/recapitulatif'" class="btn btn-block">Voyons ce que ça donne</a>
</div>

View File

@ -9,18 +9,25 @@ import {ConfigService} from '../../config.service';
}) })
export class AnswersComponent extends BaseComponent implements OnInit { export class AnswersComponent extends BaseComponent implements OnInit {
private answerList=[];
constructor(config: ConfigService) { constructor(config: ConfigService) {
super(config); super(config);
this.answerList = this.config.answers;
} }
// todo, manage validation of each page in a common way // todo, manage validation of each page in a common way
ngOnInit() { ngOnInit() {
} }
trackFunction(index: number, item: any): number { return item.id; }
// add a new answer on the press of ENTER in an input // add a new answer on the press of ENTER in an input
addWhenEnterKey(event) { addWhenEnterKey(event) {
console.log('event', event);
if (event.keyCode === 13) { if (event.keyCode === 13) {
this.config.addAnswer(); this.config.addAnswer();
} }
return;
} }
} }

View File

@ -1,64 +1,43 @@
<div class="choices"> <nav class="choices">
<a <a
class="btn btn-primary"
[routerLink]="'/step/date'"> [routerLink]="'/step/date'">
Aller aux dates Aller aux dates
</a> </a>
<a <a
class="btn btn-primary"
[routerLink]="'/step/answers'"> [routerLink]="'/step/answers'">
Réponses Réponses
</a> </a>
<a <a
class="btn btn-primary"
[routerLink]="'/step/visibility'"> [routerLink]="'/step/visibility'">
Visibilité Visibilité
</a> </a>
<a <a
class="btn btn-primary"
[routerLink]="'/step/answers'"> [routerLink]="'/step/answers'">
Base Base
</a> </a>
<a <a
class="btn btn-primary"
[routerLink]="'/step/pictures'"> [routerLink]="'/step/pictures'">
Images Images
</a> </a>
<a <a
class="btn btn-primary"
[routerLink]="'/step/resume'"> [routerLink]="'/step/resume'">
Résumé Résumé
</a> </a>
<a <a
class="btn btn-primary"
[routerLink]="'/step/kind'"> [routerLink]="'/step/kind'">
Aller aux options classiques Aller aux options classiques
</a> </a>
<a <a
class="btn btn-primary"
[routerLink]="'/home'"> [routerLink]="'/home'">
Accueil Accueil
</a> </a>
<br> </nav>
<button
(click)="nextPage()"
[disabled]="!formIsValid"
class="btn btn-primary next"
>
<span i18n>
précédent
</span>
<i class="fa fa-arrow-right"></i>
</button>
<button
(click)="nextPage()"
[disabled]="!formIsValid"
class="btn btn-primary next"
>
<span i18n>
suivant
</span>
<i class="fa fa-arrow-right"></i>
</button>
</div>

View File

@ -1,12 +1,4 @@
input, textarea, // form inputs
select {
@extend .funky-box;
}
textarea {
border-left: 3px solid $main_color_strong;
}
.funky-box { .funky-box {
background: $light; background: $light;
padding: 1em; padding: 1em;
@ -19,6 +11,17 @@ textarea {
} }
} }
input, textarea,
select {
@extend .funky-box;
}
textarea {
margin-top: 1em;
border-left: 3px solid $main_color_strong;
}
// buttons // buttons
.btn { .btn {
display: inline-block; display: inline-block;
@ -31,14 +34,31 @@ textarea {
min-height: 1.5rem; min-height: 1.5rem;
} }
.btn-block {
display: block;
}
a { a {
text-decoration: none; text-decoration: none;
nav & {
display: inline-block;
margin: 0.5em;
@extend .btn-outline, .btn;
color: #000;
}
} }
.home_link { .home_link {
text-decoration: none; text-decoration: none;
} }
.striked { .btn-outline {
background: linear-gradient($main_color, $main_color_strong); background: $light;
border: solid 1px $main_color_strong;
}
.striked {
@extend .btn-outline;
color: $main_color_strong;
} }