Commit 0a268e98 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 6446a8c1
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',

                },
            ]
        };
+62 −33
Original line number Diff line number Diff line
@@ -11,10 +11,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;
@@ -215,27 +218,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;

@@ -245,35 +248,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
     *
@@ -305,17 +313,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();
    }


@@ -1258,7 +1267,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get affectation
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getAffectation()
    {
@@ -1270,7 +1279,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get agrement
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getAgrement(TypeAgrement $typeAgrement = null)
    {
@@ -1329,7 +1338,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)
    {
@@ -1386,7 +1395,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)
    {
@@ -1461,7 +1470,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get miseEnPaiementIntervenantStructure
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getMiseEnPaiementIntervenantStructure()
    {
@@ -1506,7 +1515,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get modificationServiceDu
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getModificationServiceDu()
    {
@@ -1518,7 +1527,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get pieceJointe
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getPieceJointe()
    {
@@ -1530,7 +1539,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get service
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getService()
    {
@@ -1542,7 +1551,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get service référentiel
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getServiceReferentiel()
    {
@@ -1554,7 +1563,7 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
    /**
     * Get IndicModifDossier
     *
     * @return \Doctrine\Common\Collections\Collection
     * @return Collection
     */
    public function getIndicModifDossier()
    {
@@ -1573,6 +1582,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
     */
@@ -1602,7 +1631,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
+32 −0
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;

use Psr\Container\ContainerInterface;



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

    /**
     * @param ContainerInterface $container
     * @param string             $requestedName
     * @param array|null         $options
     *
     * @return TabViewHelper
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null): TabViewHelper
    {
        $viewHelper = new TabViewHelper;

        /* Injectez vos dépendances ICI */

        return $viewHelper;
    }
}
 No newline at end of file
Loading