From 12a41b502217ce8c2f0df9673ca7a21f80550409 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 30 Apr 2021 11:27:54 +0200 Subject: [PATCH] auto save on dev env --- mocks/old-stuff/config/PollConfig.ts | 2 +- mocks/old-stuff/services/config.service.ts | 1 + src/app/core/services/poll.service.ts | 24 +++++++----- .../advanced-config.component.html | 6 +-- .../base-config/base-config.component.html | 5 +-- .../form/base-config/base-config.component.ts | 37 ++----------------- .../administration/form/form.component.html | 16 ++++---- .../administration/form/form.component.ts | 35 ++++++++++++++++-- .../stepper/stepper.component.ts | 2 +- .../consultation/consultation.component.ts | 6 +-- .../user-polls/user-polls.component.html | 4 +- src/environments/environment.ts | 2 +- 12 files changed, 72 insertions(+), 68 deletions(-) diff --git a/mocks/old-stuff/config/PollConfig.ts b/mocks/old-stuff/config/PollConfig.ts index 99ceac24..32e5d94f 100644 --- a/mocks/old-stuff/config/PollConfig.ts +++ b/mocks/old-stuff/config/PollConfig.ts @@ -50,7 +50,7 @@ export class PollConfig { expirationDate = ''; // expiracy date voteStackId = null; // id of the vote stack to update pollId = null; // id of the current poll when created. data given by the backend api - pollSlug = null; // id of the current poll when created. data given by the backend api + custom_url = null; // id of the current poll when created. data given by the backend api currentPoll; // current poll selected with createPoll or getPoll of ConfigService passwordAccess = 0; password = ''; diff --git a/mocks/old-stuff/services/config.service.ts b/mocks/old-stuff/services/config.service.ts index fe22909f..9a1268f2 100644 --- a/mocks/old-stuff/services/config.service.ts +++ b/mocks/old-stuff/services/config.service.ts @@ -20,6 +20,7 @@ import { mockMyPolls } from '../mocks/mockmypolls'; export class ConfigService extends PollConfig { loading = false; apiBaseHref: any = environment.api.baseHref; + pollSlug: string; constructor( private http: HttpClient, diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 3a717d84..7197c678 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -143,15 +143,21 @@ export class PollService implements Resolve { return str + '-' + this.uuidService.getUUID(); } - public async saveCurrentPoll(): Promise { - const pollUrl: Subscription = await this.apiService.createPoll(this._poll.getValue()); - // TODO: Maybe handle the url to update currentPoll according to backend response - if (pollUrl) { - console.log('pollUrl', pollUrl); - this.toastService.display('Le sondage a été enregistré.'); - } else { - this.toastService.display('Le sondage n’a été correctement enregistré, veuillez ré-essayer.'); - } + public async saveCurrentPoll(): Promise { + // .then((resp) => { + // console.log('resp', resp); + // if (pollUrl) { + // console.log('pollUrl', pollUrl); + // this.toastService.display('Le sondage a été enregistré.'); + // // TODO: redirect to view + // } else { + // this.toastService.display('Le sondage n’a été correctement enregistré, veuillez ré-essayer.'); + // } + // }) + // .catch((err) => { + // console.error('err', err); + // }); + return await this.apiService.createPoll(this._poll.getValue()); } public saveParticipation(choice: Choice, user: Owner, response: Answer): void { diff --git a/src/app/features/administration/form/advanced-config/advanced-config.component.html b/src/app/features/administration/form/advanced-config/advanced-config.component.html index 1bd574b7..d378952f 100644 --- a/src/app/features/administration/form/advanced-config/advanced-config.component.html +++ b/src/app/features/administration/form/advanced-config/advanced-config.component.html @@ -31,14 +31,14 @@ {{ urlPrefix }} - {{ form.controls.slug.value }} + {{ form.controls.custom_url.value }} - + +
@@ -37,11 +37,11 @@ - - - - - + +