Skip to content
Snippets Groups Projects
Commit 4cdfa339 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Les indicateurs et les tableaux de bords sont maintenant munis de namespace

parent 2967bd2b
Branches
Tags
No related merge requests found
Showing
with 90 additions and 4 deletions
......@@ -11,7 +11,7 @@
"unicaen/app": "^4|^5",
"unicaen/utilisateur": "^4|^5",
"unicaen/privilege": "^4|^5",
"unicaen/mail": "^4|^5"
"unicaen/mail": "^5"
},
"autoload": {
"psr-0": [],
......
......@@ -66,17 +66,21 @@ class IndicateurController extends AbstractActionController {
public function creerAction() : ViewModel
{
$indicateur = new Indicateur();
$namespace = $this->params()->fromQuery('namespace');
if ($namespace) $indicateur->setNamespace($namespace);
$form = $this->getIndicateurForm();
$form->setAttribute('action', $this->url()->fromRoute('indicateur/creer', [], [], true));
$form->setAttribute('action', $this->url()->fromRoute('indicateur/creer', [], ['query' => ['namespace' => $namespace]], true));
$form->bind($indicateur);
/** @var Request $request */
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$indicateur->setDernierRafraichissement(new DateTime());
$this->getIndicateurService()->create($indicateur);
$this->getIndicateurService()->createView($indicateur);
}
......
......@@ -39,6 +39,9 @@ class TableauDeBordController extends AbstractActionController
{
$tableau = new TableauDeBord();
$namespace = $this->params()->fromQuery('namespace');
if ($namespace) $tableau->setNamespace($namespace);
$form = $this->getTableauDeBordForm();
$form->setAttribute('action', $this->url()->fromRoute('tableau-de-bord/ajouter', [], [], true));
$form->bind($tableau);
......
......@@ -20,6 +20,7 @@ class Indicateur {
private ?DateTime $dernierRafraichissement = null;
private ?string $viewId = null;
private ?string $entity = null;
private ?string $namespace = null;
private Collection $abonnements;
private Collection $tableaux;
......@@ -94,6 +95,16 @@ class Indicateur {
$this->entity = $entity;
}
public function getNamespace(): ?string
{
return $this->namespace;
}
public function setNamespace(?string $namespace): void
{
$this->namespace = $namespace;
}
/** Abonnements **************************************************************** */
/**
......
......@@ -12,6 +12,7 @@
<field name="dernierRafraichissement" type="datetime" column="dernier_rafraichissement" nullable="true"/>
<field name="viewId" type="string" length="255" column="view_id" nullable="true"/>
<field name="entity" type="string" length="255" column="entity" nullable="true"/>
<field name="namespace" type="string" length="1024" column="namespace" nullable="true"/>
<one-to-many target-entity="UnicaenIndicateur\Entity\Db\Abonnement" field="abonnements" mapped-by="indicateur" />
......
......@@ -9,6 +9,7 @@
<field name="titre" type="string" length="255" column="titre" nullable="false"/>
<field name="description" type="string" length="2047" column="description" nullable="false"/>
<field name="nbColumn" type="integer" column="nb_column" nullable="false"/>
<field name="namespace" type="string" length="1024" column="namespace" nullable="true"/>
<many-to-many field="indicateurs" target-entity="UnicaenIndicateur\Entity\Db\Indicateur" inversed-by="indicateur" fetch="LAZY">
<join-table name="unicaen_indicateur_tableau_indicateur">
......
......@@ -12,6 +12,7 @@ class TableauDeBord {
private ?string $titre = null;
private ?string $description = null;
private ?int $nbColumn = 1;
private ?string $namespace = null;
private Collection $indicateurs;
public function __construct()
......@@ -54,6 +55,16 @@ class TableauDeBord {
$this->nbColumn = $nbColumn;
}
public function getNamespace(): ?string
{
return $this->namespace;
}
public function setNamespace(?string $namespace): void
{
$this->namespace = $namespace;
}
/**
* @return Indicateur[]
*/
......
......@@ -38,6 +38,17 @@ class IndicateurForm extends Form {
'class' => 'type2 form-control',
]
]);
// namespace
$this->add([
'type' => Text::class,
'name' => 'namespace',
'options' => [
'label' => "Namespace :",
],
'attributes' => [
'id' => 'namespace',
],
]);
// view_id
$this->add([
'type' => Text::class,
......@@ -104,6 +115,7 @@ class IndicateurForm extends Form {
$this->setInputFilter((new Factory())->createInputFilter([
'libelle' => [ 'required' => true, ],
'description' => [ 'required' => false, ],
'namespace' => [ 'required' => false, ],
'view_id' => [ 'required' => true, ],
'entity' => [ 'required' => true, ],
'requete' => [ 'required' => true, ],
......
......@@ -16,6 +16,7 @@ class IndicateurHydrator implements HydratorInterface {
$data = [
'libelle' => $object->getTitre(),
'description' => $object->getDescription(),
'namespace' => $object->getNamespace(),
'view_id' => $object->getViewId(),
'entity' => $object->getEntity(),
'requete' => $object->getRequete(),
......@@ -30,8 +31,11 @@ class IndicateurHydrator implements HydratorInterface {
*/
public function hydrate(array $data, $object) : object
{
$namespace = (isset($data['namespace']) AND trim($data['namespace']) !== '')?trim($data['namespace']):null;
$object->setTitre($data['libelle']);
$object->setDescription($data['description']);
$object->setNamespace($namespace);
$object->setViewId($data['view_id']);
$object->setEntity($data['entity']);
$object->setRequete($data['requete']);
......
......@@ -37,6 +37,17 @@ class TableauDeBordForm extends Form {
'class' => 'type2 form-control',
]
]);
// libelle
$this->add([
'type' => Text::class,
'name' => 'namespace',
'options' => [
'label' => "Namespace :",
],
'attributes' => [
'id' => 'namespace',
],
]);
// nbCOlum
$this->add([
'name' => 'nb_colonne',
......@@ -74,6 +85,7 @@ class TableauDeBordForm extends Form {
$this->setInputFilter((new Factory())->createInputFilter([
'libelle' => [ 'required' => true, ],
'description' => [ 'required' => false, ],
'namespace' => [ 'required' => false, ],
'nb_colonne' => [ 'required' => true, ],
]));
}
......
......@@ -16,6 +16,7 @@ class TableauDeBordHydrator implements HydratorInterface {
$data = [
'libelle' => $object->getTitre(),
'description' => $object->getDescription(),
'namespance' => $object->getNamespace(),
'nb_colonne' => $object->getNbColumn(),
];
return $data;
......@@ -31,10 +32,12 @@ class TableauDeBordHydrator implements HydratorInterface {
$libelle = (isset($data['libelle']) AND trim($data['libelle']) !== '')?trim($data['libelle']):null;
$description = (isset($data['description']) AND trim($data['description']) !== '')?trim($data['description']):null;
$nbColonne = (isset($data['nb_colonne']))?$data['nb_colonne']:null;
$namespace = (isset($data['namespace']) AND trim($data['namespace']) !== '')?trim($data['namespace']):null;
$object->setTitre($libelle);
$object->setDescription($description);
$object->setNbColumn($nbColonne);
$object->setNamespace($namespace);
return $object;
}
......
......@@ -219,6 +219,19 @@ class IndicateurService {
return $this->getIndicateur($id);
}
/**
* @return Indicateur[]
*/
public function getIndicateursByNamespace(?string $namespace) : array
{
$qb = $this->getObjectManager()->getRepository(Indicateur::class)->createQueryBuilder('indicateur')
->andWhere('indicateur.namespace = :namespace')
->setParameter('namespace', $namespace);
return $qb->getQuery()->getResult();
}
/** FACADE **************************************************************/
/** RECUPERATION DONNEES *****************************************************************************************
* @param Indicateur $indicateur
* @return array|null
......
......@@ -92,5 +92,16 @@ class TableauDeBordService {
return $result;
}
/**
* @return TableauDeBord[]
*/
public function getTableauxDeBordByNamespace(?string $namespace) : array
{
$qb = $this->createQueryBuilder()
->andWhere('tableau.namespace = :namespace')
->setParameter('namespace', $namespace);
return $qb->getQuery()->getResult();
}
/** FACADE ******************************************************/
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment