diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 43b0fa8e..4a0e9f19 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -3,7 +3,7 @@ import { RouterModule } from '@angular/router'; import { routes } from './routes-framadate'; @NgModule({ - imports: [RouterModule.forRoot(routes, { useHash: true, enableTracing: true })], + imports: [RouterModule.forRoot(routes, { useHash: true })], exports: [RouterModule], }) export class AppRoutingModule {} diff --git a/src/app/core/services/api.service.ts b/src/app/core/services/api.service.ts index 4bc8df9a..7ee51523 100644 --- a/src/app/core/services/api.service.ts +++ b/src/app/core/services/api.service.ts @@ -80,9 +80,13 @@ export class ApiService { }; } + /** + * + * @param poll + */ public async createPoll(poll: PollDTO): Promise { // this.loaderService.setStatus(true); - console.log('createPoll config', poll); + console.log('apiservice createPoll config', poll); return this.axiosInstance.post( `${this.baseHref}${currentApiRoutes['api_new_poll']}`, poll, diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index da254d98..c6cf37cd 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -89,7 +89,7 @@ export class PollService implements Resolve { this.addChoice('abricot'); this.form.patchValue({ - title: 'mon titre', + title: 'mon titre de sondage du ' + this.DateUtilitiesService.formateDateToInputStringNg(new Date()), description: 'répondez SVP <3 ! *-* ', custom_url: this.uuidService.getUUID(), creatorPseudo: 'Chuck Norris', @@ -115,7 +115,7 @@ export class PollService implements Resolve { public createFormGroup() { let minlengthValidation = environment.production ? 12 : 0; let form = this.fb.group({ - title: ['', [Validators.required, Validators.minLength(minlengthValidation)]], + title: ['mon titre de sondage', [Validators.required, Validators.minLength(minlengthValidation)]], creatorPseudo: ['', [Validators.required]], created_at: [new Date(), [Validators.required]], creatorEmail: ['', [Validators.required]], @@ -385,9 +385,12 @@ export class PollService implements Resolve { } } + /** + * convert form data to DTO to create a new poll, and store the admin key + */ public createPoll(): Promise { this.toastService.display('sending...'); - console.log('this.form', this.form); + console.log('createPoll this.form', this.form); const newpoll = this.newPollFromForm(); return this.apiService.createPoll(newpoll).then( (resp: any) => { @@ -395,8 +398,12 @@ export class PollService implements Resolve { console.log('TODO fill admin_key'); console.log('resp', resp); this.admin_key = resp.data.poll.admin_key; + this.storageService.userPolls.push(resp.data.poll); }, - (error) => this.apiService.ousideHandleError(error) + (error) => { + this.toastService.display('BOOM, the createPoll went wrong'); + this.apiService.ousideHandleError(error); + } ); } diff --git a/src/app/core/services/storage.service.ts b/src/app/core/services/storage.service.ts index d19c83db..eceb828b 100644 --- a/src/app/core/services/storage.service.ts +++ b/src/app/core/services/storage.service.ts @@ -47,7 +47,7 @@ export class StorageService { constructor(public dateUtilities: DateUtilitiesService, private toastService: ToastService) { if (environment.autofill_participation) { - this.toastService.display('autofill des sondages utilisateur'); + // this.toastService.display('autofill des sondages utilisateur'); this.userPolls.push(new Poll(new Owner(), 'Démo: Anniversaire de tonton Patrick', 'aujourdhui-ou-demain')); this.userPolls.push(new Poll(new Owner(), 'Démo: Atelier cuisine du quartier', 'aujourdhui-ou-demain')); this.userPolls.push( diff --git a/src/app/features/administration/form/steps/step-four/step-four.component.ts b/src/app/features/administration/form/steps/step-four/step-four.component.ts index 3017ec41..edca8077 100644 --- a/src/app/features/administration/form/steps/step-four/step-four.component.ts +++ b/src/app/features/administration/form/steps/step-four/step-four.component.ts @@ -21,8 +21,7 @@ export class StepFourComponent implements OnInit { ngOnInit(): void {} createPoll() { - let apiData = this.pollService.newPollFromForm(); - this.apiService.createPoll(apiData).then((resp) => { + this.pollService.createPoll().then((resp) => { this.router.navigate(['administration/success']); }); } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 4add204a..8b3a6a3c 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -10,7 +10,7 @@ endpoints.baseHref = apiV1.baseHref; export const environment = { frontDomain: 'http://127.0.0.1:4200', production: false, - display_routes: false, // demo paths to test polls + display_routes: true, // demo paths to test polls autofill_creation: true, advanced_options_display: true, autofill_participation: true,