Commit 3fb91a75 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Nouvelle aide de vue pour dessiner des Tabs.

Ajout de getMissions à Intervenant
WIP Saisie Realisé de mission
parent 661d2cb9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ export default {
                    component: SuiviEvent,
                    date: new Date(2023,1,5),
                    texte:'Coucou, le 505 février 2023',

                },
                {
                    component: SuiviEvent,
@@ -36,7 +35,6 @@ export default {
                    component: SuiviEvent,
                    date: new Date(2023,2,6),
                    texte:'Coucou, le 6 mars 2023',

                },
            ]
        };
+1 −0
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ $config = [
            \UnicaenApp\View\Helper\AppLink::class                     => View\Helper\AppLinkFactory::class,
            \UnicaenAuth\View\Helper\UserCurrent::class                => View\Helper\UserCurrentFactory::class,
            \UnicaenAuth\View\Helper\LocalConnectViewHelper::class     => View\Helper\LocalConnectViewHelperFactory::class,
            'tab' => View\Helper\TabViewHelperFactory::class,
        ],
        'invokables' => [
            'utilisateur'     => View\Helper\UtilisateurViewHelper::class,
+62 −33
Original line number Diff line number Diff line
@@ -9,10 +9,13 @@ use Application\Entity\Db\Traits\GradeAwareTrait;
use Application\Entity\Db\Traits\StructureAwareTrait;
use Application\Entity\Traits\AdresseTrait;
use Application\Interfaces\AdresseInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Indicateur\Entity\Db\IndicModifDossier;
use Intervenant\Entity\Db\Statut;
use Laminas\Hydrator\ClassMethodsHydrator;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use Mission\Entity\Db\Mission;
use OffreFormation\Entity\Db\Traits\DisciplineAwareTrait;
use Service\Entity\Db\EtatVolumeHoraire;
use Service\Entity\Db\HistoIntervenantService;
@@ -213,27 +216,27 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    protected $validiteFin;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $affectation;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $agrement;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $contrat;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    private $formuleResultat;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $histoService;

@@ -243,35 +246,40 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    protected $miseEnPaiementIntervenantStructure;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $modificationServiceDu;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $pieceJointe;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $service;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $serviceReferentiel;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $validation;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @var Collection
     */
    protected $indicModifDossier;

    /**
     * @var Collection
     */
    protected $missions;

    /**
     * Cache
     *
@@ -303,17 +311,18 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
     */
    public function __construct()
    {
        $this->affectation                        = new \Doctrine\Common\Collections\ArrayCollection();
        $this->agrement                           = new \Doctrine\Common\Collections\ArrayCollection();
        $this->contrat                            = new \Doctrine\Common\Collections\ArrayCollection();
        $this->formuleResultat                    = new \Doctrine\Common\Collections\ArrayCollection();
        $this->histoService                       = new \Doctrine\Common\Collections\ArrayCollection();
        $this->miseEnPaiementIntervenantStructure = new \Doctrine\Common\Collections\ArrayCollection();
        $this->modificationServiceDu              = new \Doctrine\Common\Collections\ArrayCollection();
        $this->pieceJointe                        = new \Doctrine\Common\Collections\ArrayCollection();
        $this->service                            = new \Doctrine\Common\Collections\ArrayCollection();
        $this->serviceReferentiel                 = new \Doctrine\Common\Collections\ArrayCollection();
        $this->validation                         = new \Doctrine\Common\Collections\ArrayCollection();
        $this->affectation                        = new ArrayCollection();
        $this->agrement                           = new ArrayCollection();
        $this->contrat                            = new ArrayCollection();
        $this->formuleResultat                    = new ArrayCollection();
        $this->histoService                       = new ArrayCollection();
        $this->miseEnPaiementIntervenantStructure = new ArrayCollection();
        $this->modificationServiceDu              = new ArrayCollection();
        $this->pieceJointe                        = new ArrayCollection();
        $this->service                            = new ArrayCollection();
        $this->serviceReferentiel                 = new ArrayCollection();
        $this->validation                         = new ArrayCollection();
        $this->missions                           = new ArrayCollection();
    }


@@ -1256,7 +1265,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get affectation
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getAffectation()
    {
@@ -1268,7 +1277,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get agrement
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getAgrement(TypeAgrement $typeAgrement = null)
    {
@@ -1327,7 +1336,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
     * @param \Application\Entity\Db\TypeContrat $typeContrat
     * @param \Application\Entity\Db\Structure   $structure
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getContrat(TypeContrat $typeContrat = null, Structure $structure = null)
    {
@@ -1384,7 +1393,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
     * @param TypeVolumeHoraire $typeVolumeHoraire
     * @param EtatVolumeHoraire $etatVolumehoraire
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getFormuleResultat(TypeVolumeHoraire $typeVolumeHoraire = null, EtatVolumeHoraire $etatVolumehoraire = null)
    {
@@ -1459,7 +1468,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get miseEnPaiementIntervenantStructure
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getMiseEnPaiementIntervenantStructure()
    {
@@ -1504,7 +1513,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get modificationServiceDu
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getModificationServiceDu()
    {
@@ -1516,7 +1525,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get pieceJointe
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getPieceJointe()
    {
@@ -1528,7 +1537,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get service
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getService()
    {
@@ -1540,7 +1549,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get service référentiel
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getServiceReferentiel()
    {
@@ -1552,7 +1561,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get IndicModifDossier
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getIndicModifDossier()
    {
@@ -1571,6 +1580,26 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import



    /**
     * Get IndicModifDossier
     *
     * @return Collection|Mission[]
     */
    public function getMissions(): Collection
    {
        if (null === $this->missions) {
            return null;
        }

        $filter = function (Mission $mission) {
            return ($mission->estHistorise()) ? false : true;
        };

        return $this->missions->filter($filter);
    }



    /**
     * @return bool
     */
@@ -1600,7 +1629,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
     *
     * @param \Application\Entity\Db\TypeValidation $type
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getValidation(TypeValidation $type = null)
    {
+1 −1
Original line number Diff line number Diff line
@@ -136,6 +136,6 @@
        <one-to-many field="validation" target-entity="Application\Entity\Db\Validation" mapped-by="intervenant"/>
        <one-to-many field="indicModifDossier" target-entity="Indicateur\Entity\Db\IndicModifDossier"
                     mapped-by="intervenant"/>

        <one-to-many field="missions" target-entity="Mission\Entity\Db\Mission" mapped-by="intervenant"/>
    </entity>
</doctrine-mapping>
+170 −0
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;

use Laminas\View\Helper\AbstractHtmlElement;


/**
 * Description of TabViewHelper
 *
 * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
 */
class TabViewHelper extends AbstractHtmlElement
{

    protected array  $pages = [];

    protected string $current;



    /**
     *
     * @return self
     */
    public function __invoke()
    {
        return $this;
    }



    /**
     * Retourne le code HTML.
     *
     * @return string Code HTML
     */
    public function __toString(): string
    {
        return $this->render();
    }



    /**
     *
     *
     * @return string Code HTML
     */
    public function render(): string
    {
        $r = $this->getView()->tag('ul', ['class' => 'nav nav-tabs', 'role' => 'tablist'])->open();
        foreach ($this->pages as $id => $label) {
            $liAttrs     = [
                'class' => 'nav-item',
                'role'  => 'presentation',
            ];
            $buttonAttrs = [
                'class'          => ['nav-link'],
                'data-bs-toggle' => 'tab',
                'data-bs-target' => '#' . $id,
                'type'           => 'button',
                'role'           => 'tab',
                'aria-controls'  => $id,
                'aria-selected'  => $id === $this->current ? 'true' : 'false',
            ];
            if ($id === $this->current) {
                $buttonAttrs['class'][] = 'active';
            }
            $r .= $this->getView()->tag('li', $liAttrs)->html(
                $this->getView()->tag('button', $buttonAttrs)->text($label)
            );
        }
        $r .= $this->getView()->tag('ul')->close();

        return $r;
    }



    public function contentBegin(): string
    {
        return '<div class="tab-content" id="myTabContent">';
    }



    public function contentEnd(): string
    {
        return '</div>';
    }


    public function pageBegin(string $pageId): string
    {
        $attrs = [
            'class'           => ['tab-pane', 'fade', 'show'],
            'id'              => $pageId,
            'role'            => 'tabpanel',
            'aria-labelledby' => $pageId . '-tab',
        ];
        if ($pageId === $this->current) {
            $attrs['class'][] = 'active';
        }

        return $this->getView()->tag('div', $attrs)->open();
    }



    public function pageEnd(): string
    {
        return '</div>';
    }



    public function addPages(array $pages): self
    {
        foreach ($pages as $id => $label) {
            if (is_string($label) && is_string($id)) {
                $this->pages[$id] = $label;
            }
        }

        return $this;
    }



    public function addPage(string $id, string $label): self
    {
        $this->pages[$id] = $label;

        return $this;
    }



    public function getPages(): array
    {
        return $this->pages;
    }



    public function setPages(array $pages): TabViewHelper
    {
        $this->pages = $pages;

        return $this;
    }



    public function getCurrent(): string
    {
        return $this->current;
    }



    public function setCurrent(string $current): TabViewHelper
    {
        $this->current = $current;

        return $this;
    }

}
 No newline at end of file
Loading