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

Ajustement style et correction de warning

parent 391d9afc
No related branches found
No related tags found
No related merge requests found
Pipeline #16289 passed
<?php
namespace UnicaenUtilisateur\Acl;
use BjyAuthorize\Acl\Role;
use Laminas\Permissions\Acl\Role\RoleInterface;
/**
* Rôle avec nom explicite (humainement intelligible).
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class NamedRole extends \BjyAuthorize\Acl\Role
class NamedRole extends Role
{
/**
* @var string
......@@ -31,11 +30,11 @@ class NamedRole extends \BjyAuthorize\Acl\Role
*
* @param string|null $id
* @param RoleInterface|string|null $parent
* @param string $name
* @param string $description
* @param string|null $name
* @param string|null $description
* @param bool $selectable
*/
public function __construct($id = null, $parent = null, $name = null, $description = null, $selectable = true)
public function __construct($id = null, $parent = null, ?string $name = null, ?string $description = null, bool $selectable = true)
{
parent::__construct($id, $parent);
......@@ -60,7 +59,7 @@ class NamedRole extends \BjyAuthorize\Acl\Role
*
* @return string
*/
public function getRoleName()
public function getRoleName() : string
{
return $this->roleName;
}
......@@ -71,9 +70,9 @@ class NamedRole extends \BjyAuthorize\Acl\Role
* @param string $roleName
* @return self
*/
public function setRoleName($roleName)
public function setRoleName(string $roleName) : NamedRole
{
$this->roleName = (string) $roleName;
$this->roleName = $roleName;
return $this;
}
......@@ -82,7 +81,7 @@ class NamedRole extends \BjyAuthorize\Acl\Role
*
* @return string
*/
public function getRoleDescription()
public function getRoleDescription() : string
{
return $this->roleDescription;
}
......@@ -90,12 +89,12 @@ class NamedRole extends \BjyAuthorize\Acl\Role
/**
* Spécifie la description du rôle.
*
* @param string $roleDescription
* @param string|null $roleDescription
* @return self
*/
public function setRoleDescription($roleDescription)
public function setRoleDescription(?string $roleDescription) : NamedRole
{
$this->roleDescription = (string) $roleDescription;
$this->roleDescription = $roleDescription;
return $this;
}
......@@ -106,7 +105,7 @@ class NamedRole extends \BjyAuthorize\Acl\Role
*
* @return bool
*/
public function getSelectable()
public function getSelectable() : bool
{
return $this->selectable;
}
......@@ -119,7 +118,7 @@ class NamedRole extends \BjyAuthorize\Acl\Role
* @param bool $selectable
* @return NamedRole
*/
public function setSelectable($selectable = true)
public function setSelectable(bool $selectable = true) : NamedRole
{
$this->selectable = $selectable;
return $this;
......
......@@ -10,7 +10,6 @@ use UnicaenUtilisateur\Entity\Db\RoleInterface;
use UnicaenUtilisateur\Entity\Db\UserInterface;
use UnicaenUtilisateur\Form\Role\RoleFormAwareTrait;
use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait;
use Laminas\Http\Request;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Laminas\View\Model\ViewModel;
......@@ -29,19 +28,18 @@ class RoleController extends AbstractActionController {
$this->identityProviders = $provider;
}
public function indexAction()
public function indexAction() : ViewModel
{
/** @var RoleInterface[] $roles */
$roles = $this->roleService->findAll();
return new ViewModel([
'title' => "Gestion des rôles",
'roles' => $roles,
'identityproviders' => $this->identityProviders,
]);
}
public function exporterAction()
public function exporterAction() : CsvModel
{
$role = $this->roleService->getRequestedRole($this);
......@@ -84,7 +82,7 @@ class RoleController extends AbstractActionController {
return $CSV;
}
public function ajouterAction()
public function ajouterAction() : ViewModel
{
$role = $this->roleService->getEntityInstance();
$form = $this->roleForm;
......@@ -113,7 +111,7 @@ class RoleController extends AbstractActionController {
return $view;
}
public function modifierAction()
public function modifierAction() : ViewModel
{
$role = $this->roleService->getRequestedRole($this);
$form = $this->roleForm;
......@@ -142,8 +140,9 @@ class RoleController extends AbstractActionController {
return $view;
}
public function supprimerAction()
public function supprimerAction() : array
{
$role = null;
try {
$role = $this->roleService->getRequestedRole($this);
$this->roleService->delete($role);
......
......@@ -3,20 +3,22 @@
namespace UnicaenUtilisateur\Controller;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenUtilisateur\Form\Role\RoleForm;
use UnicaenUtilisateur\Service\Role\RoleService;
class RoleControllerFactory {
/**
* Create controller
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return RoleController|object
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
public function __invoke(ContainerInterface $container, string $requestedName, array $options = null)
{
/**
* @var RoleService $roleService
......
......@@ -4,6 +4,7 @@ namespace UnicaenUtilisateur\Controller;
use BjyAuthorize\Provider\Identity\ProviderInterface;
use DateTime;
use Exception;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenApp\View\Model\CsvModel;
use UnicaenUtilisateur\Entity\Db\UserInterface;
......@@ -13,7 +14,6 @@ use UnicaenUtilisateur\Service\RechercheIndividu\RechercheIndividuResultatInterf
use UnicaenUtilisateur\Service\RechercheIndividu\RechercheIndividuServiceInterface;
use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Laminas\Http\Request;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Laminas\View\Model\JsonModel;
......@@ -42,24 +42,18 @@ class UtilisateurController extends AbstractActionController
/**
* @param $searchServices
* @return self
*/
public function setSearchServices($searchServices)
public function setSearchServices($searchServices) : void
{
$this->searchServices = $searchServices;
return $this;
}
/**
* @param $provider
* @return self
*/
public function setIdentityProvider($provider)
public function setIdentityProvider($provider) : void
{
$this->identityProvider = $provider;
return $this;
}
public function indexAction()
......@@ -196,6 +190,7 @@ class UtilisateurController extends AbstractActionController
public function changerStatutAction()
{
$utilisateur = null;
try {
$utilisateur = $this->userService->getRequestedUser($this);
$utilisateur = $this->userService->changeStatus($utilisateur);
......@@ -214,6 +209,7 @@ class UtilisateurController extends AbstractActionController
public function supprimerAction()
{
$utilisateur = null;
try {
$utilisateur = $this->userService->getRequestedUser($this);
$this->userService->delete($utilisateur);
......@@ -269,7 +265,7 @@ class UtilisateurController extends AbstractActionController
return new JsonModel($result);
}
public function listerAction()
public function listerAction() : ViewModel
{
$users = $this->userService->findAll();
......@@ -279,7 +275,7 @@ class UtilisateurController extends AbstractActionController
]);
}
public function exporterAction()
public function exporterAction() : CsvModel
{
$users = $this->userService->findAll();
$headers = [ 'Identifiant de connexion', 'Nom', 'Activé', 'Rôle'];
......
......@@ -2,9 +2,9 @@
namespace UnicaenUtilisateur\Controller;
use Application\Provider\IdentityProvider;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenUtilisateur\Form\User\UserForm;
use UnicaenUtilisateur\Form\User\UserRechercheForm;
use UnicaenUtilisateur\Service\RechercheIndividu\RechercheIndividuServiceInterface;
......@@ -15,14 +15,14 @@ class UtilisateurControllerFactory
{
/**
* Create controller
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return UtilisateurController|object
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
public function __invoke(ContainerInterface $container, string $requestedName, array $options = null)
{
/**
* @var RoleService $roleService
......
......@@ -19,7 +19,7 @@ abstract class AbstractRole implements RoleInterface
protected $roleId;
/**
* @var libelle
* @var string
*/
protected $libelle;
......@@ -78,9 +78,9 @@ abstract class AbstractRole implements RoleInterface
/**
* Get id.
*
* @return int
* @return int|null
*/
public function getId()
public function getId() : ?int
{
return $this->id;
}
......
......@@ -3,14 +3,12 @@
namespace UnicaenUtilisateur\Service\Role;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\QueryBuilder;
use InvalidArgumentException;
use Laminas\Mvc\Controller\AbstractActionController;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenUtilisateur\Entity\Db\AbstractRole;
use UnicaenUtilisateur\Entity\Db\RoleInterface;
use UnicaenUtilisateur\Exception\RuntimeException;
use Laminas\Mvc\Controller\AbstractActionController;
class RoleService
{
......@@ -26,7 +24,7 @@ class RoleService
* @param string $roleEntityClass
* @return void
*/
public function setRoleEntityClass($roleEntityClass)
public function setRoleEntityClass(string $roleEntityClass)
{
if (! class_exists($roleEntityClass) || ! in_array(RoleInterface::class, class_implements($roleEntityClass))) {
throw new InvalidArgumentException("L'entité associée aux rôles doit implémenter " . RoleInterface::class);
......@@ -38,7 +36,7 @@ class RoleService
/**
* @return string
*/
public function getEntityClass()
public function getEntityClass() : string
{
return $this->roleEntityClass;
}
......@@ -62,10 +60,10 @@ class RoleService
}
/**
* @param mixed $id
* @param ?int $id
* @return RoleInterface|null
*/
public function find($id)
public function find(?int $id)
{
return $this->getRepo()->find($id);
}
......@@ -99,7 +97,7 @@ class RoleService
/**
* @return array
*/
public function getRolesAsOptions()
public function getRolesAsOptions() : array
{
$roles = $this->findAll();
$result = [];
......@@ -116,7 +114,7 @@ class RoleService
* @param string $paramName
* @return RoleInterface
*/
public function getRequestedRole(AbstractActionController $controller, string $paramName = 'role')
public function getRequestedRole(AbstractActionController $controller, string $paramName = 'role') : RoleInterface
{
$id = $controller->params()->fromRoute($paramName);
$role = $this->find($id);
......@@ -128,7 +126,7 @@ class RoleService
* @param RoleInterface $role
* @return RoleInterface
*/
public function create(RoleInterface $role)
public function create(RoleInterface $role) : RoleInterface
{
try {
$this->getEntityManager()->persist($role);
......@@ -144,7 +142,7 @@ class RoleService
* @param RoleInterface $role
* @return RoleInterface
*/
public function update(RoleInterface $role)
public function update(RoleInterface $role) : RoleInterface
{
try {
$this->getEntityManager()->flush($role);
......@@ -159,7 +157,7 @@ class RoleService
* @param RoleInterface $role
* @return RoleInterface
*/
public function delete(RoleInterface $role)
public function delete(RoleInterface $role) : RoleInterface
{
try {
$this->getEntityManager()->remove($role);
......
......@@ -17,12 +17,12 @@ $canAjouter = $this->isAllowed(RolePrivileges::getResourceId(RolePrivileges:
$canModifier = $this->isAllowed(RolePrivileges::getResourceId(RolePrivileges::ROLE_MODIFIER));
$canEffacer = $this->isAllowed(RolePrivileges::getResourceId(RolePrivileges::ROLE_EFFACER));
?>
$this->headTitle("Rôles");
<?php $this->headTitle($this->translate($title)) ?>
?>
<h1 class="page-header">
<?php echo $title; ?>
Rôles
<span class="badge"><?php echo count($roles); ?></span>
</h1>
......@@ -41,7 +41,7 @@ $canEffacer = $this->isAllowed(RolePrivileges::getResourceId(RolePrivileges:
<?php endif; ?>
<div class="card border-default mb-3">
<div class="card">
<div class="card-header bg-default">
<h2>
Liste des rôles
......@@ -91,7 +91,7 @@ $canEffacer = $this->isAllowed(RolePrivileges::getResourceId(RolePrivileges:
}
?>
<?php if($result): ?>
<i class="fas fa-user"></i> <?php echo $nbUser; ?>
<i class="fas fa-user"></i> <?php echo count($result); ?>
<?php else: ?>
<span class="text-warning"><i class="fas fa-exclamation-triangle"></i> Aucune méthode de calcul associée à ce rôle automatique.</span>
<?php endif; ?>
......@@ -166,9 +166,7 @@ $canEffacer = $this->isAllowed(RolePrivileges::getResourceId(RolePrivileges:
$("body").on("event-unicaen-role-editer", function (event) {
event.div.modal('hide');
window.location.reload();
});
$("body").on("event-unicaen-role-supprimer", function (event) {
}).on("event-unicaen-role-supprimer", function (event) {
window.location.reload();
});
......@@ -194,7 +192,7 @@ $canEffacer = $this->isAllowed(RolePrivileges::getResourceId(RolePrivileges:
"next": "<i class=\"fas fa-chevron-right\"></i>"
}
},
"createdRow": function (row, data, index) {
"createdRow": function (row) {
$('.pop-ajax', row).popAjax();
},
});
......
......@@ -4,7 +4,6 @@ use UnicaenUtilisateur\Controller\UtilisateurController;
use UnicaenUtilisateur\Entity\Db\RoleInterface;
use UnicaenUtilisateur\Entity\Db\UserInterface;
use UnicaenUtilisateur\Form\User\UserRechercheForm;
use UnicaenUtilisateur\Provider\Privilege\Privileges;
use UnicaenUtilisateur\Provider\Privilege\UtilisateurPrivileges;
/**
......@@ -164,7 +163,8 @@ $canCreerLocal = $canAjouter;
<button type='submit' class='btn btn-success'><i class='fas fa-check'></i> Oui</button>
<button type='button' class='btn btn-danger pop-ajax-hide'><i class='fas fa-times'></i> Non</button>
</div>
</div>">
</div>"
>
<i class="fas fa-user-times"></i> Suspendre
</a>
......@@ -176,15 +176,14 @@ $canCreerLocal = $canAjouter;
data-submit-close="true"
data-submit-event="event-unicaen-utilisateur-changer-statut"
title="Activer l'utilisateur"
data-title="Activation de l'utilisateur
data-confirm-button=""
data-cancel-button=""
data-content="<p>Voulez-vous activer
l'utilisateur ?</p>
<div class='text-center'>
<div class='btn-group'>
<button type='submit' class='btn btn-success'><i class='fas fa-check'></i> Oui</button>
<button type='button' class='btn btn-danger pop-ajax-hide'><i class='fas fa-times'></i> Non
data-title="Activation de l'utilisateur"
data-confirm-button="
data-cancel-button=''
data-content='<p>Voulez-vous activer l\'utilisateur ?</p>
<div class=\'text-center\'>
<div class=\'btn-group\'>
<button type=\'submit\' class=\'btn btn-success\'><i class=\'fas fa-check\'></i> Oui</button>
<button type=\'button\' class=\'btn btn-danger pop-ajax-hide\'><i class=\'fas fa-times\'></i> Non
</button>
</div>
</div>">
......@@ -297,9 +296,7 @@ $canCreerLocal = $canAjouter;
function (event) {
event.div.modal('hide');
window.location.reload();
});
$("body").on("event-unicaen-utilisateur-changer-statut " +
}).on("event-unicaen-utilisateur-changer-statut " +
"event-unicaen-utilisateur-supprimer",
function (event) {
window.location.reload();
......@@ -333,13 +330,13 @@ $canCreerLocal = $canAjouter;
},
})
.autocomplete("instance")._renderItem = function (ul, item) {
var template = '<span id=\"{id}\">{label} <span class=\"extra\">{extra}</span></span>';
var markup = template
let template = '<span id=\"{id}\">{label} <span class=\"extra\">{extra}</span></span>';
let markup = template
.replace('{id}', item.id ? item.id : '')
.replace('{label}', item.label ? item.label : '')
.replace('{extra}', item.extra ? item.extra : '');
markup = '<a id="autocomplete-item-' + item.id + '">' + markup + "</a>";
var li = $("<li></li>");
let li = $("<li></li>");
if (item.id) {
const t = item.id.split("||");
if (t[0] == 'app') {
......@@ -360,7 +357,7 @@ $canCreerLocal = $canAjouter;
};
$('form').on('submit', function () {
var btn = $(this).find('button[type="submit"]:first');
let btn = $(this).find('button[type="submit"]:first');
btn.attr("disabled", "disabled")
.find('i').attr('class', 'fas fa-pulse fa-spinner');
});
......@@ -432,7 +429,5 @@ $canCreerLocal = $canAjouter;
cursor: pointer;
}
.text-highlight {
color: #919191;
}
</style>
\ No newline at end of file
......@@ -4,6 +4,7 @@ use UnicaenUtilisateur\Entity\Db\UserInterface;
/**
* @var UserInterface[] $users
* @var string $title
*/
?>
......@@ -94,14 +95,14 @@ use UnicaenUtilisateur\Entity\Db\UserInterface;
"next": "<i class=\"fas fa-chevron-right\"></i>"
}
},
"createdRow": function (row, data, index) {
"createdRow": function (row) {
$('.pop-ajax', row).popAjax();
},
});
}
$('#utilisateur-liste tbody').on('click', 'tr', function () {
var href = $(this).find("a").attr("href");
let href = $(this).find("a").attr("href");
if (href) {
window.location.href = href;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment