mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { Component, Input, OnInit } from '@angular/core';
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
import { Poll } from '../../../core/models/poll.model';
|
|
import { PollUtilsService } from '../../../core/utils/poll-utils.service';
|
|
|
|
@Component({
|
|
selector: 'app-edit-description',
|
|
templateUrl: './edit-description.component.html',
|
|
styleUrls: ['./edit-description.component.scss'],
|
|
})
|
|
export class EditDescriptionComponent implements OnInit {
|
|
@Input()
|
|
public poll?: Poll;
|
|
public pollForm: FormGroup;
|
|
|
|
constructor(private fb: FormBuilder, private pollUtilsService: PollUtilsService) {}
|
|
|
|
ngOnInit(): void {
|
|
this.pollForm = this.fb.group({
|
|
type: [this.poll ? this.poll.isDateType : false, [Validators.required]],
|
|
title: [this.poll ? this.poll.title : '', [Validators.required]],
|
|
description: [this.poll ? this.poll.description : ''],
|
|
slug: [this.poll ? this.poll.slug : this.generateRandomSlug(), [Validators.required]],
|
|
address: this.fb.group({
|
|
street: [''],
|
|
city: [''],
|
|
state: [''],
|
|
zip: [''],
|
|
}),
|
|
});
|
|
}
|
|
|
|
public onSubmit(): void {
|
|
console.log(this.pollForm);
|
|
}
|
|
|
|
private generateRandomSlug(): string {
|
|
return this.pollUtilsService.makeUuid();
|
|
}
|
|
}
|