From f1e5903d0aa2d444b9dd5dc1ecdf3f30e2b61f22 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 3 May 2021 14:54:32 +0200 Subject: [PATCH] update custom_url with title --- src/app/core/models/poll.model.ts | 2 +- src/app/core/services/poll.service.ts | 25 +++++-------------- .../base-config/base-config.component.html | 10 +++----- .../form/base-config/base-config.component.ts | 2 +- src/styles/dev-utilities/_helpers.scss | 4 +++ src/styles/partials/_forms.scss | 10 ++++++-- 6 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index 2883d1fe..dbd9bbbc 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -24,7 +24,7 @@ export class Poll { public expiracy_date?: string; - public creation_date?: string; + public creation_date?: string = new Date().toISOString(); public creatorPseudo?: string; diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 644bdeb5..24bf1817 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -137,6 +137,11 @@ export class PollService implements Resolve { poll.owner.pseudo + '_' + poll.title; + + return this.convertTextToSlug(str) + '-' + this.uuidService.getUUID(); + } + + public convertTextToSlug(str: string) { str = str.replace(/^\s+|\s+$/g, ''); // trim str = str.toLowerCase(); @@ -151,25 +156,7 @@ export class PollService implements Resolve { .replace(/[^a-z0-9 -]/g, '') // remove invalid chars .replace(/\s+/g, '-') // collapse whitespace and replace by - .replace(/-+/g, '-'); // collapse dashes - - return str + '-' + this.uuidService.getUUID(); - } - - 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()); + return str; } public saveParticipation(choice: Choice, user: Owner, response: Answer): void { diff --git a/src/app/features/administration/form/base-config/base-config.component.html b/src/app/features/administration/form/base-config/base-config.component.html index 2adc91b0..b61aed25 100644 --- a/src/app/features/administration/form/base-config/base-config.component.html +++ b/src/app/features/administration/form/base-config/base-config.component.html @@ -14,20 +14,18 @@ - - - +
Ce champ est requis - +