Commit d377c211 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Amélioration du filtre enseignement

auto-population de la liste si elle est vide uniquement et uniquement sur demande lors de l'affichage
parent be8c5939
Loading
Loading
Loading
Loading
+16 −9
Changes for module/Lieu/src/Form/Element/Structure.php: 16 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -13,24 +13,20 @@ class Structure extends Select

    private bool $enseignement = false;

    private array $optionsBuilding = [];

    public function init()
    {
        parent::init();

        $this->setLabel('Structure');
        $this->setAttribute('class', 'selectpicker');
        $this->setAttribute('data-live-search', 'true');
        $this->setEmptyOption('- Aucune -');
        $this->populateOptions();
    }



    public function isEnseignement(): bool
    {
        return $this->enseignement;
        return $this->enseignement || $this->getOption('enseignement');
    }


@@ -45,13 +41,24 @@ class Structure extends Select

    protected function populateOptions()
    {
        $this->optionsBuilding = [];
        $this->valueOptions = [];

        $tree = $this->getServiceStructure()->getTree(null, $this->isEnseignement());
        $this->subPopulate($tree, 1);
    }



    /**
     * @return array
     */
    public function getValueOptions(): array
    {
        if (empty($this->valueOptions)){
            $this->populateOptions();
        }

        $this->setValueOptions($this->optionsBuilding);
        $this->optionsBuilding = [];
        return $this->valueOptions;
    }


@@ -64,7 +71,7 @@ class Structure extends Select
    protected function subPopulate(array|Collection $structures, int $level)
    {
        foreach($structures as $structure){
            $this->optionsBuilding[$structure->getId()] = [
            $this->valueOptions[$structure->getId()] = [
                'value' => $structure->getId(),
                'label' => $structure->getLibelleCourt(),
                'attributes' => [
+3
Changes for module/OffreFormation/src/Form/TypeIntervention/TypeInterventionStructureSaisieForm.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ class TypeInterventionStructureSaisieForm extends AbstractForm
        $this->add([
            'name'       => 'structure',
            'type'       => Structure::class,
            'options'    => [
                'enseignement' => true,
            ],
        ]);
        $this->add([
            'name'    => 'visible',
+3
Changes for module/Paiement/src/Form/Modulateur/TypeModulateurStructureSaisieForm.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@ class TypeModulateurStructureSaisieForm extends AbstractForm
        $this->add([
            'name'       => 'structure',
            'type'       => Structure::class,
            'options' => [
                'enseignement' => true,
            ],
        ]);

        $this->add([