-
Workflow
+
{{ w.title }}
{{ w.relatedEntityClass }}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue
index 2e4125c1a..151bc06c7 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue
@@ -12,6 +12,8 @@
:relatedEntityClass="this.relatedEntityClass"
:relatedEntityId="this.relatedEntityId"
:workflowsAvailables="workflowsAvailables"
+ :preventDefaultMoveToGenerate="this.$props.preventDefaultMoveToGenerate"
+ :goToGenerateWorkflowPayload="this.goToGenerateWorkflowPayload"
@go-to-generate-workflow="goToGenerateWorkflow"
>
@@ -36,6 +38,7 @@
:relatedEntityId="this.relatedEntityId"
:workflowsAvailables="workflowsAvailables"
:preventDefaultMoveToGenerate="this.$props.preventDefaultMoveToGenerate"
+ :goToGenerateWorkflowPayload="this.goToGenerateWorkflowPayload"
@go-to-generate-workflow="this.goToGenerateWorkflow"
>
@@ -83,6 +86,10 @@ export default {
required: false,
default: false,
},
+ goToGenerateWorkflowPayload: {
+ required: false,
+ default: {}
+ },
},
data() {
return {
@@ -105,7 +112,7 @@ export default {
this.modal.showModal = true;
},
goToGenerateWorkflow(data) {
- console.log('go to generate workflow intercepted');
+ console.log('go to generate workflow intercepted', data);
this.$emit('goToGenerateWorkflow', data);
}
},
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/PickWorkflow.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/PickWorkflow.vue
index 826917fbb..9ed1ef6cc 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/PickWorkflow.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/PickWorkflow.vue
@@ -37,6 +37,10 @@ export default {
required: false,
default: false,
},
+ goToGenerateWorkflowPayload: {
+ required: false,
+ default: {}
+ },
},
emits: ['goToGenerateWorkflow'],
methods: {
@@ -51,7 +55,7 @@ export default {
window.location.assign(this.makeLink(workflowName));
}
- this.$emit('goToGenerateWorkflow', {event, workflowName, link: this.makeLink(workflowName)});
+ this.$emit('goToGenerateWorkflow', {event, workflowName, link: this.makeLink(workflowName), payload: this.goToGenerateWorkflowPayload});
}
}
}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig
index 64482c067..bb0411371 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig
@@ -3,6 +3,8 @@
{% if transition_form is not null %}
{{ form_start(transition_form) }}
+ {{ form_errors(transition_form) }}
+
{% set step = entity_workflow.currentStepChained %}
{% set labels = workflow_metadata(entity_workflow, 'label', step.currentStep) %}
{% set label = labels is null ? step.currentStep : labels|localize_translatable_string %}
@@ -60,8 +62,10 @@
{{ form_row(transition_form.freezeAfter) }}
{% endif %}
-
+
{{ form_row(transition_form.future_dest_users) }}
+
+ {{ form_row(transition_form.future_dest_emails) }}
{{ form_label(transition_form.comment) }}
@@ -82,13 +86,23 @@
{{ 'workflow.This workflow is finalized'|trans }}
{% else %}
{{ 'workflow.You are not allowed to apply a transition on this workflow'|trans }}
-
{{ 'workflow.Only those users are allowed'|trans }}:
+ {% if entity_workflow.currentStep.destUser|length > 0 %}
+
{{ 'workflow.Only those users are allowed'|trans }} :
+
+ {% for u in entity_workflow.currentStep.destUser -%}
+ {{ u|chill_entity_render_box }}
+ {%- endfor %}
+
+ {% endif %}
-
- {% for u in entity_workflow.currentStep.destUser -%}
- {{ u|chill_entity_render_box }}
- {%- endfor %}
-
+ {% if entity_workflow.currentStep.destUserByAccessKey|length > 0 %}
+
{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :
+
+ {% for u in entity_workflow.currentStep.destUserByAccessKey %}
+ {{ u|chill_entity_render_box }}
+ {% endfor %}
+
+ {% endif %}
{% endif %}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_extension_list_workflow_for.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_extension_list_workflow_for.html.twig
index 96c33e207..cfe8b83f5 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_extension_list_workflow_for.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_extension_list_workflow_for.html.twig
@@ -7,7 +7,7 @@
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig
index e40e82dab..dda309da0 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig
@@ -69,15 +69,26 @@
{% endif %}
- {% if loop.last and step.destUser|length > 0 %}
+ {% if loop.last and step.allDestUser|length > 0 %}
-
{{ 'workflow.Users allowed to apply transition'|trans }} :
-
- {% for u in step.destUser %}
- {{ u|chill_entity_render_box }}
- {% endfor %}
-
+ {% if step.destUser|length > 0 %}
+
{{ 'workflow.Users allowed to apply transition'|trans }} :
+
+ {% for u in step.destUser %}
+ {{ u|chill_entity_render_box }}
+ {% endfor %}
+
+ {% endif %}
+
+ {% if step.destUserByAccessKey|length > 0 %}
+
{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :
+
+ {% for u in step.destUserByAccessKey %}
+ {{ u|chill_entity_render_box }}
+ {% endfor %}
+
+ {% endif %}
{% endif %}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/delete.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/delete.html.twig
new file mode 100644
index 000000000..64da4ea76
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/delete.html.twig
@@ -0,0 +1,29 @@
+{% extends '@ChillMain/layout.html.twig' %}
+
+{% block title 'workflow.Delete workflow ?'|trans %}
+
+{% block display_content %}
+
+ {{ handler.entityTitle(entityWorkflow) }}
+
+
+ {% include handler.template(entityWorkflow) with handler.templateData(entityWorkflow)|merge({
+ 'display_action': false
+ }) %}
+{% endblock %}
+
+{% block content %}
+
+
+ {{ include('@ChillMain/Util/confirmation_template.html.twig',
+ {
+ 'title' : 'workflow.Delete workflow ?'|trans,
+ 'confirm_question' : 'workflow.Are you sure you want to delete this workflow ?'|trans,
+ 'display_content' : block('display_content'),
+ 'cancel_route' : 'chill_main_workflow_show',
+ 'cancel_parameters' : {'id' : entityWorkflow.id},
+ 'form' : delete_form
+ } ) }}
+
+
+{% endblock %}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/index.html.twig
index 210d552e0..1a6f3103b 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/index.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/index.html.twig
@@ -21,10 +21,12 @@
{{ encore_entry_link_tags('mod_wopi_link') }}
{% endblock %}
+{% import '@ChillMain/Workflow/macro_breadcrumb.html.twig' as macro %}
+
{% block content %}
{{ block('title') }}
-
+
{# handler_template:
- src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.html.twig
- src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig
@@ -32,11 +34,26 @@
#}
- {% include handler_template_title with handler_template_data|merge({'breadcrumb': true }) %}
+
{{ handler.entityTitle(entity_workflow) }}
+
+ {{ macro.breadcrumb({'entity_workflow': entity_workflow}) }}
+
{% include handler_template with handler_template_data|merge({'display_action': true }) %}
+
+ {% if is_granted('CHILL_MAIN_WORKFLOW_DELETE', entity_workflow) %}
+
+ {% endif %}
-
+
{% include '@ChillMain/Workflow/_follow.html.twig' %}
{% include '@ChillMain/Workflow/_decision.html.twig' %} {#
{% include '@ChillMain/Workflow/_comment.html.twig' %} #}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/list.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/list.html.twig
index 6da68e390..562413bc2 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/list.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/list.html.twig
@@ -8,9 +8,10 @@
{% block content %}
-
+
{{ block('title') }}
-
+
+
+ {% if help is defined %}
+
{{ help|trans }}
+ {% endif %}
+
{% if workflows|length == 0 %}
{{ 'workflow.No workflow'|trans }}
{% else %}
@@ -36,26 +53,24 @@
-
+
- {{ 'workflow_'|trans }}
+ {{ l.handler.entityTitle(l.entity_workflow) }}
- {% include l.handler.templateTitle(l.entity_workflow) with l.handler.templateTitleData(l.entity_workflow)|merge({
- 'description': true,
- 'add_classes': 'ms-3 h3'
- }) %}
-
+
- {{ macro.breadcrumb(l) }}
-
+
+ {{ macro.breadcrumb(l) }}
+
+
-
+
{% include l.handler.template(l.entity_workflow) with l.handler.templateData(l.entity_workflow)|merge({
'display_action': false
@@ -78,6 +93,13 @@
+ {% if is_granted('CHILL_MAIN_WORKFLOW_DELETE', l.entity_workflow) %}
+
+
+
+ {% endif %}
@@ -87,7 +109,7 @@
-
+
{% endfor %}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_send_access_key.fr.txt.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_send_access_key.fr.txt.twig
new file mode 100644
index 000000000..6237cb68a
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_send_access_key.fr.txt.twig
@@ -0,0 +1,15 @@
+Madame, Monsieur,
+
+Un suivi "{{ workflow.text }}" a atteint une nouvelle étape: {{ workflow.text }}.
+
+Titre du workflow: "{{ entityTitle }}".
+
+Vous êtes invité·e à valider cette étape. Pour obtenir un accès, vous pouvez cliquer sur le lien suivant:
+
+{{ absolute_url(path('chill_main_workflow_grant_access_by_key', {'id': entity_workflow.currentStep.id, 'accessKey': entity_workflow.currentStep.accessKey})) }}
+
+Dès que vous aurez cliqué une fois sur le lien, vous serez autorisé à valider cette étape.
+
+Notez que vous devez disposer d'un compte utilisateur valide dans Chill.
+
+Cordialement,
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_send_access_key_title.fr.txt.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_send_access_key_title.fr.txt.twig
new file mode 100644
index 000000000..b505a97ed
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_send_access_key_title.fr.txt.twig
@@ -0,0 +1 @@
+Un suivi {{ workflow.text }} demande votre attention: {{ entityTitle }}
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php
index 9542d3acb..fe0597e6b 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php
@@ -23,6 +23,8 @@ class EntityWorkflowVoter extends Voter
{
public const CREATE = 'CHILL_MAIN_WORKFLOW_CREATE';
+ public const DELETE = 'CHILL_MAIN_WORKFLOW_DELETE';
+
public const SEE = 'CHILL_MAIN_WORKFLOW_SEE';
private EntityWorkflowManager $manager;
@@ -40,7 +42,11 @@ class EntityWorkflowVoter extends Voter
return $subject instanceof EntityWorkflow && in_array($attribute, self::getRoles(), true);
}
- protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
+ /**
+ * @param EntityWorkflow $subject
+ * @param mixed $attribute
+ */
+ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
switch ($attribute) {
case self::CREATE:
@@ -55,6 +61,9 @@ class EntityWorkflowVoter extends Voter
return $this->security->isGranted($entityAttribute, $handler->getRelatedEntity($subject));
+ case self::DELETE:
+ return $subject->getStep() === 'initial';
+
default:
throw new UnexpectedValueException("attribute {$attribute} not supported");
}
@@ -65,6 +74,7 @@ class EntityWorkflowVoter extends Voter
return [
self::SEE,
self::CREATE,
+ self::DELETE,
];
}
}
diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php
index 551a17747..93ba4351e 100644
--- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php
+++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php
@@ -33,10 +33,6 @@ interface EntityWorkflowHandlerInterface
public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array;
- public function getTemplateTitle(EntityWorkflow $entityWorkflow, array $options = []): string;
-
- public function getTemplateTitleData(EntityWorkflow $entityWorkflow, array $options = []): array;
-
public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool;
public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool;
diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php
index 1fc56e898..7074be14d 100644
--- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php
+++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php
@@ -72,7 +72,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
return;
}
- if (!$entityWorkflow->getCurrentStep()->getDestUser()->contains($this->security->getUser())) {
+ if (!$entityWorkflow->getCurrentStep()->getAllDestUser()->contains($this->security->getUser())) {
if (!$event->getMarking()->has('initial')) {
$event->addTransitionBlocker(new TransitionBlocker(
'workflow.You are not allowed to apply a transition on this workflow. Only those users are allowed: %users%',
@@ -80,7 +80,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
[
'%users%' => implode(
', ',
- $entityWorkflow->getCurrentStep()->getDestUser()->map(function (User $u) {
+ $entityWorkflow->getCurrentStep()->getAllDestUser()->map(function (User $u) {
return $this->userRender->renderString($u, []);
})->toArray()
),
diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php
index 6d5a54d45..f7854c93f 100644
--- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php
+++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php
@@ -52,11 +52,11 @@ class NotificationOnTransition implements EventSubscriberInterface
public static function getSubscribedEvents(): array
{
return [
- 'workflow.completed' => 'onCompleted',
+ 'workflow.completed' => 'onCompletedSendNotification',
];
}
- public function onCompleted(Event $event): void
+ public function onCompletedSendNotification(Event $event): void
{
if (!$event->getSubject() instanceof EntityWorkflow) {
return;
diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php
new file mode 100644
index 000000000..d91926dc5
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php
@@ -0,0 +1,71 @@
+engine = $engine;
+ $this->metadataExtractor = $metadataExtractor;
+ $this->registry = $registry;
+ $this->entityWorkflowManager = $entityWorkflowManager;
+ $this->mailer = $mailer;
+ }
+
+ public function postPersist(EntityWorkflowStep $step): void
+ {
+ $entityWorkflow = $step->getEntityWorkflow();
+
+ $place = $this->metadataExtractor->buildArrayPresentationForPlace($entityWorkflow);
+ $workflow = $this->metadataExtractor->buildArrayPresentationForWorkflow(
+ $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName())
+ );
+ $handler = $this->entityWorkflowManager->getHandler($entityWorkflow);
+
+ foreach ($entityWorkflow->futureDestEmails as $emailAddress) {
+ $context = [
+ 'entity_workflow' => $entityWorkflow,
+ 'dest' => $emailAddress,
+ 'place' => $place,
+ 'workflow' => $workflow,
+ 'entityTitle' => $handler->getEntityTitle($entityWorkflow),
+ ];
+
+ $email = new Email();
+ $email
+ ->addTo($emailAddress)
+ ->subject($this->engine->render('@ChillMain/Workflow/workflow_send_access_key_title.fr.txt.twig', $context))
+ ->text($this->engine->render('@ChillMain/Workflow/workflow_send_access_key.fr.txt.twig', $context));
+
+ $this->mailer->send($email);
+ }
+ }
+}
diff --git a/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php b/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php
index edb1aa7b7..21a0f6b43 100644
--- a/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php
+++ b/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php
@@ -61,7 +61,38 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
return null;
}
- public function listWorkflows(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string
+ /**
+ * @param array{relatedEntityClass: string, relatedEntityId: int} $supplementaryRelated
+ *
+ * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
+ * @throws \Twig\Error\LoaderError
+ * @throws \Twig\Error\RuntimeError
+ * @throws \Twig\Error\SyntaxError
+ */
+ public function listWorkflows(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = [], array $supplementaryRelated = []): string
+ {
+ [$blankEntityWorkflow, $workflowsAvailable, $entityWorkflows] = $this->getWorkflowsForRelated($relatedEntityClass, $relatedEntityId);
+
+ foreach ($supplementaryRelated as $supplementary) {
+ [$supplementaryBlankEntityWorkflow, $supplementaryWorkflowsAvailable, $supplementaryEntityWorkflows]
+ = $this->getWorkflowsForRelated($supplementary['relatedEntityClass'], $supplementary['relatedEntityId']);
+
+ $entityWorkflows = array_merge($entityWorkflows, $supplementaryEntityWorkflows);
+ }
+
+ return $environment->render('@ChillMain/Workflow/_extension_list_workflow_for.html.twig', [
+ 'entity_workflows_json' => $this->normalizer->normalize($entityWorkflows, 'json', ['groups' => 'read']),
+ 'blank_workflow' => $blankEntityWorkflow,
+ 'workflows_available' => $workflowsAvailable,
+ 'relatedEntityClass' => $relatedEntityClass,
+ 'relatedEntityId' => $relatedEntityId,
+ ]);
+ }
+
+ /**
+ * @return array where keys are: {0: blankWorkflow, 1: entityWorkflows, 2: workflowList}
+ */
+ private function getWorkflowsForRelated(string $relatedEntityClass, int $relatedEntityId): array
{
$blankEntityWorkflow = new EntityWorkflow();
$blankEntityWorkflow
@@ -70,25 +101,13 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
$workflowsList = $this->metadataExtractor->availableWorkflowFor($relatedEntityClass, $relatedEntityId);
- // get the related entity already created
- $entityWorkflows = [];
-
- foreach ($entityWorkflowsNaked = $this->repository->findBy(
- ['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId]
- ) as $entityWorkflow) {
- $workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
- $entityWorkflows[] = [
- 'entity_workflow' => $entityWorkflow,
- 'workflow' => $this->metadataExtractor->buildArrayPresentationForWorkflow($workflow),
- 'handler' => $this->entityWorkflowManager->getHandler($entityWorkflow),
+ return
+ [
+ $blankEntityWorkflow,
+ $workflowsList,
+ $this->repository->findBy(
+ ['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId]
+ ),
];
- }
-
- return $environment->render('@ChillMain/Workflow/_extension_list_workflow_for.html.twig', [
- 'entity_workflows_json' => $this->normalizer->normalize($entityWorkflowsNaked, 'json', ['groups' => 'read']),
- 'entity_workflows' => $entityWorkflows,
- 'blank_workflow' => $blankEntityWorkflow,
- 'workflows_availables' => $workflowsList,
- ]);
}
}
diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml
index d370979b8..6d55532a6 100644
--- a/src/Bundle/ChillMainBundle/config/services.yaml
+++ b/src/Bundle/ChillMainBundle/config/services.yaml
@@ -38,6 +38,17 @@ services:
arguments:
$handlers: !tagged_iterator chill_main.workflow_handler
+ Chill\MainBundle\Workflow\EventSubscriber\SendAccessKeyEventSubscriber:
+ autoconfigure: true
+ autowire: true
+ tags:
+ -
+ name: 'doctrine.orm.entity_listener'
+ event: 'postPersist'
+ entity: 'Chill\MainBundle\Entity\Workflow\EntityWorkflowStep'
+ # set the 'lazy' option to TRUE to only instantiate listeners when they are used
+ lazy: true
+
# other stuffes
chill.main.helper.translatable_string:
diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220223171457.php b/src/Bundle/ChillMainBundle/migrations/Version20220223171457.php
new file mode 100644
index 000000000..b62f4a88a
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/migrations/Version20220223171457.php
@@ -0,0 +1,51 @@
+addSql('ALTER TABLE chill_main_workflow_entity_step DROP accessKey');
+ $this->addSql('DROP TABLE chill_main_workflow_entity_step_user_by_accesskey');
+ }
+
+ public function getDescription(): string
+ {
+ return 'Add access key to EntityWorkflowStep';
+ }
+
+ public function up(Schema $schema): void
+ {
+ $this->addSql('ALTER TABLE chill_main_workflow_entity_step ADD accessKey TEXT DEFAULT NULL');
+ $this->addSql('WITH randoms AS (select
+ cmwes.id,
+ string_agg(substr(characters, (random() * length(characters) + 0.5)::integer, 1), \'\') as random_word
+ from (values(\'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\')) as symbols(characters)
+ -- length of word
+ join generate_series(1, 32) on 1 = 1
+ JOIN chill_main_workflow_entity_step cmwes ON true
+ GROUP BY cmwes.id)
+ UPDATE chill_main_workflow_entity_step SET accessKey = randoms.random_word FROM randoms WHERE chill_main_workflow_entity_step.id = randoms.id');
+ $this->addSql('ALTER TABLE chill_main_workflow_entity_step ALTER accessKey DROP DEFAULT ');
+ $this->addSql('ALTER TABLE chill_main_workflow_entity_step ALTER accessKey SET NOT NULL');
+
+ $this->addSql('CREATE TABLE chill_main_workflow_entity_step_user_by_accesskey (entityworkflowstep_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(entityworkflowstep_id, user_id))');
+ $this->addSql('CREATE INDEX IDX_8296D8397E6AF9D4 ON chill_main_workflow_entity_step_user_by_accesskey (entityworkflowstep_id)');
+ $this->addSql('CREATE INDEX IDX_8296D839A76ED395 ON chill_main_workflow_entity_step_user_by_accesskey (user_id)');
+ $this->addSql('ALTER TABLE chill_main_workflow_entity_step_user_by_accesskey ADD CONSTRAINT FK_8296D8397E6AF9D4 FOREIGN KEY (entityworkflowstep_id) REFERENCES chill_main_workflow_entity_step (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
+ $this->addSql('ALTER TABLE chill_main_workflow_entity_step_user_by_accesskey ADD CONSTRAINT FK_8296D839A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
+ }
+}
diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
index 78659c819..e907f187f 100644
--- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
@@ -397,6 +397,23 @@ workflow:
Current step: Étape actuelle
Comment on last change: Commentaire à la transition précédente
Users allowed to apply transition: Utilisateurs pouvant valider cette étape
+ Workflow deleted with success: Le workflow a été supprimé
+ Delete workflow ?: Supprimer le workflow ?
+ Are you sure you want to delete this workflow ?: Êtes-vous sûr·e de vouloir supprimer ce 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
+ Remove an email: Enlever cette adresse email
+ Any email: Aucune adresse email
+ Previous dest without reaction: Workflows clotûrés après action d'un autre utilisateur
+ Previous workflow without reaction help: Liste des workflows où vous avez été cité comme pouvant réagir à une étape, mais où un autre utilisateur a exécuté une action avant vous.
+ Previous transitionned: Anciens workflows
+ Previous workflow transitionned help: Workflows où vous avez exécuté une action.
+
Subscribe final: Recevoir une notification à l'étape finale
Subscribe all steps: Recevoir une notification à chaque étape
diff --git a/src/Bundle/ChillMainBundle/translations/validators.fr.yml b/src/Bundle/ChillMainBundle/translations/validators.fr.yml
index 33973f9d7..da433ba0f 100644
--- a/src/Bundle/ChillMainBundle/translations/validators.fr.yml
+++ b/src/Bundle/ChillMainBundle/translations/validators.fr.yml
@@ -28,3 +28,6 @@ notification:
At least one addressee: Indiquez au moins un destinataire
Title must be defined: Un titre doit être indiqué
Comment content might not be blank: Le commentaire ne peut pas être vide
+
+workflow:
+ You must add at least one dest user or email: Indiquez au moins un destinataire ou une adresse email
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index 3da40db4c..f1306640b 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -322,19 +322,39 @@ final class AccompanyingCourseApiController extends ApiController
/**
* @Route("/api/1.0/person/accompanying-course/{id}/confidential.json", name="chill_api_person_accompanying_period_confidential")
* @ParamConverter("accompanyingCourse", options={"id": "id"})
+ *
+ * @param mixed $id
*/
- public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, Request $request)
+ public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, $id, Request $request)
{
if ($request->getMethod() === 'POST') {
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL, $accompanyingCourse);
$accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential());
+
$this->getDoctrine()->getManager()->flush();
}
return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]);
}
+ /**
+ * @Route("/api/1.0/person/accompanying-course/{id}/intensity.json", name="chill_api_person_accompanying_period_intensity")
+ * @ParamConverter("accompanyingCourse", options={"id": "id"})
+ */
+ public function toggleIntensityApi(AccompanyingPeriod $accompanyingCourse, Request $request)
+ {
+ if ($request->getMethod() === 'POST') {
+ $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_INTENSITY, $accompanyingCourse);
+
+ $status = $accompanyingCourse->getIntensity() === 'regular' ? 'occasional' : 'regular';
+ $accompanyingCourse->setIntensity($status);
+ $this->getDoctrine()->getManager()->flush();
+ }
+
+ return $this->json($accompanyingCourse->getIntensity(), Response::HTTP_OK, [], ['groups' => ['read']]);
+ }
+
public function workApi($id, Request $request, string $_format): Response
{
return $this->addRemoveSomething(
diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
index 716ef9ee8..b05da5626 100644
--- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
+++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
@@ -395,16 +395,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
],
],
- 'confidential' => [
- 'methods' => [
- Request::METHOD_POST => true,
- Request::METHOD_GET => true,
- ],
- 'controller_action' => 'toggleConfidentialApi',
- 'roles' => [
- Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL,
- ],
- ],
+ // 'confidential' => [
+ // 'methods' => [
+ // Request::METHOD_POST => true,
+ // Request::METHOD_GET => true,
+ // ],
+ // 'controller_action' => 'toggleConfidentialApi',
+ // 'roles' => [
+ // Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL,
+ // ],
+ // ],
'findAccompanyingPeriodsByPerson' => [
'path' => '/by-person/{person_id}.{_format}',
'controller_action' => 'getAccompanyingPeriodsByPerson',
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index 0012f341d..d75ade12b 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -30,6 +30,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\AccompanyingPeriodValidity;
+use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ConfidentialCourseMustHaveReferrer;
+use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\LocationValidity;
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap;
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
@@ -62,12 +64,9 @@ use const SORT_REGULAR;
* "accompanying_period": AccompanyingPeriod::class
* })
* @Assert\GroupSequenceProvider
- * @Assert\Expression(
- * "this.isConfidential and this.getUser === NULL",
- * message="If the accompanying course is confirmed and confidential, a referrer must remain assigned."
- * )
- *
* @AccompanyingPeriodValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
+ * @LocationValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
+ * @ConfidentialCourseMustHaveReferrer(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
*/
class AccompanyingPeriod implements
GroupSequenceProviderInterface,
@@ -201,7 +200,7 @@ class AccompanyingPeriod implements
/**
* @var string
* @ORM\Column(type="string", nullable=true)
- * @Groups({"read", "write"})
+ * @Groups({"read"})
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private $intensity = self::INTENSITY_OCCASIONAL;
@@ -1000,7 +999,7 @@ class AccompanyingPeriod implements
}
/**
- * Validation function.
+ * Validation functions.
*/
public function isDateConsistent(ExecutionContextInterface $context)
{
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
index b7e8d1c5d..ed00c8611 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
@@ -250,10 +250,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->accompanyingPeriod;
}
- /**
- * @return Collection
- */
- public function getAccompanyingPeriodWorkEvaluations()
+ public function getAccompanyingPeriodWorkEvaluations(): Collection
{
return $this->accompanyingPeriodWorkEvaluations;
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
index 68f508b95..07c9f526c 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
@@ -67,10 +67,15 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
private ?User $createdBy = null;
/**
+ * **Note on deserialization/denormalization**: denormalization of documents is handled by.
+ *
+ * @see{Chill\PersonBundle\Serializer\Normalizer\AccompanyingPeriodWorkEvaluationDenormalizer}
+ *
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWorkEvaluationDocument::class,
* mappedBy="accompanyingPeriodWorkEvaluation",
- * cascade={"remove"}
+ * cascade={"remove", "persist"},
+ * orphanRemoval=true
* )
* @Serializer\Groups({"read"})
*/
@@ -261,6 +266,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
public function removeDocument(AccompanyingPeriodWorkEvaluationDocument $document): self
{
$this->documents->removeElement($document);
+ $document->setAccompanyingPeriodWorkEvaluation(null);
return $this;
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php
index cbb4231b8..b31225df1 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php
@@ -41,6 +41,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?\DateTimeImmutable $createdAt = null;
@@ -49,6 +50,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* targetEntity=User::class
* )
* @Serializer\Groups({"read"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?User $createdBy = null;
@@ -60,15 +62,32 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* @internal the default name exceeds 64 characters, we must set manually:
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
* @Serializer\Groups({"read"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
- private ?int $id;
+ private ?int $id = null;
+
+ /**
+ * This is a workaround for client, to allow them to assign arbitrary data
+ * dedicated to their job.
+ *
+ * This data is not persisted into database, but will appears on the data
+ * normalized during the same request (like PUT/PATCH request)
+ *
+ * @Serializer\Groups({"read"})
+ * @Serializer\Groups({"write"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
+ *
+ * @var mixed
+ */
+ private $key;
/**
* @ORM\ManyToOne(
* targetEntity=StoredObject::class,
- * cascade={"remove"},
* )
* @Serializer\Groups({"read"})
+ * @Serializer\Groups({"write"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?StoredObject $storedObject = null;
@@ -77,12 +96,22 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* targetEntity=DocGeneratorTemplate::class
* )
* @Serializer\Groups({"read"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?DocGeneratorTemplate $template = null;
+ /**
+ * @ORM\Column(type="text", nullable=false, options={"default": ""})
+ * @Serializer\Groups({"read"})
+ * @Serializer\Groups({"write"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
+ */
+ private ?string $title = '';
+
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?\DateTimeImmutable $updatedAt = null;
@@ -91,6 +120,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* targetEntity=User::class
* )
* @Serializer\Groups({"read"})
+ * @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?User $updatedBy = null;
@@ -117,6 +147,14 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this->id;
}
+ /**
+ * @return mixed
+ */
+ public function getKey()
+ {
+ return $this->key;
+ }
+
public function getStoredObject(): ?StoredObject
{
return $this->storedObject;
@@ -127,6 +165,11 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this->template;
}
+ public function getTitle(): ?string
+ {
+ return $this->title;
+ }
+
/**
* @return DateTimeImmutable|null
*/
@@ -171,6 +214,18 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this;
}
+ /**
+ * @param mixed $key
+ *
+ * @return AccompanyingPeriodWorkEvaluationDocument
+ */
+ public function setKey($key)
+ {
+ $this->key = $key;
+
+ return $this;
+ }
+
public function setStoredObject(?StoredObject $storedObject): AccompanyingPeriodWorkEvaluationDocument
{
$this->storedObject = $storedObject;
@@ -185,6 +240,13 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this;
}
+ public function setTitle(?string $title): AccompanyingPeriodWorkEvaluationDocument
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
{
$this->updatedAt = $datetime;
diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocumentRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocumentRepository.php
new file mode 100644
index 000000000..d2dfe094a
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocumentRepository.php
@@ -0,0 +1,61 @@
+repository = $em->getRepository(AccompanyingPeriodWorkEvaluationDocument::class);
+ }
+
+ public function find($id): ?AccompanyingPeriodWorkEvaluationDocument
+ {
+ return $this->repository->find($id);
+ }
+
+ /**
+ * @return array|object[]|AccompanyingPeriodWorkEvaluationDocument[]
+ */
+ public function findAll(): array
+ {
+ return $this->repository->findAll();
+ }
+
+ /**
+ * @param null|mixed $limit
+ * @param null|mixed $offset
+ *
+ * @return array|object[]|AccompanyingPeriodWorkEvaluationDocument[]
+ */
+ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
+ {
+ return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
+ }
+
+ public function findOneBy(array $criteria): ?AccompanyingPeriodWorkEvaluationDocument
+ {
+ return $this->repository->findOneBy($criteria);
+ }
+
+ public function getClassName(): string
+ {
+ return AccompanyingPeriodWorkEvaluationDocument::class;
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue
index 39fe50acc..a24277fa0 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue
@@ -58,7 +58,7 @@ export default {
this.$store.dispatch('toggleIntensity', value)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
- violations.forEach((violation) => this.$toast.open({message: violation}));
+ this.$toast.open({message: this.$t('Only the referrer can toggle the intensity of an accompanying course')})
} else {
this.$toast.open({message: 'An error occurred'})
}
@@ -75,20 +75,15 @@ export default {
});
},
toggleConfidential() {
- this.$store.dispatch('fetchPermissions').then(() => {
- if (!this.$store.getters.canTogglePermission) {
- this.$toast.open({message: "Seul le référent peut modifier la confidentialité"});
- return Promise.resolve();
- } else {
- return this.$store.dispatch('toggleConfidential', (!this.isConfidential));
- }
- }).catch(({name, violations}) => {
- if (name === 'ValidationException' || name === 'AccessException') {
- violations.forEach((violation) => this.$toast.open({message: violation}));
- } else {
- this.$toast.open({message: 'An error occurred'})
- }
- });
+ this.$store.dispatch('toggleConfidential')
+ .catch(({name, violations}) => {
+ console.log(name);
+ if (name === 'ValidationException' || name === 'AccessException') {
+ this.$toast.open({message: this.$t('Only the referrer can toggle the confidentiality of an accompanying course')})
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
},
},
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
index 8440e50d5..4cf073eb4 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
@@ -46,6 +46,12 @@ if (root === 'banner') {
})
.use(store)
.use(i18n)
+ .use(VueToast, {
+ position: "bottom-right",
+ type: "error",
+ duration: 5000,
+ dismissible: true
+ })
.component('banner', Banner)
.mount('#banner-accompanying-course');
});
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
index 49253eab8..5f0321c70 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
@@ -167,6 +167,8 @@ const appMessages = {
'Error while retriving users.': "Erreur du serveur lors du chargement de la liste des travailleurs.",
'Error while getting whoami.': "Erreur du serveur lors de la requête 'qui suis-je ?'",
'Error while retriving origin\'s list.': "Erreur du serveur lors du chargement de la liste des origines de la demande.",
+ 'Only the referrer can toggle the intensity of an accompanying course': "Seul le référent peut modifier l'intensité d'un parcours.",
+ 'Only the referrer can toggle the confidentiality of an accompanying course': "Seul le référent peut modifier la confidentialité d'un parcours."
}
};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
index 05960aaea..f7fd59b32 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
@@ -420,24 +420,24 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
const url = `/api/1.0/person/accompanying-course/resource/${id}.json`;
return makeFetch('PATCH', url, body)
- .then((response) => {
- commit('patchResource', response);
- })
- .catch((error) => {
- commit('catchError', error);
- throw error;
- })
+ .then((response) => {
+ commit('patchResource', response);
+ })
+ .catch((error) => {
+ commit('catchError', error);
+ throw error;
+ })
},
/**
* Update accompanying course intensity/emergency/confidentiality
*/
toggleIntensity({ commit }, payload) {
- const url = `/api/1.0/person/accompanying-course/${id}.json`
+ const url = `/api/1.0/person/accompanying-course/${id}/intensity.json`
const body = { type: "accompanying_period", 'intensity': payload }
- return makeFetch('PATCH', url, body)
+ return makeFetch('POST', url, body)
.then((response) => {
- commit('toggleIntensity', response.intensity);
+ commit('toggleIntensity', response);
})
.catch((error) => {
@@ -459,14 +459,18 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
})
},
toggleConfidential({ commit }, payload) {
- const url = `/api/1.0/person/accompanying-course/${id}.json`
+ const url = `/api/1.0/person/accompanying-course/${id}/confidential.json`
const body = { type: "accompanying_period", confidential: payload }
- return makeFetch('PATCH', url, body)
+ console.log('url', url, 'body', body);
+
+ return makeFetch('POST', url, body)
.then((response) => {
- commit('toggleConfidential', response.confidential);
+ console.log('response', response);
+ commit('toggleConfidential', response);
})
.catch((error) => {
+ console.log('error', error)
commit('catchError', error);
throw error;
})
@@ -737,10 +741,10 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
"object": {
"type": "accompanying_period",
"id": id
- },
- "class": "Chill\\PersonBundle\\Entity\\AccompanyingPeriod",
- "roles": [
- "CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL"
+ },
+ "class": "Chill\\PersonBundle\\Entity\\AccompanyingPeriod",
+ "roles": [
+ "CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL"
]
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
index 94c6c0b55..a0d88d1bf 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
@@ -251,6 +251,7 @@
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork"
:relatedEntityId="this.work.id"
:workflowsAvailables="this.work.workflows_availables"
+ :preventDefaultMoveToGenerate="true"
@go-to-generate-workflow="goToGenerateWorkflow"
>
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue
index faf4b0ed0..579d0b306 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue
@@ -106,8 +106,6 @@ export default {
this.toggleEditEvaluation();
},
goToGenerateWorkflow({event, link, workflowName}) {
- console.log('goToGenerate in evaluation', event, link, workflowName);
-
const callback = (data) => {
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id;
window.location.assign(buildLinkCreate(workflowName,
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue
index cabebf973..b077cfefa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue
@@ -65,29 +65,55 @@
{{ $t('Documents') }} :
-
+
-
{{ d.template.name.fr }}
-
-
Créé par {{ d.createdBy.text }}
- Le {{ $d(ISOToDatetime(d.createdAt.datetime), 'long') }}
-
-
+
+
{{ $t('document_add') }} :
{{ $t('evaluation_generate_a_document') }}
+
+
{{ $t('document_upload') }}
+
+
+