mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
update custom_url with title
This commit is contained in:
parent
1755f205ad
commit
f1e5903d0a
@ -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;
|
||||
|
||||
|
@ -137,6 +137,11 @@ export class PollService implements Resolve<Poll> {
|
||||
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<Poll> {
|
||||
.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<Subscription> {
|
||||
// .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 {
|
||||
|
@ -14,20 +14,18 @@
|
||||
<!-- >-->
|
||||
|
||||
<input
|
||||
class="input is-block is-fullwidth"
|
||||
class="input"
|
||||
[placeholder]="'creation.choose_title_placeholder' | translate"
|
||||
formControlName="title"
|
||||
id="title"
|
||||
autofocus="autofocus"
|
||||
(change)="updateSlug()"
|
||||
(keyup)="updateSlug()"
|
||||
required="required"
|
||||
#title
|
||||
/>
|
||||
|
||||
<app-erasable-input [inputModel]="form.value.title"></app-erasable-input>
|
||||
<span class="button is-error" *ngIf="form.controls.title.errors">
|
||||
<div class="hint" *ngIf="form.controls.title.errors">
|
||||
Ce champ est requis
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
mat-button
|
||||
*ngIf="form.value.title"
|
||||
|
@ -38,7 +38,7 @@ export class BaseConfigComponent {
|
||||
}
|
||||
|
||||
public updateSlug(): void {
|
||||
const newValueFormatted = this.pollService.makecustom_url(this.poll);
|
||||
const newValueFormatted = this.pollService.convertTextToSlug(this.form.value.title);
|
||||
this.form.patchValue({ custom_url: newValueFormatted });
|
||||
}
|
||||
|
||||
|
@ -32,3 +32,7 @@
|
||||
.padded {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.marged {
|
||||
margin: 1em;
|
||||
}
|
||||
|
@ -40,8 +40,6 @@ textarea {
|
||||
input,
|
||||
select {
|
||||
display: inline-block;
|
||||
margin-bottom: 10px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.next {
|
||||
@ -73,3 +71,11 @@ li {
|
||||
button[type='submit'] {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1em;
|
||||
padding: 1em;
|
||||
background: $warning;
|
||||
color: $white;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user