mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Fixes for feature "Regroupment of center"
* allow more than 15 character in regroupment name * remove unused methods in PickCenterType * show only active Regroupment in form * remove dead code and commented code
This commit is contained in:
parent
73fa585707
commit
62532e0a90
@ -43,7 +43,7 @@ class Regroupment
|
|||||||
private bool $isActive = true;
|
private bool $isActive = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=15, options={"default": ""}, nullable=false)
|
* @ORM\Column(type="text", options={"default": ""}, nullable=false)
|
||||||
*/
|
*/
|
||||||
private string $name = '';
|
private string $name = '';
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ use Chill\MainBundle\Entity\Center;
|
|||||||
use Chill\MainBundle\Entity\Regroupment;
|
use Chill\MainBundle\Entity\Regroupment;
|
||||||
use Chill\MainBundle\Export\ExportManager;
|
use Chill\MainBundle\Export\ExportManager;
|
||||||
use Chill\MainBundle\Form\DataMapper\ExportPickCenterDataMapper;
|
use Chill\MainBundle\Form\DataMapper\ExportPickCenterDataMapper;
|
||||||
|
use Chill\MainBundle\Repository\RegroupmentRepository;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
@ -29,29 +30,28 @@ use function count;
|
|||||||
/**
|
/**
|
||||||
* Pick centers amongst available centers for the user.
|
* Pick centers amongst available centers for the user.
|
||||||
*/
|
*/
|
||||||
class PickCenterType extends AbstractType
|
final class PickCenterType extends AbstractType
|
||||||
{
|
{
|
||||||
public const CENTERS_IDENTIFIERS = 'c';
|
public const CENTERS_IDENTIFIERS = 'c';
|
||||||
|
|
||||||
protected AuthorizationHelperInterface $authorizationHelper;
|
private AuthorizationHelperInterface $authorizationHelper;
|
||||||
|
|
||||||
protected ExportManager $exportManager;
|
private ExportManager $exportManager;
|
||||||
|
|
||||||
protected UserInterface $user;
|
private RegroupmentRepository $regroupmentRepository;
|
||||||
|
|
||||||
|
private UserInterface $user;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TokenStorageInterface $tokenStorage,
|
TokenStorageInterface $tokenStorage,
|
||||||
ExportManager $exportManager,
|
ExportManager $exportManager,
|
||||||
|
RegroupmentRepository $regroupmentRepository,
|
||||||
AuthorizationHelperInterface $authorizationHelper
|
AuthorizationHelperInterface $authorizationHelper
|
||||||
) {
|
) {
|
||||||
$this->exportManager = $exportManager;
|
$this->exportManager = $exportManager;
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
}
|
$this->regroupmentRepository = $regroupmentRepository;
|
||||||
|
|
||||||
public function addGroupingCenter(GroupingCenterInterface $grouping)
|
|
||||||
{
|
|
||||||
$this->groupingCenters[md5($grouping->getName())] = $grouping;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
@ -71,13 +71,14 @@ class PickCenterType extends AbstractType
|
|||||||
'choice_label' => static function (Center $c) {
|
'choice_label' => static function (Center $c) {
|
||||||
return $c->getName();
|
return $c->getName();
|
||||||
},
|
},
|
||||||
'data' => count($this->groupingCenters) > 0 ? null : $centers,
|
'data' => $centers,
|
||||||
])
|
])
|
||||||
->add('regroupment', EntityType::class, [
|
->add('regroupment', EntityType::class, [
|
||||||
'class' => Regroupment::class,
|
'class' => Regroupment::class,
|
||||||
'label' => 'regroupment',
|
'label' => 'regroupment',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
|
'choices' => $this->regroupmentRepository->findAllActive(),
|
||||||
'choice_label' => static function (Regroupment $r) {
|
'choice_label' => static function (Regroupment $r) {
|
||||||
return $r->getName();
|
return $r->getName();
|
||||||
},
|
},
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
<?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\MainBundle\Form\Type\Export;
|
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
|
|
||||||
class PickRegroupmentType extends AbstractType
|
|
||||||
{
|
|
||||||
}
|
|
@ -38,6 +38,11 @@ final class RegroupmentRepository implements ObjectRepository
|
|||||||
return $this->repository->findAll();
|
return $this->repository->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findAllActive(): array
|
||||||
|
{
|
||||||
|
return $this->repository->findBy(['isActive' => true], ['name' => 'ASC']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed|null $limit
|
* @param mixed|null $limit
|
||||||
* @param mixed|null $offset
|
* @param mixed|null $offset
|
||||||
|
@ -44,16 +44,6 @@
|
|||||||
<h3 class="m-3">{{ 'Pick aggregated centers'|trans }}</h3>
|
<h3 class="m-3">{{ 'Pick aggregated centers'|trans }}</h3>
|
||||||
{{ form_widget(form.centers.regroupment) }}
|
{{ form_widget(form.centers.regroupment) }}
|
||||||
|
|
||||||
{# {% if form.centers.children.g is defined %}#}
|
|
||||||
{##}
|
|
||||||
{# <h3>{{ 'Pick aggregated centers'|trans }}</h3>#}
|
|
||||||
{##}
|
|
||||||
{# {% for f in form.centers.children.g.children %}#}
|
|
||||||
{# {{ form_row(f) }}#}
|
|
||||||
{# {% endfor %}#}
|
|
||||||
{##}
|
|
||||||
{# {% endif %}#}
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<p>{{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-action btn-create' }, 'label' : 'Go to export options' } ) }}</p>
|
<p>{{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-action btn-create' }, 'label' : 'Go to export options' } ) }}</p>
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Main;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20230301155213 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Alter type to TEXT for regroupment.name';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE regroupment ALTER name TYPE TEXT');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE regroupment ALTER name TYPE VARCHAR(15)');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user