Commit 39788c0f authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Isolation partie admin, ménage

parent d6bf36ae
Loading
Loading
Loading
Loading
Loading
+3
Changes for front/Workflow/Administration.vue: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
                   title="Vous pouvez ordonnancer les étapes du workflow, sous condition qu'il n'y ai pas de blocage ou de dépendance bloquante"><i
                class="fas fa-arrows-up-down ui-sortable-handle"></i></a>
                <a v-if="canEdit" class="perso-btn"
                   title="Personnalisation des libellés & messages"
                   :href="personnalisationUrl + '/' + etape.id"
                   @click.prevent="saisie"><i class="fas fa-pen-to-square"></i></a>
                {{ etape.libelleAutres }}</h3>
@@ -39,10 +40,12 @@ Par exemple si on a plusieurs contrat et avenants, tous doivent être terminés"
                        <td>
                            <a v-if="canEdit"
                               :href="saisieUrl + '/' + etape.id + '/' + d.id"
                               title="Modification de la dépendance"
                               @click.prevent="saisie"><i class="fas fa-pen-to-square"></i></a>
                            <a v-if="canEdit" :href="suppressionUrl + '/' + d.id"
                               data-content="Êtes-vous sur de vouloir supprimer la règle de dépendance ?"
                               data-title="Suppression de la dépendance"
                               title="Suppression de la dépendance"
                               @click.prevent="suppression"><i class="fas fa-trash-can"></i></a>

                            {{ d.etapePrecedante.libelleAutres }}
+101
Changes for module/Workflow/config/administration.config.php: 101 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Workflow;

use Application\Provider\Privilege\Privileges;


return [
    'routes' => [
        'workflow' => [
            'child_routes' => [
                'administration' => [
                    'route'         => '/administration',
                    'controller'    => Controller\AdministrationController::class,
                    'action'        => 'index',
                    'privileges'    => [Privileges::WORKFLOW_DEPENDANCES_VISUALISATION],
                    'may_terminate' => true,
                    'child_routes'  => [
                        'data'                   => [
                            'route'      => '/data',
                            'controller' => Controller\AdministrationController::class,
                            'action'     => 'data',
                            'privileges' => [Privileges::WORKFLOW_DEPENDANCES_VISUALISATION],
                        ],
                        'tri'                    => [
                            'route'      => '/tri',
                            'controller' => Controller\AdministrationController::class,
                            'action'     => 'tri',
                            'privileges' => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                        ],
                        'modification-etape'     => [
                            'route'       => '/modification-etape/:workflowEtape',
                            'controller'  => Controller\AdministrationController::class,
                            'action'      => 'modification-etape',
                            'privileges'  => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                            'constraints' => [
                                'workflowEtape' => '[0-9]*',
                            ],
                        ],
                        'saisie-dependance'      => [
                            'route'       => '/saisie-dependance/:workflowEtape[/:workflowEtapeDependance]',
                            'controller'  => Controller\AdministrationController::class,
                            'action'      => 'saisie-dependance',
                            'privileges'  => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                            'constraints' => [
                                'workflowEtape'           => '[0-9]*',
                                'workflowEtapeDependance' => '[0-9]*',
                            ],
                        ],
                        'suppression-dependance' => [
                            'route'       => '/suppression-dependance/:workflowEtapeDependance',
                            'controller'  => Controller\AdministrationController::class,
                            'action'      => 'suppression-dependance',
                            'privileges'  => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                            'constraints' => [
                                'workflowEtapeDependance' => '[0-9]*',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'navigation' => [
        'administration' => [
            'pages' => [
                'configuration' => [
                    'pages' => [
                        'workflow' => [
                            'label'    => "Workflow",
                            'title'    => "Page d\'administration du workflow",
                            'route'    => 'workflow/administration',
                            'order'    => 60,
                            'resource' => Privileges::getResourceId(Privileges::WORKFLOW_DEPENDANCES_VISUALISATION),
                        ],
                    ],
                ],
            ],
        ],
    ],

    'controllers' => [
        Controller\AdministrationController::class => Controller\AdministrationControllerFactory::class,
    ],

    'services' => [
        Command\WorkflowResetCommand::class => Command\WorflowResetCommandFactory::class,
    ],

    'forms' => [
        Form\DependanceForm::class => Form\DependanceFormFactory::class,
        Form\EtapeForm::class      => Form\EtapeFormFactory::class,
    ],

    'laminas-cli' => [
        'commands' => [
            'workflow-reset' => Command\WorkflowResetCommand::class,
        ],
    ],
];
 No newline at end of file
+1 −90
Changes for module/Workflow/config/module.config.php: 1 added line, 90 removed lines.
Original line number Diff line number Diff line
@@ -12,57 +12,6 @@ return [
            'route'         => '/workflow',
            'may_terminate' => false,
            'child_routes'  => [
                'administration' => [
                    'route'         => '/administration',
                    'controller'    => Controller\WorkflowController::class,
                    'action'        => 'administration',
                    'privileges'    => [Privileges::WORKFLOW_DEPENDANCES_VISUALISATION],
                    'may_terminate' => true,
                    'child_routes'  => [
                        'data'                   => [
                            'route'      => '/data',
                            'controller' => Controller\WorkflowController::class,
                            'action'     => 'administration-data',
                            'privileges' => [Privileges::WORKFLOW_DEPENDANCES_VISUALISATION],
                        ],
                        'tri'                    => [
                            'route'      => '/tri',
                            'controller' => Controller\WorkflowController::class,
                            'action'     => 'administration-tri',
                            'privileges' => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                        ],
                        'modification-etape' => [
                            'route'       => '/modification-etape/:workflowEtape',
                            'controller'  => Controller\WorkflowController::class,
                            'action'      => 'administration-modification-etape',
                            'privileges'  => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                            'constraints' => [
                                'workflowEtape'           => '[0-9]*',
                            ],
                        ],
                        'saisie-dependance'      => [
                            'route'       => '/saisie-dependance/:workflowEtape[/:workflowEtapeDependance]',
                            'controller'  => Controller\WorkflowController::class,
                            'action'      => 'administration-saisie-dependance',
                            'privileges'  => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                            'constraints' => [
                                'workflowEtape'           => '[0-9]*',
                                'workflowEtapeDependance' => '[0-9]*',
                            ],
                        ],
                        'suppression-dependance' => [
                            'route'       => '/suppression-dependance/:workflowEtapeDependance',
                            'controller'  => Controller\WorkflowController::class,
                            'action'      => 'administration-suppression-dependance',
                            'privileges'  => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
                            'constraints' => [
                                'workflowEtapeDependance' => '[0-9]*',
                            ],
                        ],
                    ],
                ],


                'calculer-tout'             => [
                    'route'      => '/calculer-tout',
                    'controller' => Controller\WorkflowController::class,
@@ -85,24 +34,6 @@ return [
        ],
    ],

    'navigation' => [
        'administration' => [
            'pages' => [
                'configuration' => [
                    'pages' => [
                        'workflow' => [
                            'label'    => "Workflow",
                            'title'    => "Page d\'administration du workflow",
                            'route'    => 'workflow/administration',
                            'order'    => 60,
                            'resource' => Privileges::getResourceId(Privileges::WORKFLOW_DEPENDANCES_VISUALISATION),
                        ],
                    ],
                ],
            ],
        ],
    ],

    'guards' => [
        [
            'controller' => Controller\WorkflowController::class,
@@ -121,12 +52,7 @@ return [
        ],
        [
            'controller' => Controller\WorkflowController::class,
            'action'     => ['index', 'dependances'],
            'privileges' => [Privileges::WORKFLOW_DEPENDANCES_VISUALISATION, Privileges::WORKFLOW_DEPENDANCES_EDITION],
        ],
        [
            'controller' => Controller\WorkflowController::class,
            'action'     => ['saisieDep', 'suppressionDep', 'calculerTout'],
            'action'     => ['calculerTout'],
            'privileges' => [Privileges::WORKFLOW_DEPENDANCES_EDITION],
        ],
    ],
@@ -143,10 +69,6 @@ return [
        ],
    ],

    'controllers' => [
        Controller\WorkflowController::class => Controller\WorkflowControllerFactory::class,
    ],

    'services' => [
        Service\WfEtapeDepService::class     => Service\WfEtapeDepServiceFactory::class,
        Service\WfEtapeService::class        => Service\WfEtapeServiceFactory::class,
@@ -154,20 +76,9 @@ return [
        Service\ValidationService::class     => Service\ValidationServiceFactory::class,
        Service\WorkflowService::class       => Service\WorkflowServiceFactory::class,
        Assertion\WorkflowAssertion::class   => AssertionFactory::class,
        Command\WorkflowResetCommand::class  => Command\WorflowResetCommandFactory::class,
    ],

    'forms' => [
        Form\DependanceForm::class => Form\DependanceFormFactory::class,
    ],

    'view_helpers' => [
        'feuilleDeRoute' => View\Helper\FeuilleDeRouteViewHelperFactory::class,
    ],

    'laminas-cli' => [
        'commands' => [
            'workflow-reset' => Command\WorkflowResetCommand::class,
        ],
    ],
];
 No newline at end of file
+x+173
Changes for module/Workflow/src/Controller/AdministrationController.php: 173 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Workflow\Controller;

use Application\Controller\AbstractController;
use Application\Provider\Privilege\Privileges;
use UnicaenVue\View\Model\AxiosModel;
use UnicaenVue\View\Model\VueModel;
use Workflow\Entity\Db\WorkflowEtape;
use Workflow\Entity\Db\WorkflowEtapeDependance;
use Workflow\Form\DependanceFormAwareTrait;
use Workflow\Form\EtapeFormAwareTrait;
use Workflow\Service\WorkflowServiceAwareTrait;


/**
 * Description of AdministrationController
 *
 * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
 */
class AdministrationController extends AbstractController
{
    use WorkflowServiceAwareTrait;
    use EtapeFormAwareTrait;
    use DependanceFormAwareTrait;

    public function indexAction(): VueModel
    {
        $props = [
            'canEdit' => $this->isAllowed(Privileges::getResourceId(Privileges::WORKFLOW_DEPENDANCES_EDITION)),
        ];

        $vueModel = new VueModel();
        $vueModel->setTemplate('workflow/administration');
        $vueModel->setVariables($props);

        return $vueModel;
    }



    public function dataAction(): AxiosModel
    {
        // Le cache est vidé systématiquement ici pour éviter tout problème
        $this->getServiceWorkflow()->clearEtapesCache();

        $etapes = array_values($this->getServiceWorkflow()->getEtapes());

        $properties = [
            'id',
            'code',
            ['perimetre', [
                'code',
                'libelle',
            ]],
            'libelleIntervenant',
            'libelleAutres',
            ['dependances', [
                'id',
                ['etapePrecedante', [
                    'code',
                    'libelleAutres',
                ]],
                'active',
                ['typeIntervenant', [
                    'code',
                    'libelle',
                ]],
                ['perimetre', [
                    'code',
                    'libelle',
                ]],
                'avancement',
            ]],
        ];

        return new AxiosModel($etapes, $properties);
    }



    public function modificationEtapeAction(): array
    {
        /* @var $workflowEtape WorkflowEtape */
        $workflowEtape = $this->getEvent()->getParam('workflowEtape');

        $title = "Personnalisation des libellés de l'étape";

        $form = $this->getFormEtape();
        $form->bindRequestSave($workflowEtape, $this->getRequest(), function ($workflowEtape) {
            try {
                $this->getServiceWorkflow()->saveEtape($workflowEtape);
            } catch (\Throwable $e) {
                $this->flashMessenger()->addErrorMessage($this->translate($e));
            }
        });

        return compact('title', 'form');
    }



    public function saisieDependanceAction(): array
    {
        /* @var $workflowEtapeDependance WorkflowEtapeDependance */
        $workflowEtapeDependance = $this->getEvent()->getParam('workflowEtapeDependance');

        /* @var $workflowEtape WorkflowEtape */
        $workflowEtape = $this->getEvent()->getParam('workflowEtape');

        if (!$workflowEtapeDependance) {
            $workflowEtapeDependance = new WorkflowEtapeDependance();
            $workflowEtapeDependance->setEtapeSuivante($workflowEtape);
            $workflowEtape->addDependance($workflowEtapeDependance);

            $title = 'Ajout d\'une dépendance';
        } else {
            $title = 'Modification d\'une dépendance';
        }

        $form = $this->getFormWorkflowDependance();
        $form->init2($workflowEtapeDependance);
        $form->bindRequestSave($workflowEtapeDependance, $this->getRequest(), function ($workflowEtapeDependance) {
            try {
                $this->getServiceWorkflow()->saveEtapeDependance($workflowEtapeDependance);
            } catch (\Throwable $e) {
                $this->flashMessenger()->addErrorMessage($this->translate($e));
            }
        });

        return compact('title', 'form');
    }



    public function suppressionDependanceAction(): AxiosModel
    {
        /* @var $workflowEtapeDependance WorkflowEtapeDependance */
        $workflowEtapeDependance = $this->getEvent()->getParam('workflowEtapeDependance');

        if (!$workflowEtapeDependance) {
            throw new \RuntimeException('L\'identifiant n\'est pas bon ou n\'a pas été fourni');
        }

        try {
            $this->getServiceWorkflow()->deleteEtapeDependance($workflowEtapeDependance);

            $this->flashMessenger()->addSuccessMessage("Dépendance supprimée avec succès.");
        } catch (\Exception $e) {
            $this->flashMessenger()->addErrorMessage($this->translate($e));
        }

        return new AxiosModel([]);
    }



    public function triAction(): AxiosModel
    {
        /** @var array $etapes */
        $etapes = $this->axios()->fromPost('etapes');

        try {
            $this->getServiceWorkflow()->trier($etapes);
            $this->flashMessenger()->addSuccessMessage('Nouvel ordonnancement du workflow bien pris en compte');
        } catch (\Throwable $e) {
            $this->flashMessenger()->addErrorMessage($this->translate($e));
        }

        return $this->dataAction();
    }

}
 No newline at end of file
+x+32
Changes for module/Workflow/src/Controller/AdministrationControllerFactory.php: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Workflow\Controller;

use Psr\Container\ContainerInterface;



/**
 * Description of AdministrationControllerFactory
 *
 * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
 */
class AdministrationControllerFactory
{

    /**
     * @param ContainerInterface $container
     * @param string             $requestedName
     * @param array|null         $options
     *
     * @return AdministrationController
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null): AdministrationController
    {
        $controller = new AdministrationController;

        /* Injectez vos dépendances ICI */

        return $controller;
    }
}
 No newline at end of file
Loading