patch default form values from loaded poll #105

This commit is contained in:
Tykayn 2021-05-17 17:36:24 +02:00 committed by tykayn
parent a99290186c
commit 4fefa3340c

View File

@ -101,6 +101,10 @@ export class FormComponent implements OnInit {
}); });
console.log('this.form ', this.form); console.log('this.form ', this.form);
// take back values from pollservice
this.form.patchValue(this.pollService.poll);
this.form.patchValue({ creatorPseudo: 'Chuck Norris', creatorEmail: 'chucknorris@example.com' });
if (showDemoValues) { if (showDemoValues) {
this.setDemoValues(); this.setDemoValues();
this.toastService.display('default values filled for demo'); this.toastService.display('default values filled for demo');
@ -116,6 +120,10 @@ export class FormComponent implements OnInit {
*/ */
setDemoValues(): void { setDemoValues(): void {
const title = 'le titre de démo oh oh ' + new Date().getTime(); const title = 'le titre de démo oh oh ' + new Date().getTime();
// this.form.patchValue(this.pollService.poll);
// this.form.patchValue({ creatorPseudo: 'Chuck Norris', creatorEmail: 'chucknorris@example.com' });
this.form.patchValue({ this.form.patchValue({
title: title, title: title,
custom_url: this.pollUtilitiesService.makeSlugFromString(title), custom_url: this.pollUtilitiesService.makeSlugFromString(title),
@ -142,14 +150,6 @@ export class FormComponent implements OnInit {
startDateInterval: new Date(), startDateInterval: new Date(),
endDateInterval: new Date(), endDateInterval: new Date(),
comments: [], comments: [],
// choices: [
// {
// name: 'un choix',
// url: 'https://placekitten.com/120/150',
// },
// ],
// dateChoices: defaultDates,
// timeChoices: defaultTimeOfDay,
}); });
} }