import { ChangeDetectorRef, Component, Inject, Input } from '@angular/core'; import { ToastService } from '../../../../core/services/toast.service'; import { FormBuilder, FormGroup } from '@angular/forms'; import { UuidService } from '../../../../core/services/uuid.service'; import { PollService } from '../../../../core/services/poll.service'; import { ApiService } from '../../../../core/services/api.service'; import { Router } from '@angular/router'; import { DOCUMENT } from '@angular/common'; import { Poll } from '../../../../core/models/poll.model'; import { environment } from '../../../../../environments/environment'; import { PollUtilitiesService } from '../../../../core/services/poll.utilities.service'; @Component({ selector: 'app-base-config', templateUrl: './base-config.component.html', styleUrls: ['./base-config.component.scss'], }) export class BaseConfigComponent { @Input() public poll?: Poll; @Input() public form: FormGroup; constructor( private fb: FormBuilder, private cd: ChangeDetectorRef, private uuidService: UuidService, private toastService: ToastService, private pollService: PollService, private utilitiesService: PollUtilitiesService, private apiService: ApiService, private router: Router, @Inject(DOCUMENT) private document: Document ) {} askInitFormDefault(): void { this.toastService.display('formulaire réinitialisé', 'info'); } public updateSlug(): void { const newValueFormatted = this.pollService.makecustom_url(this.poll); this.form.patchValue({ custom_url: newValueFormatted }); } /** * set the poll custom_url from other data of the poll */ automaticSlug(): void { this.form.patchValue({ custom_url: this.utilitiesService.makeUuid() }); } }