Commit 06b5a7ca authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Nettoyage de code mort lié à un ancien embryon de module admin. des structures

parent e8cfaf2d
......@@ -16,63 +16,15 @@ return [
],
'may_terminate' => true,
'child_routes' => [
'modifier' => [
'voir' => [
'type' => 'Segment',
'options' => [
'route' => '/modifier/:id',
'route' => '/voir/:structure',
'constraints' => [
'id' => '[0-9]*',
'structure' => '[0-9]*',
],
'defaults' => [
'action' => 'modifier',
],
],
],
'recherche' => [
'type' => 'Segment',
'options' => [
'route' => '/recherche[/:term]',
'defaults' => [
'action' => 'recherche',
],
],
],
'default' => [
'type' => 'Segment',
'options' => [
'route' => '/:action[/:id]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]*',
],
'defaults' => [
'action' => 'index',
],
],
],
],
],
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'structure' => [
'label' => 'Structures',
'title' => "Gestion des structures",
'route' => 'structure',
'visible' => false,
'params' => [
'action' => 'index',
],
'pages' => [
'voir' => [
'label' => "Voir",
'title' => "Voir une structure",
'route' => 'structure',
'visible' => false,
'pages' => [],
'action' => 'voir',
],
],
],
......@@ -80,17 +32,13 @@ return [
],
],
],
'bjyauthorize' => [
'guards' => [
'BjyAuthorize\Guard\Controller' => [
[
'controller' => 'Application\Controller\Structure',
'action' => ['voir', 'apercevoir'],
'roles' => ['user'],
],
[
'controller' => 'Application\Controller\Structure',
'action' => ['index', 'choisir', 'recherche'],
'action' => ['voir'],
'roles' => ['user'],
],
],
......
......@@ -3,8 +3,7 @@
namespace Application\Controller;
use RuntimeException;
use LogicException;
use Zend\View\Model\JsonModel;
/**
* Description of StructureController
......@@ -13,80 +12,16 @@ use Zend\View\Model\JsonModel;
*/
class StructureController extends AbstractController
{
use \Application\Service\Traits\ContextServiceAwareTrait;
use \Application\Service\Traits\StructureServiceAwareTrait;
public function indexAction()
{
$url = $this->url()->fromRoute('structure/default', ['action' => 'choisir']);
return $this->redirect()->toUrl($url);
}
/**
*
* @return \Zend\View\Model\ViewModel
* @todo placer le formulaire danx une classe à part
*/
public function choisirAction()
{
$url = $this->url()->fromRoute('structure/recherche');
$structure = new \UnicaenApp\Form\Element\SearchAndSelect('structure');
$structure->setAutocompleteSource($url)
->setRequired(true)
->setSelectionRequired(true)
->setLabel("Recherchez la structure concernée :")
->setAttributes(['title' => "Saisissez le nom de la structure"]);
$form = new \Zend\Form\Form('search');
$form->setAttributes(['class' => 'structure-rech']);
$form->add($structure);
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost();
$form->setData($data);
if ($form->isValid()) {
$url = $this->url()->fromRoute('structure/default', ['action' => 'voir', 'id' => $form->get('structure')->getValueId() ] );
return $this->redirect()->toUrl($url);
}
}
return compact('form');
}
public function rechercheAction()
{
$this->em()->getFilters()->enable('historique')->init([
\Application\Entity\Db\Structure::class
]);
if (!($term = $this->params()->fromQuery('term'))) {
return new JsonModel([]);
}
$entities = $this->getServiceStructure()->finderByNom($term)->getQuery()->execute();
$result = [];
foreach ($entities as $item) { /* @var $item \Application\Entity\Db\Structure */
$result[] = [
'id' => $item->getId(), // identifiant unique de l'item
'label' => $item->getLibelleLong(), // libellé de l'item
'extra' => $item->getLibelleCourt(), // infos complémentaires (facultatives) sur l'item
];
};
return new JsonModel($result);
}
public function voirAction()
{
if (!($id = $this->params()->fromRoute('id', $this->params()->fromPost('id')))) {
throw new LogicException("Aucun identifiant de structure spécifié.");
}
if (!($structure = $this->getServiceStructure()->get($id))) {
throw new RuntimeException("Structure '$id' spécifiée introuvable.");
$structure = $this->getEvent()->getParam('structure');
if (!$structure) {
throw new RuntimeException("Structure non spécifiée ou introuvable.");
}
$title = "Structure";
$title = (string)$structure;
return compact('structure', 'title');
}
......
......@@ -171,9 +171,8 @@ class Ligne extends AbstractViewHelper
{
if (! $structure) return '';
$url = $this->getView()->url('structure/default', ['action' => 'voir', 'id' => $structure->getId()]);
$pourl = $this->getView()->url('structure/default', ['action' => 'apercevoir', 'id' => $structure->getId()]);
$out = '<a href="'.$url.'" data-po-href="'.$pourl.'" class="ajax-modal">'.$structure.'</a>';
$url = $this->getView()->url('structure/voir', ['structure' => $structure->getId()]);
$out = '<a href="'.$url.'" class="ajax-modal">'.$structure.'</a>';
return $out;
}
......
......@@ -2,7 +2,6 @@
namespace Application\View\Helper;
use Zend\View\Helper\AbstractHelper;
use Application\Entity\Db\Structure;
use Application\Entity\Db\Traits\StructureAwareTrait;
......@@ -11,7 +10,7 @@ use Application\Entity\Db\Traits\StructureAwareTrait;
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class StructureViewHelper extends AbstractHelper
class StructureViewHelper extends AbstractViewHelper
{
use StructureAwareTrait;
......@@ -85,9 +84,8 @@ class StructureViewHelper extends AbstractHelper
return '<span class="bg-danger"><abbr title="Cette structure n\'existe plus">' . $structure . '</abbr></span>';
}
$url = $this->getView()->url('structure/default', ['action' => 'voir', 'id' => $structure->getId()]);
$pourl = $this->getView()->url('structure/default', ['action' => 'apercevoir', 'id' => $structure->getId()]);
$out = '<a href="' . $url . '" data-po-href="' . $pourl . '" class="ajax-modal">' . $structure . '</a>';
$url = $this->getView()->url('structure/voir', ['structure' => $structure->getId()]);
$out = '<a href="' . $url . '" class="ajax-modal">' . $structure . '</a>';
return $out;
}
......
<h1><?= $structure ?></h1>
<?= $this->structure($structure) ?>
<div class="jumbotron">
<h1>Choisir une structure</h1>
</div>
<style>
span.sas-highlight { font-weight: bold; }
</style>
<?php $form->prepare(); ?>
<?= $this->form()->openTag($form) ?>
<?= $this->formControlGroup($form->get('structure')); ?>
<input class="btn btn-primary" type="submit" value="Choisir" name="submit">
<?= $this->form()->closeTag() ?>
<script>
$(function() {
$(":input").tooltip({ /*placement: 'left'*/ });
});
</script>
\ No newline at end of file
<h1><?= $structure ?></h1>
<?= $this->structure($structure);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment