<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\TicketBundle\Form;

use Chill\MainBundle\Form\Type\ChillCollectionType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\TicketBundle\Entity\EmergencyStatusEnum;
use Chill\TicketBundle\MotiveDTO;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class MotiveType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('label', TranslatableStringFormType::class, [
                'label' => 'Label',
                'required' => true,
            ])
            ->add('active', CheckboxType::class, [
                'label' => 'Active',
                'required' => false,
            ])
            ->add('makeTicketEmergency', EnumType::class, [
                'class' => EmergencyStatusEnum::class,
                'label' => 'emergency?',
                'required' => false,
                'placeholder' => 'Choose an option...',
            ])
            ->add('supplementaryComments', ChillCollectionType::class, [
                'entry_type' => TextType::class,
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => true,
                'label' => 'Supplementary comments',
                'required' => false,
            ])
            ->add('ordering', NumberType::class, [
                'scale' => 4,
                'label' => 'Ordering',
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => MotiveDTO::class,
        ]);
    }

    public function getBlockPrefix(): string
    {
        return 'chill_ticketbundle_motive';
    }
}
