mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-18 08:14:24 +00:00
AsideActivityType entity changed to AsideActivityCategory + building forms for both entities
This commit is contained in:
parent
e7c76734a6
commit
ea2d6eac7b
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Chill\AsideActivityBundle\Form\AsideActivityType;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
class AsideArticleController extends AbstractController
|
||||
{
|
||||
public function new(EntityManager $entityManager)
|
||||
{
|
||||
$form = $this->createForm(AsideActivityType::class);
|
||||
|
||||
return $this->render('asideActivity_new.html.twig', [
|
||||
'asideActivityForm' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace Chill\AsideActivityBundle\Entity;
|
||||
|
||||
use Chill\AsideActivityBundle\Repository\AsideActivityRepository;
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivityType;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@ -20,7 +18,7 @@ class AsideActivity
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AsideActivityType::class, inversedBy="asideActivities")
|
||||
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="asideActivities")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $type;
|
||||
@ -49,6 +47,7 @@ class AsideActivity
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotBlank(message="Vous devez choisir un agent")
|
||||
*/
|
||||
private $agent;
|
||||
|
||||
@ -77,12 +76,12 @@ class AsideActivity
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getType(): ?AsideActivityType
|
||||
public function getType(): ?AsideActivityCategory
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(?AsideActivityType $type): self
|
||||
public function setType(?AsideActivityCategory $type): self
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
|
@ -2,15 +2,14 @@
|
||||
|
||||
namespace Chill\AsideActivityBundle\Entity;
|
||||
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=AsideActivityTypeRepository::class)
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class AsideActivityType
|
||||
class AsideActivityCategory
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class AsideActivityCategoryType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('title', TextType::class,
|
||||
[
|
||||
'label' => 'Nom',
|
||||
])
|
||||
->add('isActive', ChoiceType::class,
|
||||
[
|
||||
'choices' => [
|
||||
'Yes' => true,
|
||||
'No' => false
|
||||
],
|
||||
'expanded' => true
|
||||
]);
|
||||
}
|
||||
}
|
@ -2,14 +2,16 @@
|
||||
|
||||
namespace Chill\AsideActivityBundle\Form;
|
||||
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -20,32 +22,27 @@ class AsideActivityType extends AbstractType
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('createdBy', 'entity',
|
||||
array(
|
||||
'class' => User::class,
|
||||
'choice_label' => 'username'
|
||||
),
|
||||
->add('createdBy', EntityType::class,
|
||||
[
|
||||
'label' => 'Utilisateur',
|
||||
'required' => true
|
||||
])
|
||||
->add('agent', 'entity',
|
||||
array(
|
||||
'required' => true,
|
||||
'class' => User::class,
|
||||
'choice_label' => 'username'
|
||||
),
|
||||
])
|
||||
->add('agent', EntityType::class,
|
||||
[
|
||||
'label' => 'Agent',
|
||||
'required' => true
|
||||
'required' => true,
|
||||
'class' => User::class,
|
||||
'placeholder' => 'L’agent pour qui l\'activité annexe est créée',
|
||||
'choice_label' => 'username'
|
||||
])
|
||||
->add('type', 'entity',
|
||||
array(
|
||||
'class' => AsideActivityType::class,
|
||||
'choice_label' => 'title'
|
||||
),
|
||||
->add('type', EntityType::class,
|
||||
[
|
||||
'label' => 'Type',
|
||||
'required' => true
|
||||
'required' => true,
|
||||
'class' => AsideActivityCategory::class,
|
||||
'choice_label' => 'title'
|
||||
])
|
||||
->add('date', DateType::class, [
|
||||
'label' => 'Date',
|
||||
@ -54,9 +51,6 @@ class AsideActivityType extends AbstractType
|
||||
->add('duration', NumberType::class, [
|
||||
'label' => 'Durée'
|
||||
])
|
||||
->add('location', TextType::class, [
|
||||
'label' => 'Lieu'
|
||||
])
|
||||
->add('note', TextareaType::class, [
|
||||
'label' => 'Note'
|
||||
])
|
||||
|
@ -4,28 +4,28 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\AsideActivityBundle\Repository;
|
||||
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivityType;
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
class AsideActivityTypeRepository implements ObjectRepository
|
||||
class AsideActivityCategoryRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(AsideActivityType::class);
|
||||
$this->repository = $entityManager->getRepository(AsideActivityCategory::class);
|
||||
}
|
||||
|
||||
|
||||
public function find($id): ?AsideActivityType
|
||||
public function find($id): ?AsideActivityCategory
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AsideActivityType[]
|
||||
* @return AsideActivityCategory[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
@ -33,20 +33,20 @@ class AsideActivityTypeRepository implements ObjectRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AsideActivityType[]
|
||||
* @return AsideActivityCategory[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?AsideActivityType
|
||||
public function findOneBy(array $criteria): ?AsideActivityCategory
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return AsideActivityType::class;
|
||||
return AsideActivityCategory::class;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user