Commit 91f11f1a authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Gestion des processus (envoi et traitement)

parent 92c1d23c
Loading
Loading
Loading
Loading
Loading
+101 −2
Changes for config/merged/signature.config.php: 101 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ namespace UnicaenCalendrier;

use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
use UnicaenSignature\Controller\ProcessController;
use UnicaenSignature\Controller\ProcessControllerFactory;
use UnicaenSignature\Controller\SignatureAssetsController;
use UnicaenSignature\Controller\SignatureAssetsControllerFactory;
use UnicaenSignature\Controller\SignatureController;
@@ -16,6 +18,8 @@ use UnicaenSignature\Service\LetterfileService;
use UnicaenSignature\Service\LetterfileServiceFactory;
use UnicaenSignature\Service\LoggerService;
use UnicaenSignature\Service\LoggerServiceFactory;
use UnicaenSignature\Service\ProcessService;
use UnicaenSignature\Service\ProcessServiceFactory;
use UnicaenSignature\Service\SignatureService;
use UnicaenSignature\Service\SignatureServiceFactory;
use UnicaenSignature\Service\SignatureConfigurationService;
@@ -34,6 +38,8 @@ return [
                        'home',
                        'letterfiles',
                        'letterfileWorkflows',
                        'process',
                        'processNextStep',
                        'signatures',
                        'signatureflows',
                        'signatureflowsUi',
@@ -75,6 +81,24 @@ return [
                    ],
                    'roles' => []
                ],

                ////////////////////////////////////////////////////////////////////
                /// PROCESS
                [
                    'controller' => ProcessController::class,
                    'action' => [
                        'configure',
                        'delete',
                        'previewDocument',
                        'index',
                        'new',
                        'trigger',
                    ],
                    'privileges' => [
                        SignaturePrivileges::SIGNATURE_DELETE,
                    ],
                    'roles' => []
                ],
            ],
        ],
    ],
@@ -92,6 +116,69 @@ return [
                ],
                'may_terminate' => true,
                'child_routes' => [

                    //////////////////////////////////////////////////////////////////////// < PROCESS
                    'process' => [
                        'type' => Literal::class,
                        'options' => [
                            'route' => '/process',
                            'defaults' => [
                                'controller' => ProcessController::class,
                                'action' => 'index',
                            ],
                        ],
                        'may_terminate' => true,

                        'child_routes' => [
                            'configure' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/configure/:id',
                                    'defaults' => [
                                        'action' => 'configure'
                                    ]
                                ]
                            ],
                            'delete' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/delete/:id',
                                    'defaults' => [
                                        'action' => 'delete'
                                    ]
                                ]
                            ],
                            'document' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/document/:id',
                                    'defaults' => [
                                        'action' => 'previewDocument'
                                    ]
                                ]
                            ],
                            'new' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/new/:id',
                                    'defaults' => [
                                        'action' => 'new'
                                    ]
                                ]
                            ],
                            'trigger' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/trigger/:id',
                                    'defaults' => [
                                        'action' => 'trigger'
                                    ]
                                ]
                            ],
                            //processing
                        ]
                    ],
                    //////////////////////////////////////////////////////////////////////// > PROCESS
                    'signatures' => [
                        'type' => Segment::class,
                        'options' => [
@@ -128,6 +215,16 @@ return [
                            ]
                        ]
                    ],
                    // process-next-step
                    'process-next-step' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/process-next-step/:id',
                            'defaults' => [
                                'action' => 'processNextStep'
                            ]
                        ]
                    ],
                    'status' => [
                        'type' => Segment::class,
                        'options' => [
@@ -208,10 +305,11 @@ return [

    'service_manager' => [
        'factories' => [
            SignatureService::class => SignatureServiceFactory::class,
            SignatureConfigurationService::class => SignatureConfigurationServiceFactory::class,
            LetterfileService::class => LetterfileServiceFactory::class,
            LoggerService::class => LoggerServiceFactory::class,
            SignatureConfigurationService::class => SignatureConfigurationServiceFactory::class,
            SignatureService::class => SignatureServiceFactory::class,
            ProcessService::class => ProcessServiceFactory::class,
        ],
    ],

@@ -220,6 +318,7 @@ return [
            SignatureAssetsController::class => SignatureAssetsControllerFactory::class,
            SignatureController::class => SignatureControllerFactory::class,
            SignatureTypeController::class => SignatureTypeControllerFactory::class,
            ProcessController::class => ProcessControllerFactory::class,
        ],
    ],

+7 −12
Changes for config/module.config.php: 7 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ return [
                        'key' => 'recipients',
                        'label' => "Destinataires",
                        'type' => 'recipients',
                        'editables' => false,
                        'values' => [
                        ],
                        'defaultValue' => [
@@ -71,18 +72,7 @@ return [
                    ]
                ],
                'methods_on_create' => null,
                'getRecipients' => function( $sc, $options){
                    var_dump($options);
                    die("Récup des personnes");
                }
            ],
            [
                'key' => \UnicaenSignature\Utils\SignatureConstants::GET_RECIPIENTS_METHOD_FREE,
                'label' => 'Destinataires libres',
                'description' => 'Destinataires nommés au déclenchement du processus',
                'methods' => 'free',
                'options' => [],
                'methods_on_create' => null
                'getRecipients' => null
            ]
        ],

@@ -98,6 +88,11 @@ return [

        'vite_mode' => 'prod',

        'documents_path' => '/tmp',
        'documents_mimes' => [
            'application/pdf' => 'pdf'
        ],

        ////////////////////////////////////////////////////////////
        /// Niveau de signatures disponibles (tous parafeurs confondus)
        ///
+1 −0
Changes for public/dist/assets/Recipients-bf6a1a83.css: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
.buttons-bar{margin:.25em}
+1 −0
Changes for public/dist/assets/TriggerProcess-839ca4b7.css: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
.step{border:solid thin #f1f5f8;padding:.3em 1em 1em;margin:1em 0;background:white;border-radius:4px}
+1 −0
Changes for public/dist/assets/signatureflows-5ab2ee16.js: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
import{a as b,r as k,c as r,b as t,d as u,t as d,e as f,w as S,v,f as m,F as p,g as c,o,h as C,i as N,j as O}from"../vendor.js";import{_ as E,R as M}from"../vendor2.js";const D={components:{Recipients:M},props:{entrypoint:{required:!0,type:String}},data(){return{signatureflows:[],letterfiles:[],get_recipients_methods:null,editStep:null,editedStep:null,editSignatureFlow:null,editedSignatureFlow:null,error:""}},methods:{handlerRecipientsChange(n){console.log("handlerRecipientsChange",n)},handlerUp(n){console.log("handlerUp"),this.moveStep(n,-1)},handlerDown(n){console.log("handlerDown"),this.moveStep(n,1)},moveStep(n,e){let a=this.editSignatureFlow.steps.indexOf(n);if(a==this.editSignatureFlow.steps.length&&e==1||a==0&&e==-1)return;let g=this.editSignatureFlow.steps[a];this.editSignatureFlow.steps.splice(a,1),this.editSignatureFlow.steps.splice(a+e,0,g),this.updateOrder()},updateOrder(){console.log("Update order");let n=1;this.editSignatureFlow.steps.forEach(e=>{e.order=n++})},handlerEditSignatureFlow(n){this.editedSignatureFlow=n,this.editSignatureFlow=JSON.parse(JSON.stringify(n))},handlerDeleteSignatureFlow(n){this.remoteDelete(n)},handlerEditSignatureFlowCancel(){this.editedStep=null,this.editStep=null,this.editSignatureFlow=null,this.editedSignatureFlow=null},handlerEditSignatureFlowSave(){if(this.editedSignatureFlow){let n=this.signatureflows.indexOf(this.editSignatureFlow);this.signatureflows[n]=JSON.parse(JSON.stringify(this.editSignatureFlow))}else this.signatureflows.push(JSON.parse(JSON.stringify(this.editSignatureFlow)));this.remoteSave(this.editSignatureFlow),this.editSignatureFlow=null},handlerNewSignatureFlow(){this.editSignatureFlow={id:null,label:"Nouvelle procédure",description:"",letterfile:"",level:"",steps:[],options:null}},handlerNewStep(){let n=this.editSignatureFlow.steps.length+1;this.editSignatureFlow.steps.push({id:null,label:"Nouvelle étape",order:n,letterfile:null,level:null,allValid:!1,getReceipedMethd:"todo"})},handlerEditStepCancel(){this.editStep=null,this.editedStep=null},handlerEditStepSave(){let n=this.editSignatureFlow.steps.indexOf(this.editedStep);this.editSignatureFlow.steps[n]=JSON.parse(JSON.stringify(this.editStep)),this.editStep=null,this.editedStep=null},handlerEditStep(n){this.editStep=JSON.parse(JSON.stringify(n)),this.editedStep=n;let e=this.getStepOptions(n);console.log("options",e)},handlerDeleteStep(n){let e=this.editSignatureFlow.steps.indexOf(n);this.editSignatureFlow.steps.splice(e,1),this.updateOrder()},getLevels(n){for(let e=0;e<this.letterfiles.length;e++)if(this.letterfiles[e].name==n)return this.letterfiles[e].levels;return[]},getLevelsLabel(n){if(n.level)if(n.letterfile){let g=this.getLevels(n.letterfile);for(let i=0;i<g.length;i++)if(g[i].key==n.level)return g[i].label;return"inconnue"}else return"Pas de parapheur";else return"Non configuré"},handlerChangeMethod(n){let e=this.getMethodOptions(this.editStep.method);(!this.editStep.options||Array.isArray(this.editStep.options))&&(this.editStep.options={}),e.forEach(a=>{this.editStep.options.hasOwnProperty(a.key)||(this.editStep.options[a.key]=[])})},getMethod(n){for(let e=0;e<this.get_recipients_methods.length;e++)if(this.get_recipients_methods[e].key==n)return this.get_recipients_methods[e];return null},getMethodLabel(n){let e=this.getMethod(n);return e?e.label:"N.D"},getMethodOptions(n){let e=this.getMethod(n);return e?e.options:null},getMethodOptionsDefaultValue(n){return this.getMethod(n)?[]:null},getStepOptions(n){let e=this.getMethod(n.method);return e?e.options:null},stepHasOptions(n){return this.getStepOptions(n)!=null},getLetterfile(n){for(let e=0;e<this.letterfiles.length;e++)if(this.letterfiles[e].name==n)return this.letterfiles[e];return null},getLetterfileLabel(n){let e=this.getLetterfile(n);return e?e.label:"N.D"},fetch(){this.loading="Chargement des processus",b.get(this.entrypoint).then(n=>{this.signatureflows=n.data.signatureflows,this.letterfiles=n.data.letterfiles,this.get_recipients_methods=n.data.get_recipients_methods,this.loading=""},n=>{this.error=""})},remoteDelete(n){this.loading="Suppression";let e=new FormData;e.append("action","delete"),e.append("json",JSON.stringify(n)),b.post(this.entrypoint,e).then(a=>{this.loading="",this.fetch()},a=>{this.loading="";try{this.error=a.response.data.error}catch{this.error="Une erreur inconnue est survenue côté serveur"}})},remoteSave(n){this.loading="Enregistement";let e=new FormData;e.append("action","save"),e.append("json",JSON.stringify(n)),b.post(this.entrypoint,e).then(a=>{this.loading="",this.fetch()},a=>{console.log(a),this.loading="",a.response.data.error?this.error=a.response.data.error:this.error="Une erreur inconnue est survenue côté serveur"})}},mounted(){this.fetch()}},L={class:"signatureflows"},x={key:0,class:"overlay error"},U={class:"overlay-content"},V=t("hr",null,null,-1),J={key:1,class:"overlay"},P={class:"overlay-content"},A=t("i",{class:"icon-spinner animate-spin"},null,-1),R={class:"row"},I={class:"col-md-12"},T={key:0,class:"signatureflows-edit"},j=t("h2",null,"Edition de la procédure",-1),B=t("label",{for:"label"}," Intitulé ",-1),q=t("label",{for:"description"}," Description ",-1),H={class:""},K={key:0,class:"step-edit"},z=t("label",{for:"letterfile"},"Parapheur",-1),G=["value"],Q=t("label",{for:"level"},"Type de validation",-1),W=["value"],X=t("label",{for:"method"},"Méthode d'obtention des destinataires",-1),Y=["value"],Z={key:1,class:"options"},$=t("h3",null,"Paramètres de récupération des destinataires",-1),ee={key:0},te=["for"],le=["onUpdate:modelValue","value","id"],ne={key:1},ie={key:1},se=t("h3",null,"étapes",-1),re={class:"steps"},oe={class:"step"},de=t("i",{class:"icon-location"},null,-1),ae=t("br",null,null,-1),ue=t("br",null,null,-1),he={class:"buttons-bar"},pe=["onClick"],ce=["onClick"],ge=["onClick"],Se=["onClick"],fe={class:"buttons-bar"},_e=t("i",{class:"icon-location"},null,-1),be={class:"buttons-bar"},ve={key:1},me={class:"signatureflow"},we={key:0,class:"steps"},ye={class:"step"},Fe={key:1,class:"alert alert-info"},ke={class:"buttons-bar"},Ce=["onClick"],Ne=["onClick"],Oe=t("hr",null,null,-1);function Ee(n,e,a,g,i,s){const y=k("recipients");return o(),r("section",L,[i.error?(o(),r("div",x,[t("div",U,[u(d(i.error)+" ",1),V,t("a",{href:"#",class:"btn btn-default",onClick:e[0]||(e[0]=l=>i.error="")},"Fermer")])])):f("",!0),n.loading?(o(),r("div",J,[t("div",P,[A,u(" "+d(n.loading),1)])])):f("",!0),t("section",R,[t("div",I,[i.editSignatureFlow?(o(),r("article",T,[j,t("div",null,[B,S(t("input",{"onUpdate:modelValue":e[1]||(e[1]=l=>i.editSignatureFlow.label=l),id:"label",type:"text",name:"label",placeholder:"Intitulé",class:"form-control input-lg"},null,512),[[v,i.editSignatureFlow.label]])]),t("div",null,[q,S(t("textarea",{"onUpdate:modelValue":e[2]||(e[2]=l=>i.editSignatureFlow.description=l),id:"description",type:"text",name:"description",placeholder:"Une description",class:"form-control input-lg"},null,512),[[v,i.editSignatureFlow.description]])]),t("section",H,[i.editStep?(o(),r("article",K,[t("h3",null,[u(" Modification de l'étape "),t("strong",null,d(i.editStep.label),1)]),S(t("input",{type:"text","onUpdate:modelValue":e[3]||(e[3]=l=>i.editStep.label=l),class:"form-control"},null,512),[[v,i.editStep.label]]),z,S(t("select",{"onUpdate:modelValue":e[4]||(e[4]=l=>i.editStep.letterfile=l),id:"letterfile",class:"form-control"},[(o(!0),r(p,null,c(i.letterfiles,l=>(o(),r("option",{value:l.name},d(l.label),9,G))),256))],512),[[m,i.editStep.letterfile]]),Q,i.editStep.letterfile?S((o(),r("select",{key:0,"onUpdate:modelValue":e[5]||(e[5]=l=>i.editStep.level=l),id:"level",class:"form-control"},[(o(!0),r(p,null,c(s.getLevels(i.editStep.letterfile),l=>(o(),r("option",{value:l.key},d(l.label),9,W))),256))],512)),[[m,i.editStep.level]]):f("",!0),X,S(t("select",{"onUpdate:modelValue":e[6]||(e[6]=l=>i.editStep.method=l),id:"method",class:"form-control",onChange:e[7]||(e[7]=(...l)=>s.handlerChangeMethod&&s.handlerChangeMethod(...l))},[(o(!0),r(p,null,c(i.get_recipients_methods,l=>(o(),r("option",{value:l.key},d(l.label),9,Y))),256))],544),[[m,i.editStep.method]]),s.stepHasOptions(i.editStep)?(o(),r("section",Z,[$,(o(!0),r(p,null,c(s.getStepOptions(i.editStep),l=>(o(),r("section",null,[t("h4",null,d(l.label),1),t("p",null,d(l.description),1),t("p",null,d(l.type),1),l.type=="checkbox"?(o(),r("section",ee,[(o(!0),r(p,null,c(l.values,(h,_)=>(o(),r("label",{for:l.key+"_"+_,class:"form-control"},[S(t("input",{"onUpdate:modelValue":F=>i.editStep.options[l.key]=F,type:"checkbox",value:_,id:l.key+"_"+_},null,8,le),[[C,i.editStep.options[l.key]]]),u(" "+d(h),1)],8,te))),256))])):f("",!0),l.type=="recipients"?(o(),r("section",ne,[N(y,{recipients:i.editStep.options[l.key],editable:!0,onChange:s.handlerRecipientsChange},null,8,["recipients","onChange"])])):f("",!0)]))),256))])):f("",!0),t("nav",null,[t("button",{onClick:e[8]||(e[8]=(...l)=>s.handlerEditStepSave&&s.handlerEditStepSave(...l)),class:"btn btn-success"},"Terminer"),t("button",{onClick:e[9]||(e[9]=(...l)=>s.handlerEditStepCancel&&s.handlerEditStepCancel(...l)),class:"btn btn-danger"},"Annuler")])])):(o(),r("section",ie,[se,t("section",re,[(o(!0),r(p,null,c(i.editSignatureFlow.steps,l=>(o(),r("article",oe,[t("h4",null,[de,u(" Etape "+d(l.order)+" - "+d(l.label),1)]),t("div",null,[u(" Niveau de validation : "),t("strong",null,d(s.getLevelsLabel(l)),1),ae,u(" Parapheur : "),t("strong",null,d(s.getLetterfileLabel(l.letterfile)),1),ue,u(" Destinataires : "),t("strong",null,d(s.getMethodLabel(l.method)),1)]),t("nav",he,[t("button",{class:"btn btn-default btn-xs",onClick:h=>s.handlerEditStep(l)},"Modifier",8,pe),t("button",{class:"btn btn-default btn-xs",onClick:h=>s.handlerDeleteStep(l)},"Supprimer",8,ce),t("button",{onClick:h=>s.handlerUp(l)},"up",8,ge),t("button",{onClick:h=>s.handlerDown(l)},"down",8,Se)])]))),256)),t("nav",fe,[t("button",{onClick:e[10]||(e[10]=(...l)=>s.handlerNewStep&&s.handlerNewStep(...l)),class:"btn btn-default"},[_e,u(" Nouvelle étape ")])])]),t("nav",be,[t("button",{onClick:e[11]||(e[11]=(...l)=>s.handlerEditSignatureFlowSave&&s.handlerEditSignatureFlowSave(...l)),class:"btn btn-large btn-success"}," Enregistrer la procédure "),t("button",{onClick:e[12]||(e[12]=(...l)=>s.handlerEditSignatureFlowCancel&&s.handlerEditSignatureFlowCancel(...l)),class:"btn btn-danger"}," Annuler les modifications ")])]))])])):(o(),r("section",ve,[(o(!0),r(p,null,c(i.signatureflows,l=>(o(),r("article",me,[t("h3",null,[u("Procédure : "),t("strong",null,d(l.label),1),u(),t("small",null," (ID: "+d(l.id)+")",1)]),t("p",null,[t("small",null,d(l.description),1)]),l.steps.length?(o(),r("section",we,[(o(!0),r(p,null,c(l.steps,h=>(o(),r("article",ye,[t("h4",null,"Etape "+d(h.order)+" - "+d(h.label),1),t("small",null,[u(" Parapheur : "),t("strong",null,d(s.getLetterfileLabel(h.letterfile)),1),u(" - Niveau de validation : "),t("strong",null,d(s.getLevelsLabel(h)),1),u(" - Destinataires : "),t("strong",null,d(s.getMethodLabel(h.method)),1)])]))),256))])):(o(),r("section",Fe," Aucune étape configurée ")),t("nav",ke,[t("button",{class:"btn btn-xs",onClick:h=>s.handlerEditSignatureFlow(l)},"Modifier la procédure",8,Ce),t("button",{class:"btn btn-xs",onClick:h=>s.handlerDeleteSignatureFlow(l)},"Supprimer la procédure",8,Ne)])]))),256)),t("nav",null,[t("button",{class:"btn btn-success",onClick:e[13]||(e[13]=(...l)=>s.handlerNewSignatureFlow&&s.handlerNewSignatureFlow(...l))}," Nouvelle procédure ")])])),Oe])])])}const Me=E(D,[["render",Ee]]);let w="#signatureflows",De=document.querySelector(w);const Le=O(Me,{entrypoint:De.dataset.entrypoint});Le.mount(w);
Loading