Commit 56dd5ac1 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Nouvelle action + amélioration IHM

parent 811d359e
Loading
Loading
Loading
Loading
Loading
+32 −9
Original line number Diff line number Diff line
@@ -24,28 +24,37 @@ return [
                    'action' => [
                        'ajouter',
                    ],
                    'privileges' => ParametrePrivileges::PARAMETRE_AJOUTER,
                    'privileges' => [
                        ParametrePrivileges::PARAMETRE_AJOUTER,
                    ]
                ],
                [
                    'controller' => ParametreController::class,
                    'action' => [
                        'modifier',
                    ],
                    'privileges' => ParametrePrivileges::PARAMETRE_MODIFIER,
                    'privileges' => [
                        ParametrePrivileges::PARAMETRE_MODIFIER,
                    ],
                ],
                [
                    'controller' => ParametreController::class,
                    'action' => [
                        'modifier-valeur',
                        'reinitialiser-valeur',
                    ],
                    'privileges' => [
                        ParametrePrivileges::PARAMETRE_VALEUR,
                    ],
                    'privileges' => ParametrePrivileges::PARAMETRE_VALEUR,
                ],
                [
                    'controller' => ParametreController::class,
                    'action' => [
                        'supprimer',
                    ],
                    'privileges' => ParametrePrivileges::PARAMETRE_SUPPRIMER,
                    'privileges' => [
                        ParametrePrivileges::PARAMETRE_SUPPRIMER,
                    ],
                ],
            ],
        ],
@@ -57,15 +66,19 @@ return [
                'type'  => Literal::class,
                'options' => [
                    'route'    => '/parametre',
                    'defaults' => [
                       'controller' => ParametreController::class,
                        'action' => 'ajouter'
                    ],
                ],
                'may_terminate' => false,
                'may_terminate' => true,
                'child_routes' => [
                    'ajouter' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/ajouter/:categorie',
                            'defaults' => [
                                'controller' => ParametreController::class,
                                /** @see ParametreController::ajouterAction() */
                                'action' => 'ajouter'
                            ],
                        ],
@@ -75,7 +88,7 @@ return [
                        'options' => [
                            'route'    => '/modifier/:parametre',
                            'defaults' => [
                                'controller' => ParametreController::class,
                                /** @see ParametreController::modifierAction() */
                                'action' => 'modifier'
                            ],
                        ],
@@ -85,7 +98,7 @@ return [
                        'options' => [
                            'route'    => '/supprimer/:parametre',
                            'defaults' => [
                                'controller' => ParametreController::class,
                                /** @see ParametreController::supprimerAction() */
                                'action' => 'supprimer'
                            ],
                        ],
@@ -95,11 +108,21 @@ return [
                        'options' => [
                            'route'    => '/modifier-valeur/:parametre',
                            'defaults' => [
                                'controller' => ParametreController::class,
                                /** @see ParametreController::modifierValeurAction() */
                                'action' => 'modifier-valeur'
                            ],
                        ],
                    ],
                    'reinitialiser-valeur' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/reinitialiser-valeur/:parametre',
                            'defaults' => [
                                /** @see ParametreController::reinitialiserValeurAction() */
                                'action' => 'reinitialiser-valeur'
                            ],
                        ],
                    ],
                ],
            ],
        ],
+12 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace UnicaenParametre\Controller;

use Laminas\Http\Response;
use UnicaenParametre\Entity\Db\Parametre;
use UnicaenParametre\Form\Parametre\ParametreFormAwareTrait;
use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait;
@@ -107,4 +108,15 @@ class ParametreController extends AbstractActionController {
            'parametre' => $parametre,
        ]);
    }

    public function reinitialiserValeurAction() : Response
    {
        $parametre = $this->getParametreService()->getRequestedParametre($this);
        $parametre->setValeur(null);
        $this->getParametreService()->update($parametre);

        $retour = $this->params()->fromQuery('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('parametre/index');
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ class CategorieForm extends Form {
            ],
            'attributes' => [
                'type' => 'submit',
                'class' => 'btn btn-primary',
                'class' => 'btn btn-success',
            ],
        ]);
        //input filter
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ class ParametreForm extends Form {
            ],
            'attributes' => [
                'type' => 'submit',
                'class' => 'btn btn-primary',
                'class' => 'btn btn-success',
            ],
        ]);
        //input filter
+81 −48
Original line number Diff line number Diff line
@@ -10,8 +10,13 @@
use UnicaenParametre\Entity\Db\Categorie;
use UnicaenParametre\Entity\Db\Parametre;
use UnicaenParametre\Provider\Privilege\ParametrecategoriePrivileges;
use UnicaenParametre\Provider\Privilege\ParametrePrivileges;

$canAjouterCategorie = $this->isAllowed(ParametrecategoriePrivileges::getResourceId(ParametrecategoriePrivileges::PARAMETRECATEGORIE_AJOUTER));
$canValeurParametre = $this->isAllowed(ParametrePrivileges::getResourceId(ParametrePrivileges::PARAMETRE_VALEUR));
$canAjouterParametre = $this->isAllowed(ParametrePrivileges::getResourceId(ParametrePrivileges::PARAMETRE_AJOUTER));
$canModifierParametre = $this->isAllowed(ParametrePrivileges::getResourceId(ParametrePrivileges::PARAMETRE_MODIFIER));
$canSupprimerParametre = $this->isAllowed(ParametrePrivileges::getResourceId(ParametrePrivileges::PARAMETRE_SUPPRIMER));

$array_categorie = [];
$array_parametre = [];
@@ -30,7 +35,7 @@ if ($selection !== null) $categories = [ $selection ];
    Affichage des paramètres
</h1>

<?php if ($selection === null AND $canAjouterCategorie) : ?>
<?php if ($selection === null and $canAjouterCategorie) : ?>
    <a
        <?php /** @see \UnicaenParametre\Controller\CategorieController::ajouterAction() */ ?>
            href="<?php echo $this->url('parametre/categorie/ajouter', ['categorie' => -1], [], true); ?>"
@@ -42,7 +47,8 @@ if ($selection !== null) $categories = [ $selection ];
<?php foreach ($categories as $categorie) : ?>
    <?php $id = $categorie->getId(); ?>

            <h2 title="<?php echo $categorie->getDescription(); ?>" data-bs-toggle="tooltip" data-bs-html="true" style="cursor: help;"> Catégorie : <?php echo $categorie->getLibelle(); ?> </h2>
    <h2 title="<?php echo $categorie->getDescription(); ?>" data-bs-toggle="tooltip" data-bs-html="true"
        style="cursor: help;"> Catégorie : <?php echo $categorie->getLibelle(); ?> </h2>

    <a <?php /** @see \UnicaenParametre\Controller\ParametreController::ajouterAction() */ ?>
            href="<?php echo $this->url('parametre/ajouter', ['categorie' => $categorie->getId()], [], true); ?>"
@@ -55,7 +61,7 @@ if ($selection !== null) $categories = [ $selection ];
                class="btn btn-primary ajax-modal" data-event="modification">
            <i class="fas fa-pencil-alt"></i> Modifier la catégorie
        </a>
                <?php if (!isset($array_parametre[$id]) OR empty ($array_parametre[$id])) : ?>
        <?php if (!isset($array_parametre[$id]) or empty ($array_parametre[$id])) : ?>
            <a <?php /** @see \UnicaenParametre\Controller\CategorieController::supprimerAction() */ ?>
                    href="<?php echo $this->url('parametre/categorie/supprimer', ['categorie' => $categorie->getId()], [], true); ?>"
                    class="btn btn-danger ajax-modal" data-event="modification">
@@ -78,13 +84,13 @@ if ($selection !== null) $categories = [ $selection ];
        <table class="table table-condensed">
            <thead>
            <tr>
                <th style="width:60%; min-width:20rem;">
                <th class="col-md-5">
                    Paramètre
                </th>
                <th style="width:30%; min-width:10rem;">
                <th class="col-md-5">
                    Valeur
                </th>
                <th>
                <th class="col-md action">
                    Action
                </th>
            </tr>
@@ -93,7 +99,8 @@ if ($selection !== null) $categories = [ $selection ];
            <?php foreach ($array_parametre[$id] as $parametre) : ?>
                <tr>
                    <td>
                        <span title="<?php echo $parametre->getDescription(); ?>" data-bs-toggle="tooltip" data-bs-html="true" style="cursor: help;">
                        <span title="<?php echo $parametre->getDescription(); ?>" data-bs-toggle="tooltip"
                              data-bs-html="true" style="cursor: help;">
                            <?php echo $parametre->getLibelle(); ?>
                        </span>
                    </td>
@@ -107,22 +114,48 @@ if ($selection !== null) $categories = [ $selection ];
                        };
                        ?>
                    </td>
                    <td>
                    <td class="action">
                        <?php if ($canValeurParametre) : ?>
                            <a <?php /** @see \UnicaenParametre\Controller\ParametreController::modifierValeurAction() */ ?>
                                    href="<?php echo $this->url('parametre/modifier-valeur', ['parametre' => $parametre->getId()], [], true); ?>"
                                    title="Modifier la valeur du paramètre [<?php echo $parametre->getCode(); ?>]"
                            class="ajax-modal" data-event="modification" >
                            <i class="fas fa-pencil-alt"></i></a>
                                    class="ajax-modal action primary " data-event="modification">
                                <span class="icon icon-modifier"></span>
                                Modifier
                            </a>

                        <?php endif; ?>
                        <?php if ($canModifierParametre) : ?>
                            <br>
                            <a <?php /** @see \UnicaenParametre\Controller\ParametreController::modifierAction() */ ?>
                                    href="<?php echo $this->url('parametre/modifier', ['parametre' => $parametre->getId()], [], true); ?>"
                                    title="Modifier le paramètre [<?php echo $parametre->getCode(); ?>]"
                            class="ajax-modal" data-event="modification">
                            <i class="fas fa-cog"></i></a>
                                    class="ajax-modal action primary" data-event="modification">
                                <span class="icon icon-gerer"></span>
                                Gerer
                            </a>
                        <?php endif; ?>
                        <?php if ($canValeurParametre) : ?>
                            <br>
                            <a <?php /** @see \UnicaenParametre\Controller\ParametreController::reinitialiserValeurAction() */ ?>
                                    href="<?php echo $this->url('parametre/reinitialiser-valeur', ['parametre' => $parametre->getId()], [], true); ?>"
                                    title="Reinitialiser la valeur du paramètre [<?php echo $parametre->getCode(); ?>]"
                                    class="action warning"
                            >
                                <span class="icon icon-gommer"></span>
                                Reinitialiser
                            </a>
                        <?php endif; ?>
                        <?php if ($canSupprimerParametre) : ?>
                            <br>
                            <a <?php /** @see \UnicaenParametre\Controller\ParametreController::supprimerAction() */ ?>
                                    href="<?php echo $this->url('parametre/supprimer', ['parametre' => $parametre->getId()], [], true); ?>"
                                    title="Supprimer le paramètre [<?php echo $parametre->getCode(); ?>]"
                            class="ajax-modal disabled" data-event="modification" disabled>
                            <i class="fas fa-times disabled"></i></a>
                                    class="ajax-modal action danger" data-event="modification" disabled>
                                <span class="icon icon-unchecked"></span>
                                Supprimer
                            </a>
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
Loading