Commit 63c4a2c9 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Structures hiérarchiques pour la page ODF

parent dc905e61
Loading
Loading
Loading
Loading
+18 −1
Changes for module/Lieu/src/Form/Element/Structure.php: 18 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ class Structure extends Select
{
    use StructureServiceAwareTrait;

    private bool $enseignement = false;

    private array $optionsBuilding = [];

    public function init()
@@ -26,11 +28,26 @@ class Structure extends Select



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



    public function setEnseignement(bool $enseignement): Structure
    {
        $this->enseignement = $enseignement;
        return $this;
    }



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

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

        $this->setValueOptions($this->optionsBuilding);
+4 −2
Changes for module/OffreFormation/src/Controller/Factory/OffreFormationControllerFactory.php: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
*/
namespace OffreFormation\Controller\Factory;

use Lieu\Form\Element\Structure;
use OffreFormation\Controller\OffreFormationController;
use Psr\Container\ContainerInterface;
use UnicaenImport\Service\SchemaService;
@@ -19,8 +20,9 @@ class OffreFormationControllerFactory
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null)
    {
        $renderer   = $container->get('ViewRenderer');
        $controller = new OffreFormationController($renderer);
        $structureElement = $container->get('FormElementManager')->get(Structure::class);

        $controller = new OffreFormationController($structureElement);
        $controller->setServiceSchema($container->get(SchemaService::class));

        return $controller;
+12 −2
Changes for module/OffreFormation/src/Controller/OffreFormationController.php: 12 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace OffreFormation\Controller;
use Application\Service\Traits\AnneeServiceAwareTrait;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\LocalContextServiceAwareTrait;
use Lieu\Form\Element\Structure;
use Lieu\Service\StructureServiceAwareTrait;
use OffreFormation\Entity\Db\CheminPedagogique;
use OffreFormation\Entity\Db\ElementPedagogique;
@@ -40,6 +41,16 @@ class OffreFormationController extends \Application\Controller\AbstractControlle
    use OffreFormationServiceAwareTrait;
    use SchemaServiceAwareTrait;

    private Structure $structureElement;



    public function __construct(Structure $structureElement)
    {
        $this->structureElement = $structureElement;
    }



    public function indexAction()
    {
@@ -54,7 +65,6 @@ class OffreFormationController extends \Application\Controller\AbstractControlle
            ->setNiveau($niveau)
            ->setEtape($etape);

        $structures = $this->getServiceStructure()->getList($this->getServiceStructure()->finderByEnseignement());
        [$niveaux, $etapes, $elements] = $this->getServiceOffreFormation()->getNeep($structure, $niveau, $etape);

        $params = [];
@@ -69,7 +79,7 @@ class OffreFormationController extends \Application\Controller\AbstractControlle
        }

        return [
            'structures'     => $structures,
            'structureElement' => $this->structureElement,
            'niveaux'          => $niveaux,
            'etapes'           => $etapes,
            'elements'         => $elements,
+8 −4
Changes for module/OffreFormation/view/offre-formation/offre-formation/index.phtml: 8 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
 * @var $structure  \Lieu\Entity\Db\Structure
 * @var $niveau     \Application\Entity\NiveauEtape
 * @var $etape      \OffreFormation\Entity\Db\Etape
 * @var $structures \Lieu\Entity\Db\Structure[]
 * @var $niveaux    \Application\Entity\NiveauEtape[]
 * @var $etapes     \OffreFormation\Entity\Db\Etape[]
 * @var $elements   \OffreFormation\Entity\Db\ElementPedagogique[]
@@ -102,6 +101,10 @@ $canSyncElement = $this->isAllowed(Privileges::getResourceId(Privileges::ODF_ELE
    div.card-body input.form-control {
        width: 75%
    }

    .bootstrap-select.struct {
        max-width: 200px;
    }
</style>

<?php ?>
@@ -116,11 +119,12 @@ $canSyncElement = $this->isAllowed(Privileges::getResourceId(Privileges::ODF_ELE
            <div class="card-header">Structure</div>
            <div class="card-body">
                <?php
                $selectStructure = new \Laminas\Form\Element\Select('structure');
                $selectStructure = new \Lieu\Form\Element\Structure('structure');
                $selectStructure->setEnseignement(true);
                $selectStructure->init();
                $selectStructure
                    ->setValueOptions(['' => "(Sélectionnez...)"] + \UnicaenApp\Util::collectionAsOptions($structures))
                    ->setValue($structure ? $structure->getId() : null)
                    ->setAttributes(['class' => 'struct form-select']);
                    ->setAttributes(['class' => 'struct selectpicker']);
                echo $this->formSelect($selectStructure);
                ?>
                <script>