fix cancel modal

This commit is contained in:
Tykayn 2021-12-06 12:13:47 +01:00 committed by tykayn
parent e4689a5e71
commit 8035ea700e
8 changed files with 50 additions and 14 deletions

View File

@ -114,7 +114,7 @@ export class PollService implements Resolve<Poll> {
public createFormGroup() {
let minlengthValidation = environment.production ? 12 : 0;
let form = this.fb.group({
title: ['défault titre', [Validators.required, Validators.minLength(minlengthValidation)]],
title: ['', [Validators.required, Validators.minLength(minlengthValidation)]],
creatorPseudo: ['', []],
created_at: [new Date(), [Validators.required]],
creatorEmail: ['', [environment.creation_email_is_required ? Validators.required : null]],
@ -176,7 +176,6 @@ export class PollService implements Resolve<Poll> {
* get a new slug from form title and creation date
*/
public updateSlug(): void {
console.log('this.form.value', this.form.value);
this.form.patchValue({ custom_url: this.makeSlug(this.form) });
}
@ -713,7 +712,6 @@ export class PollService implements Resolve<Poll> {
*/
newPollFromForm(): Poll {
let form = this.form;
console.log('this.form.value', this.form.value);
const newOwner = this.storageService.vote_stack.owner;
const newpoll = new Poll(newOwner, form.value.custom_url, form.value.title);

View File

@ -36,6 +36,7 @@ import { TextListComponent } from './form/text-list/text-list.component';
import { HoursComponent } from './form/hours/hours.component';
import { ActionsMenuComponent } from './actions-menu/actions-menu.component';
import { NavStepsComponent } from './nav-steps/nav-steps.component';
import { DialogModule } from 'primeng/dialog';
@NgModule({
declarations: [
@ -78,6 +79,7 @@ import { NavStepsComponent } from './nav-steps/nav-steps.component';
TranslateModule.forChild({ extend: true }),
DragDropModule,
ConfirmDialogModule,
DialogModule,
],
exports: [ActionsMenuComponent],
})

View File

@ -7,6 +7,7 @@ import { ToastService } from '../../../core/services/toast.service';
import { PollService } from '../../../core/services/poll.service';
import { DOCUMENT } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { environment } from '../../../../environments/environment';
@Component({
selector: 'app-admin-form',
@ -33,7 +34,9 @@ export class FormComponent implements OnInit {
}
ngOnInit(): void {
this.pollService.askInitFormDefault();
if (environment.autofill_creation) {
this.pollService.askInitFormDefault();
}
}
goNextStep() {}

View File

@ -42,7 +42,7 @@
maxlength="300"
></textarea>
<div
class="text-info padded"
class="text-info"
[ngClass]="{ 'has-background-warning': pollService.form.value.description.length === 300 }"
>
<span class="counter-current" *ngIf="pollService.form.value.description.length">

View File

@ -74,4 +74,34 @@
<div class="step-bar-container" style="width: 100%;">
<div class="step-bar-progress" [ngStyle]="{ width: (step_current / step_max) * 100 + '%' }"></div>
</div>
<!-- modale pour quitter la création-->
<p-dialog
header="Quitter?"
[modal]="true"
[(visible)]="display_cancel_dialog"
[breakpoints]="{ '960px': '75vw' }"
[style]="{ width: '50vw' }"
[draggable]="false"
[resizable]="false"
>
<p>Souhaitez-vous vraiment quitter le sondage ? Toutes les informations seront effacées.</p>
<ng-template pTemplate="footer">
<div class="columns">
<div class="column">
<button class="button is-warning is-fullwidth cancel-button-confirm" (click)="goToHome()">
Quitter
</button>
</div>
<div class="column">
<button
class="button is-primary is-fullwidth cancel-button-reject"
(click)="display_cancel_dialog = false"
>
Rester
</button>
</div>
</div>
</ng-template>
</p-dialog>
</section>

View File

@ -77,4 +77,10 @@
.step-counter-text {
font-weight: 600;
}
.cancel-button-reject,
.cancel-button-confirm {
display: block !important;
width: 100%;
color: white !important;
}
}

View File

@ -19,6 +19,7 @@ export class StepperComponent {
public step_max: number = 5;
public environment = environment;
public show_shortcuts = environment.showStepperShortcuts;
display_cancel_dialog: boolean;
constructor(
public pollService: PollService,
private confirmationService: ConfirmationService,
@ -28,17 +29,10 @@ export class StepperComponent {
}
showCancelDialog() {
this.confirmationService.confirm({
header: 'Quitter ?',
acceptLabel: 'Quitter',
rejectLabel: 'Rester',
message: 'Souhaitez-vous vraiment quitter le sondage ? Toutes les informations seront effacées.',
accept: () => this.goToHome(),
reject: () => console.log('rejected'),
});
this.display_cancel_dialog = true;
}
goToHome() {
this.confirmationService.close();
this.display_cancel_dialog = false;
this.router.navigate(['/']);
}
}

View File

@ -0,0 +1,3 @@
#lang_selector {
background: white;
}