[workflow] Feature: allow user to retrieve the access link for the

workflow + show dest email for a workflow
This commit is contained in:
Julien Fastré 2022-09-29 22:05:29 +02:00
parent a91b35298a
commit fd0e541e3f
5 changed files with 56 additions and 1 deletions

View File

@ -11,6 +11,8 @@ and this project adheres to
## Unreleased
<!-- write down unreleased development here -->
* [workflow] Feature: allow user to copy and send manually the access link for the workflow
* [workflow] Feature: show the email addresses that received an access link for the workflow
## Test releases

View File

@ -95,6 +95,15 @@
</ul>
{% endif %}
{% if entity_workflow.currentStep.destEmail|length > 0 %}
<p><b>{{ 'workflow.An access key was also sent to those addresses'|trans }}&nbsp;:</b></p>
<ul>
{% for e in entity_workflow.currentStep.destEmail -%}
<li><a href="mailto:{{ e|escape('html_attr') }}">{{ e }}</a></li>
{%- endfor %}
</ul>
{% endif %}
{% if entity_workflow.currentStep.destUserByAccessKey|length > 0 %}
<p><b>{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }}&nbsp;:</b></p>
<ul>
@ -103,6 +112,21 @@
{% endfor %}
</ul>
{% endif %}
{% if is_granted('CHILL_MAIN_WORKFLOW_LINK_SHOW', entity_workflow) %}
<p><b>{{ 'workflow.This link grant any user to apply a transition'|trans }}&nbsp;:</b></p>
{% set link = absolute_url(path('chill_main_workflow_grant_access_by_key', {'id': entity_workflow.currentStep.id, 'accessKey': entity_workflow.currentStep.accessKey})) %}
<div class="input-group mb-3">
<input type="text" readonly value="{{ link|e('html_attr') }}" class="form-control">
<button class="btn btn-secondary" type="button" id="button-copy" onclick="navigator.clipboard.writeText('{{ link|e('html_attr') }}').then(() => { window.alert({{ ('"' ~ 'workflow.Access link copied'|trans ~ ' !"') |e('html_attr') }})});"><i class="fa fa-files-o"></i></button>
<a class="btn btn-secondary" type="button" id="button-email"
href="mailto:?body={{ ((('workflow.The workflow may be accssed through this link'|trans)~':')|e('url')) ~ '%0D%0A%0D%0A' ~ link|e('url') }}"><i class="fa fa-envelope"></i></a>
</div>
{% endif %}
{% endif %}
</div>

View File

@ -81,6 +81,15 @@
</ul>
{% endif %}
{% if entity_workflow.currentStep.destEmail|length > 0 %}
<p><b>{{ 'workflow.An access key was also sent to those addresses'|trans }}&nbsp;:</b></p>
<ul>
{% for e in entity_workflow.currentStep.destEmail -%}
<li><a href="mailto:{{ e|escape('html_attr') }}">{{ e }}</a></li>
{%- endfor %}
</ul>
{% endif %}
{% if step.destUserByAccessKey|length > 0 %}
<p><b>{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }}&nbsp;:</b></p>
<ul>

View File

@ -27,6 +27,8 @@ class EntityWorkflowVoter extends Voter
public const SEE = 'CHILL_MAIN_WORKFLOW_SEE';
public const SHOW_ENTITY_LINK = 'CHILL_MAIN_WORKFLOW_LINK_SHOW';
private EntityWorkflowManager $manager;
private Security $security;
@ -80,6 +82,19 @@ class EntityWorkflowVoter extends Voter
case self::DELETE:
return $subject->getStep() === 'initial';
case self::SHOW_ENTITY_LINK:
if ($subject->getStep() === 'initial') {
return false;
}
$currentStep = $subject->getCurrentStepChained();
if ($currentStep->isFinal()) {
return false;
}
return $currentStep->getPrevious()->getTransitionBy() === $this->security->getUser();
default:
throw new UnexpectedValueException("attribute {$attribute} not supported");
}
@ -91,6 +106,7 @@ class EntityWorkflowVoter extends Voter
self::SEE,
self::CREATE,
self::DELETE,
self::SHOW_ENTITY_LINK,
];
}
}

View File

@ -454,7 +454,6 @@ workflow:
Delete workflow: Supprimer le workflow
Steps is not waiting for transition. Maybe someone apply the transition before you ?: L'étape que vous cherchez a déjà été modifiée par un autre utilisateur. Peut-être quelqu'un a-t-il modifié cette étape avant vous ?
You get access to this step: Vous avez acquis les droits pour appliquer une transition sur ce workflow.
Those users are also granted to apply a transition by using an access key: Ces utilisateurs peuvent également valider cette étape, grâce à un lien d'accès
dest by email: Liens d'autorisation par email
dest by email help: Les adresses email mentionnées ici recevront un lien d'accès. Ce lien d'accès permettra à l'utilisateur de valider cette étape.
Add an email: Ajouter une adresse email
@ -466,6 +465,11 @@ workflow:
Previous workflow transitionned help: Workflows où vous avez exécuté une action.
For: Pour
You must select a next step, pick another decision if no next steps are available: Il faut une prochaine étape. Choissisez une autre décision si nécessaire.
An access key was also sent to those addresses: Un lien d'accès a été envoyé à ces addresses
Those users are also granted to apply a transition by using an access key: Ces utilisateurs ont obtennu l'accès grâce au lien reçu par email
Access link copied: Lien d'accès copié
This link grant any user to apply a transition: Le lien d'accès suivant permet d'appliquer une transition
The workflow may be accssed through this link: Une transition peut être appliquée sur ce workflow grâce au lien d'accès suivant
Subscribe final: Recevoir une notification à l'étape finale