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

Debut d'interface de gestion des instances

parent 5953e051
No related branches found
No related tags found
No related merge requests found
Pipeline #16080 passed
......@@ -2,6 +2,9 @@
namespace UnicaenEtat;
use UnicaenEtat\Controller\EtatInstanceController;
use UnicaenEtat\Controller\EtatInstanceControllerFactory;
use UnicaenEtat\Provider\Privilege\EtatPrivileges;
use UnicaenEtat\Service\EtatInstance\EtatInstanceService;
use UnicaenEtat\Service\EtatInstance\EtatInstanceServiceFactory;
use UnicaenEtat\View\Helper\EtatInstanceViewHelper;
......@@ -13,12 +16,57 @@ return [
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => EtatInstanceController::class,
'action' => [
'index',
],
'privileges' => [
EtatPrivileges::ETAT_INDEX,
],
],
[
'controller' => EtatInstanceController::class,
'action' => [
'supprimer',
],
'privileges' => [
EtatPrivileges::ETAT_DETRUIRE,
],
],
],
],
],
'router' => [
'routes' => [
'unicaen-etat' => [
'child_routes' => [
'etat-instance' => [
'type' => Literal::class,
'options' => [
'route' => '/etat-instance',
'defaults' => [
'controller' => EtatInstanceController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'supprimer' => [
'type' => Literal::class,
'options' => [
'route' => '/supprimer/:instance',
'defaults' => [
'controller' => EtatInstanceController::class,
'action' => 'supprimer',
],
],
],
],
],
],
],
],
],
......@@ -28,7 +76,9 @@ return [
],
],
'controllers' => [
'factories' => [],
'factories' => [
EtatInstanceController::class => EtatInstanceControllerFactory::class,
],
],
'form_elements' => [
'factories' => [],
......
<?php
namespace UnicaenEtat\Controller;
use Laminas\Http\Request;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
use UnicaenEtat\Service\EtatInstance\EtatInstanceServiceAwareTrait;
class EtatInstanceController extends AbstractActionController {
use EtatInstanceServiceAwareTrait;
public function indexAction() : ViewModel
{
$instances = $this->getEtatInstanceService()->getEtatsInstances();
return new ViewModel([
'instances' => $instances,
]);
}
public function supprimerAction()
{
$etat = $this->getEtatInstanceService()->getResquestedEtatInstance($this);
/** @var Request $request */
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
if ($data["reponse"] === "oui") $this->getEtatInstanceService()->delete($etat);
exit();
}
$vm = new ViewModel();
if ($etat !== null) {
$vm->setTemplate('unicaen-etat/default/confirmation');
$vm->setVariables([
'title' => "Suppression de l'instance d'état " . $etat->getId(),
'text' => "La suppression est définitive êtes-vous sûr&middot;e de vouloir continuer ?",
'action' => $this->url()->fromRoute('unicaen-etat/etat-instance/supprimer', ["instance" => $etat->getId()], [], true),
]);
}
return $vm;
}
}
\ No newline at end of file
<?php
namespace UnicaenEtat\Controller;
use Interop\Container\ContainerInterface;
use UnicaenEtat\Service\EtatInstance\EtatInstanceService;
class EtatInstanceControllerFactory {
/**
* @param ContainerInterface $container
* @return EtatInstanceController
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container) : EtatInstanceController
{
/**
* @var EtatInstanceService $instanceService
*/
$instanceService = $container->get(EtatInstanceService::class);
$controller = new EtatInstanceController();
$controller->setEtatInstanceService($instanceService);
return $controller;
}
}
\ No newline at end of file
<?php
/**
* @see \UnicaenEtat\Controller\EtatCategorieController::indexAction()
* @var EtatInstance[] $instances
*/
use UnicaenEtat\Entity\Db\EtatInstance;
$this->headTitle("Catégories d'état");
?>
<div class="row">
<div class="col-md-8">
<h1 class="page-header">
Instances d'état
<span class="badge"><?php echo count($instances); ?></span>
</h1>
<!-- --><?php ///** @see \UnicaenEtat\Controller\EtatCategorieController::ajouterAction() */ ?>
<!-- <a href="--><?php //echo $this->url('unicaen-etat/etat-instance/ajouter', [], [], true); ?><!--"-->
<!-- class="btn btn-primary action ajax-modal" data-event="modification">-->
<!-- <span class="icon ajouter"></span>-->
<!-- Ajouter une catégorie d'état-->
<!-- </a>-->
</div>
<div class="pull-right">
<?php /** @see \UnicaenEtat\Controller\EtatTypeController::indexAction() */ ?>
<a href="<?php echo $this->url('unicaen-etat/etat-type', [], [], true); ?>"
class="btn btn-primary action">
<span class="icon acceder"></span>
Accéder aux types
</a>
<br/>
<a href="<?php echo $this->url('unicaen-etat/etat-categorie', [], [], true); ?>"
class="btn btn-primary action ">
<span class="icon acceder"></span>
Accéder aux catégories
</a>
</div>
</div>
<span class="todo"> filtre</span> <br><br>
<table class="table table-condensed table-hover">
<thead>
<tr>
<th> Badge</th>
<th> Catégorie </th>
<th> Type </th>
<th> Date </th>
<th> Utilisateur </th>
<th> Action </th>
</tr>
</thead>
<tbody>
<?php foreach ($instances as $instance) : ?>
<tr>
<td> <?php echo $this->etattype($instance->getType()); ?> </td>
<td> <?php echo ($instance->getType()->getCategorie())?$instance->getType()->getCategorie()->getCode():"Sans catégorie"; ?> </td>
<td> <?php echo $instance->getType()->getCode(); ?> </td>
<td> <?php echo $instance->getHistoCreation()->format('d/m/Y à H:i'); ?> </td>
<td> <?php echo $instance->getHistoCreateur()->getDisplayName() ?> </td>
<td>
<span class="icon editer"></span>
<a href="<?php echo $this->url(); ?>"
class="ajax-modal" data-event="modification"
>
<span class="icon detruire text-danger"></span></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script>
$(function() {
$("body").on("modification", function (event) {
event.div.modal('hide');
window.location.reload();
});
});
</script>
\ No newline at end of file
......@@ -31,10 +31,10 @@ $this->headTitle("Types d'état")
Accéder aux catégories
</a>
<br/>
<a href="<?php echo $this->url('unicaen-etat/etat-type/ajouter', [], [], true); ?>"
class="btn btn-primary action disabled">
<a href="<?php echo $this->url('unicaen-etat/etat-instance', [], [], true); ?>"
class="btn btn-primary action">
<span class="icon acceder"></span>
Accéder aux instances TODO
Accéder aux instances
</a>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment