diff --git a/view/unicaen-privilege/privilege/index.phtml b/view/unicaen-privilege/privilege/index.phtml index a29d0616c74e6a79f5974b18d9eee8912917b6c7..9c28b93a43ac1778bf1ae42f9e7935dc3c594021 100644 --- a/view/unicaen-privilege/privilege/index.phtml +++ b/view/unicaen-privilege/privilege/index.phtml @@ -6,103 +6,106 @@ use UnicaenPrivilege\Form\Privilege\CategorieFiltreForm; use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; /** - * @var string $title * @var RoleInterface[] $roles * @var array $privilegesByCategorie * @var CategorieFiltreForm $form + * @var ?string $gestion * + * @see AdministrationController::privilegeAction() * @see PrivilegeController::indexAction() */ -?> -<?php $this->headTitle($this->translate($title)) ?> +$this->headTitle("Gestion des privilèges"); +?> <h1 class="page-header"> - <?php echo $title; ?> + Gestion des privilèges </h1> <?php echo $this->messenger()->addMessagesFromFlashMessenger(); ?> -<div class="row mb-3"> - <div class="col-md-12"> -<?php /** @see PrivilegeCategorieController::indexAction() */ ?> -<a href="<?php echo $this->url('unicaen-privilege/categorie', [], []); ?>" - class="btn btn-primary"> - <i class="fas fa-crown"></i> - Gestion des privilèges -</a> - </div> -</div> - - -<div class="card border-default mb-3"> - <div class="card-header bg-default"> - <h2>Filtrer les privilèges</h2> - </div> - <div class="card-body"> -<?php echo $this->form()->openTag($form->prepare()); ?> -<div class="row"> - <div class="col-md-5"> - <?php echo $this->formControlGroup($form->get('namespace')); ?> - </div> - <div class="col-md-7"> - <div class="form-group"> - <?php echo $this->formButton($form->get('filtrer')); ?> - <?php echo $this->formButton($form->get('effacer')); ?> +<?php if ($gestion === null or $gestion !== 'off') : ?> + <div class="row mb-3"> + <div class="col-md-12"> + <?php /** @see PrivilegeCategorieController::indexAction() */ ?> + <a href="<?php echo $this->url('unicaen-privilege/categorie', [], []); ?>" + class="btn btn-primary"> + <i class="fas fa-crown"></i> + Gestion des privilèges + </a> </div> </div> -</div> - -<?php echo $this->form()->closeTag(); ?> +<?php endif; ?> + +<?php if ($form !== null) : ?> + <div class="card "> + <div class="card-header bg-default"> + <h2> + <span class="icon icon-filtrer"></span> + Filtrer les privilèges + </h2> + </div> + <div class="card-body"> + <?php echo $this->form()->openTag($form->prepare()); ?> + <div class="row"> + <div class="col-md-5"> + <?php echo $this->formControlGroup($form->get('namespace')); ?> + </div> + <div class="col-md-7"> + <div class="form-group"> + <?php echo $this->formButton($form->get('filtrer')); ?> + <?php echo $this->formButton($form->get('effacer')); ?> + </div> + </div> + </div> + + <?php echo $this->form()->closeTag(); ?> + </div> </div> -</div> +<?php endif; ?> -<div class="card border-default mb-3"> - <div class="card-header bg-default"> - <h2> - Priviléges attribués - </h2> - </div> - <div class="card-body"> <table id="privilege-liste" class="table table-hover table-condensed table-header-rotated"> - <thead> - <tr> - <th></th> - <?php $first = true; foreach( $roles as $role ):?> - <th class="rotate-45" title="<?php echo $role; ?>"><div<?php if ($first) echo ' class="first"'; ?>><span><?php echo $role; ?></span></div></th> - <?php $first = false; endforeach; ?> - <th></th> - </tr> - <tr> - <th>Privilèges <i title="Afficher / Masquer tous les privilèges" class="hide-privileges fas fa-caret-square-down"></i></th> - <th colspan="<?php echo count($roles); ?>">Rôles</th> - <th style="min-width:166px"></th> - </tr> - </thead> - <tbody> - <?php foreach ($privilegesByCategorie as $libelleCategorie => $privileges) : ?> - <tr> - <th id="<?php echo current($privileges)->getCategorie()->getId(); ?>" class="categorie" - colspan="<?php echo 1 + count($roles); ?>"><?php echo $libelleCategorie; ?> <i class="fas fa-caret-square-down text-muted"></i></th> - </tr> - <?php /** @var PrivilegeInterface $privilege */ ?> - <?php foreach ($privileges as $privilege) : ?> - <tr class="privilege categorie-id-<?php echo $privilege->getCategorie()->getId(); ?>"> - <td class="privilege"> - <?php echo $privilege; ?> - </td> - <?php foreach($roles as $role): ?> - <?php echo $this->privilege($privilege)->renderStatut($role); ?> - <?php endforeach; ?> + <thead> + <tr> + <th></th> + <?php $first = true; + foreach ($roles as $role): ?> + <th class="rotate-45" title="<?php echo $role; ?>"> + <div<?php if ($first) echo ' class="first"'; ?>><span><?php echo $role; ?></span></div> + </th> + <?php $first = false; endforeach; ?> + <th></th> </tr> - <?php endforeach; ?> - <?php endforeach; ?> - </tbody> -</table> - </div> -</div> + <tr> + <th>Privilèges <i title="Afficher / Masquer tous les privilèges" + class="hide-privileges fas fa-caret-square-down"></i></th> + <th colspan="<?php echo count($roles); ?>">Rôles</th> + <th style="min-width:166px"></th> + </tr> + </thead> + <tbody> + <?php foreach ($privilegesByCategorie as $libelleCategorie => $privileges) : ?> + <tr> + <th id="<?php echo current($privileges)->getCategorie()->getId(); ?>" class="categorie" + colspan="<?php echo 1 + count($roles); ?>"><?php echo $libelleCategorie; ?> <i + class="fas fa-caret-square-down text-muted"></i></th> + </tr> + <?php /** @var PrivilegeInterface $privilege */ ?> + <?php foreach ($privileges as $privilege) : ?> + <tr class="privilege categorie-id-<?php echo $privilege->getCategorie()->getId(); ?>"> + <td class="privilege"> + <?php echo $privilege; ?> + </td> + <?php foreach ($roles as $role): ?> + <?php echo $this->privilege($privilege)->renderStatut($role); ?> + <?php endforeach; ?> + </tr> + <?php endforeach; ?> + <?php endforeach; ?> + </tbody> + </table> <style> .table-header-rotated th.rotate-45 { @@ -111,6 +114,7 @@ use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; padding: 0; white-space: nowrap; } + .table-header-rotated th.rotate-45 > div { position: relative; top: 0; @@ -121,9 +125,11 @@ use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; border-right: 1px solid #ddd; z-index: 99; } + .table-header-rotated th.rotate-45 > div.first { border-left: 1px solid #ddd; } + .table-header-rotated th.rotate-45 span { transform: skew(40deg, 0deg) rotate(310deg); position: absolute; @@ -171,15 +177,13 @@ use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; }); }); - $("i.hide-privileges").click(function () - { + $("i.hide-privileges").click(function () { if ($(this).hasClass('fa-caret-square-down')) { $("tr.privilege").hide(); $(this) .removeClass('fa-caret-square-down') .addClass('fa-caret-square-up') - } - else { + } else { $("tr.privilege").show(); $(this) .removeClass('fa-caret-square-up') @@ -187,16 +191,14 @@ use UnicaenPrivilege\Provider\Privilege\PrivilegePrivileges; } }); - $("th.categorie > i").click(function () - { + $("th.categorie > i").click(function () { let categorieId = $(this).parent().attr("id"); $("tr.categorie-id-" + categorieId).toggle(); if ($(this).hasClass('fa-caret-square-down')) { $(this) .removeClass('fa-caret-square-down') .addClass('fa-caret-square-up') - } - else { + } else { $(this) .removeClass('fa-caret-square-up') .addClass('fa-caret-square-down')