-
+
+
@@ -29,18 +29,5 @@ export default {
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue
index 9a5dc2644..fca64106f 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue
@@ -27,7 +27,6 @@
-
@@ -94,6 +93,7 @@ export default {
return this.isMultiline === true ? "multiline" : "";
},
isConfidential() {
+ console.log(this.address.confidential)
return this.address.confidential;
}
}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue
index ccc1d4568..0e16b522f 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue
@@ -5,7 +5,7 @@
-
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/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
index 0f2b52568..00ae02dc8 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
@@ -46,7 +46,8 @@ const messages = {
person: "Quitter la page et ouvrir la fiche de l'usager",
thirdparty: "Quitter la page et voir le tiers",
},
- refresh: 'Rafraîchir'
+ refresh: 'Rafraîchir',
+ addContact: 'Ajouter un contact'
},
nav: {
next: "Suivant",
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/Templating/Entity/ChillEntityRenderExtension.php b/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderExtension.php
index e1eae3884..2081f3d9a 100644
--- a/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderExtension.php
+++ b/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderExtension.php
@@ -25,21 +25,17 @@ class ChillEntityRenderExtension extends AbstractExtension
protected $defaultRender;
/**
- * @var ChillEntityRenderInterface
+ * @var iterable|ChillEntityRenderInterface[]
*/
protected $renders = [];
/**
* ChillEntityRenderExtension constructor.
*/
- public function __construct()
+ public function __construct(iterable $renders)
{
$this->defaultRender = new ChillEntityRender();
- }
-
- public function addRender(ChillEntityRenderInterface $render)
- {
- $this->renders[] = $render;
+ $this->renders = $renders;
}
/**
diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/CompilerPass.php b/src/Bundle/ChillMainBundle/Templating/Entity/CompilerPass.php
deleted file mode 100644
index 38f6284ca..000000000
--- a/src/Bundle/ChillMainBundle/Templating/Entity/CompilerPass.php
+++ /dev/null
@@ -1,31 +0,0 @@
-getDefinition(ChillEntityRenderExtension::class);
-
- foreach ($container->findTaggedServiceIds('chill.render_entity') as $id => $tags) {
- $extension->addMethodCall('addRender', [new Reference($id)]);
- }
- }
-}
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/chill.api.specs.yaml b/src/Bundle/ChillMainBundle/chill.api.specs.yaml
index 607e7fc73..133345a6f 100644
--- a/src/Bundle/ChillMainBundle/chill.api.specs.yaml
+++ b/src/Bundle/ChillMainBundle/chill.api.specs.yaml
@@ -788,6 +788,16 @@ paths:
description: "accepted"
403:
description: "unauthorized"
+ /1.0/main/civility.json:
+ get:
+ tags:
+ - civility
+ summary: Return all civility types
+ responses:
+ 200:
+ description: "ok"
+ 401:
+ description: "Unauthorized"
/1.0/main/user-job.json:
get:
tags:
diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml
index dd2407d2b..57e18ce86 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/config/services/templating.yaml b/src/Bundle/ChillMainBundle/config/services/templating.yaml
index ade26b946..e69700732 100644
--- a/src/Bundle/ChillMainBundle/config/services/templating.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/templating.yaml
@@ -32,6 +32,8 @@ services:
- { name: twig.extension }
Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension:
+ arguments:
+ $renders: !tagged_iterator chill.render_entity
tags:
- { name: twig.extension }
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/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/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php
index f69081584..31af0a649 100644
--- a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php
+++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php
@@ -16,7 +16,7 @@ use Chill\MainBundle\Form\Type\CommentType;
use Chill\PersonBundle\Entity\Person\PersonResource;
use Chill\PersonBundle\Entity\Person\PersonResourceKind;
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
-use Chill\PersonBundle\Templating\Entity\PersonRender;
+use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Chill\PersonBundle\Templating\Entity\ResourceKindRender;
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
@@ -29,7 +29,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
final class PersonResourceType extends AbstractType
{
- private PersonRender $personRender;
+ private PersonRenderInterface $personRender;
private ResourceKindRender $resourceKindRender;
@@ -37,7 +37,7 @@ final class PersonResourceType extends AbstractType
private TranslatorInterface $translator;
- public function __construct(ResourceKindRender $resourceKindRender, PersonRender $personRender, ThirdPartyRender $thirdPartyRender, TranslatorInterface $translator)
+ public function __construct(ResourceKindRender $resourceKindRender, PersonRenderInterface $personRender, ThirdPartyRender $thirdPartyRender, TranslatorInterface $translator)
{
$this->resourceKindRender = $resourceKindRender;
$this->personRender = $personRender;
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/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
index 431441b4f..35b7fcbd6 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
@@ -159,10 +159,10 @@ export default {
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
- this.$toast.open({message: v });
+ this.$toast.open({message: v });
}
} else {
- this.$toast.open({message: 'An error occurred'});
+ this.$toast.open({message: 'An error occurred'});
}
})
}
@@ -171,9 +171,7 @@ export default {
body.name = payload.data.text;
body.email = payload.data.email;
body.telephone = payload.data.phonenumber;
- body.address = payload.data.address ? { id: payload.data.address.address_id } : null;
-
- console.log('body', body)
+ body.address = payload.data.address ? { id: payload.data.address.address_id } : null;
makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)
.then(response => {
@@ -183,10 +181,10 @@ export default {
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
- this.$toast.open({message: v });
+ this.$toast.open({message: v });
}
} else {
- this.$toast.open({message: 'An error occurred'});
+ this.$toast.open({message: 'An error occurred'});
}
})
}
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') }}
+
+
+
@@ -111,6 +151,9 @@ import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js';
import { mapGetters, mapState } from 'vuex';
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
import {buildLink} from 'ChillDocGeneratorAssets/lib/document-generator';
+import AddAsyncUpload from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUpload.vue';
+import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue';
+import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
const i18n = {
messages: {
@@ -129,6 +172,11 @@ const i18n = {
evaluation_add_a_document: "Ajouter un document",
evaluation_add: "Ajouter une évaluation",
Documents: "Documents",
+ document_add: "Générer ou téléverser un document",
+ document_upload: "Téléverser un document",
+ document_title: "Titre du document",
+ template_title: "Nom du template",
+ browse: "Ajouter un document"
}
}
};
@@ -139,12 +187,19 @@ export default {
components: {
ckeditor: CKEditor.component,
PickTemplate,
+ AddAsyncUpload,
+ ListWorkflowModal,
},
i18n,
data() {
return {
editor: ClassicEditor,
template: null,
+ asyncUploadOptions: {
+ maxFiles: 1,
+ maxPostSize: 15000000,
+ required: false,
+ }
}
},
computed: {
@@ -162,7 +217,6 @@ export default {
return dateToISO(this.evaluation.startDate);
},
set(v) {
- console.log(v);
this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) });
}
},
@@ -205,11 +259,11 @@ export default {
})
;
},
- buildEditLink(storedObject) {
- return `/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent(
+ buildEditLink(storedObject) {
+ return `/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent(
window.location.pathname + window.location.search + window.location.hash);
- },
- submitBeforeGenerate({template}) {
+ },
+ submitBeforeGenerate({template}) {
const callback = (data) => {
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id;
@@ -217,7 +271,36 @@ export default {
};
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
- }
+ },
+ onInputDocumentTitle(event) {
+ const id = Number(event.target.id);
+ const title = event.target.value;
+ this.$store.commit('updateDocumentTitle', {id: id, evaluationKey: this.evaluation.key, title: title});
+ },
+ addDocument(storedObject) {
+ let document = {
+ type: 'accompanying_period_work_evaluation_document',
+ storedObject: storedObject,
+ title: 'Nouveau document',
+ };
+ this.$store.commit('addDocument', {key: this.evaluation.key, document: document});
+ },
+ removeDocument(document) {
+ if (window.confirm("Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre \"" + document.title +"\" ?")) {
+ this.$store.commit('removeDocument', {key: this.evaluation.key, document: document});
+ }
+ },
+ goToGenerateWorkflowEvaluationDocument({event, link, workflowName, payload}) {
+ const callback = (data) => {
+ let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
+ let updatedDocument = evaluation.documents.find(d => d.key === payload.doc.key);
+ window.location.assign(buildLinkCreate(workflowName,
+ 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', updatedDocument.id));
+ };
+
+ return this.$store.dispatch('submit', callback)
+ .catch(e => { console.log(e); throw e; });
+ },
},
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
index b5421ea48..7f96843e5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
@@ -110,6 +110,7 @@ const store = createStore({
maxDate: e.maxDate !== null ? { datetime: datetimeToISO(e.maxDate) } : null,
warningInterval: intervalDaysToISO(e.warningInterval),
comment: e.comment,
+ documents: e.documents
};
if (e.id !== undefined) {
o.id = e.id;
@@ -130,6 +131,11 @@ const store = createStore({
endDate: e.endDate !== null ? ISOToDatetime(e.endDate.datetime) : null,
maxDate: e.maxDate !== null ? ISOToDatetime(e.maxDate.datetime) : null,
warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null,
+ documents: e.documents.map((d, dindex) => {
+ return Object.assign(d, {
+ key: index
+ });
+ }),
});
return k;
@@ -197,6 +203,24 @@ const store = createStore({
found.results = found.results.filter(r => r.id !== result.id);
},
+ addDocument(state, payload) {
+ let evaluation = state.evaluationsPicked.find(e => e.key === payload.key);
+ evaluation.documents.push(Object.assign(
+ payload.document, {
+ key: evaluation.documents.length + 1,
+ workflows_availables: state.work.workflows_availables_evaluation_documents,
+ workflows: [],
+ }));
+ },
+ removeDocument(state, {key, document}) {
+ let evaluations = state.evaluationsPicked.find(e => e.key === key);
+
+ if (evaluations === undefined) {
+ return;
+ }
+
+ evaluations.documents = evaluations.documents.filter(d => d.key !== document.key);
+ },
addEvaluation(state, evaluation) {
let e = {
type: "accompanying_period_work_evaluation",
@@ -284,6 +308,10 @@ const store = createStore({
setIsPosting(state, st) {
state.isPosting = st;
},
+ updateDocumentTitle(state, payload) {
+ state.evaluationsPicked.find(e => e.key === payload.evaluationKey)
+ .documents.find(d => d.id === payload.id).title = payload.title;
+ }
},
actions: {
updateThirdParty({ commit }, payload) {
@@ -374,13 +402,18 @@ const store = createStore({
});
}
},
+ addDocument({commit}, payload) {
+ commit('addDocument', payload);
+ },
+ removeDocument({commit}, payload) {
+ commit('removeDocument', payload);
+ },
submit({ getters, state, commit }, callback) {
let
payload = getters.buildPayload,
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
errors = []
;
-
commit('setIsPosting', true);
return makeFetch('PUT', url, payload)
@@ -397,6 +430,9 @@ const store = createStore({
commit('setErrors', error.violations);
});
},
+ updateDocumentTitle({commit}, payload) {
+ commit('updateDocumentTitle', payload)
+ }
}
});
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
index 6d679ff7a..37707155d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
@@ -57,6 +57,8 @@
v-bind:item="item"
v-bind:search="search"
v-bind:type="checkUniq"
+ @saveFormOnTheFly="saveFormOnTheFly"
+ @newPriorSuggestion="newPriorSuggestion"
@updateSelected="updateSelected">
@@ -249,7 +251,7 @@ export default {
}
},
newPriorSuggestion(entity) {
- console.log('newPriorSuggestion', entity);
+ // console.log('newPriorSuggestion', entity);
if (entity !== null) {
let suggestion = {
key: entity.type + entity.id,
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue
index c6bd0b262..b605cd5b5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue
@@ -18,6 +18,7 @@
@@ -26,10 +27,10 @@
v-bind:item="item">
-
-
+
+
@@ -54,7 +55,7 @@ export default {
'search',
'type'
],
- emits: ['updateSelected'],
+ emits: ['updateSelected', 'newPriorSuggestion'],
computed: {
selected: {
set(value) {
@@ -72,6 +73,9 @@ export default {
methods: {
setValueByType(value, type) {
return (type === 'radio')? [value] : value;
+ },
+ newPriorSuggestion(response) {
+ this.$emit('newPriorSuggestion', response)
}
}
};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue
index 28f74818a..0c8251e4a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue
@@ -1,13 +1,14 @@
+ {{ item.result.profession.name.fr }}
- {{ item.result.text }}
+ {{ item.result.text }}
- {{ getAddress.text }} -
- {{ getAddress.postcode.name }}
+ {{ getAddress.text }} -
+ {{ getAddress.postcode.name }}
@@ -19,21 +20,28 @@
-
-
-
-
+
+
+
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue
index 85ac8ae7c..d87e0f50c 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue
@@ -12,6 +12,7 @@
{{ person.firstName }}
{{ person.lastName }}
+
{{ person.suffixText }}
{{ altNameLabel }}
@@ -20,6 +21,7 @@
{{ person.firstName }}
{{ person.lastName }}
+
{{ person.suffixText }}
(‡)
{{ altNameLabel }}
@@ -111,6 +113,15 @@
{{ $t('renderbox.no_data') }}
+
+
+ {{ person.email }}
+
+
+
+ {{ $t('renderbox.no_data') }}
+
+
{{ c.name }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue
index 8f89649d8..8b991e3da 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue
@@ -6,6 +6,7 @@
({{ altNameLabel }})
+ {{ person.suffixText }}
{{ $tc('renderbox.years_old', person.age) }}
(‡)
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig
index b153329b7..770966d8b 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig
@@ -101,14 +101,31 @@
{% if notif_counter.total > 0 %}
{{ chill_counter_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', w.id) }}
{% endif %}
-
+
{% import '@ChillPerson/Macro/updatedBy.html.twig' as macro %}
{{ macro.updatedBy(w) }}
-
+
{% if displayAction is defined and displayAction == true %}
+ {% set suppEvaluations = [] %}
+ {% for e in w.accompanyingPeriodWorkEvaluations %}
+ {% set suppEvaluations = suppEvaluations|merge([
+ {'relatedEntityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation', 'relatedEntityId': e.id }
+ ]) %}
+
+ {% for d in e.documents %}
+ {% set suppEvaluations = suppEvaluations|merge([
+ {'relatedEntityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', 'relatedEntityId': d.id }
+ ]) %}
+ {% endfor %}
+ {% endfor %}
+
+ {{ chill_entity_workflow_list(
+ 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork',
+ w.id, [], suppEvaluations) }}
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig
index 02fc00e4c..e3280d755 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig
@@ -12,6 +12,7 @@
* hLevel integer
* addDeath bool
* addAgeBadge bool
+ * suffixText bool
* address_multiline bool
* customButtons [
'before' Twig\Markup, (injected with macro)
@@ -46,6 +47,11 @@
({{- 'years_old'|trans({ 'age': person.age }) -}})
{% endif %}
{% endif %}
+ {%- if options['suffixText'] is defined -%}
+ {% for o in options['suffixText'] %}
+ {{ o }}
+ {% endfor %}
+ {% endif %}
{% endmacro raw %}
{% macro label(person, options) %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.title.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.title.html.twig
deleted file mode 100644
index 2cc640c82..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.title.html.twig
+++ /dev/null
@@ -1,19 +0,0 @@
-{% import '@ChillMain/Workflow/macro_breadcrumb.html.twig' as m %}
-
-
-
- {% if concerne is defined and concerne == true %}
- {{ 'Concerne'|trans }}:
- {% endif %}
-
- {{ 'workflow.Work (n°%w%)'|trans({'%w%': work.id }) }}
-
- {% if description is defined and description == true %}
- {{ ' — ' ~ work.socialAction|chill_entity_render_string }}
- {% endif %}
-
-
- {% if breadcrumb is defined and breadcrumb == true %}
- {{ m.breadcrumb(_context) }}
- {% endif %}
-
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.html.twig
index 989052a0a..488f31661 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.html.twig
@@ -62,10 +62,14 @@
{% endif %}
+ {% if evaluation.createdBy is not null %}
créé par
{{ evaluation.createdBy.username }}
+ {% endif %}
+ {% if evaluation.createdAt is not null %}
{{ 'le'|trans }}
{{ evaluation.createdAt|format_date('short') }}
+ {% endif %}
{% if evaluation.comment %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.title.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.title.html.twig
deleted file mode 100644
index 4b52acc24..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.title.html.twig
+++ /dev/null
@@ -1,19 +0,0 @@
-{% import '@ChillMain/Workflow/macro_breadcrumb.html.twig' as m %}
-
-
-
- {% if concerne is defined and concerne == true %}
- {{ 'Concerne'|trans }}:
- {% endif %}
-
- {{ 'workflow.Evaluation (n°%eval%)'|trans({'%eval%': evaluation.id}) }}
-
- {% if description is defined and description == true %}
- {{ ' — ' ~ evaluation.evaluation.title|localize_translatable_string }}
- {% endif %}
-
-
- {% if breadcrumb is defined and breadcrumb == true %}
- {{ m.breadcrumb(_context) }}
- {% endif %}
-
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig
new file mode 100644
index 000000000..488f31661
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+ {{ evaluation.accompanyingPeriodWork.socialAction|chill_entity_render_string }}
+
+
+ {{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}
+ {{ evaluation.accompanyingPeriodWork.startDate|format_date('short') }}
+
+ {% if evaluation.accompanyingPeriodWork.endDate %}
+
+ {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}
+ {{ evaluation.accompanyingPeriodWork.endDate|format_date('short') }}
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+ {{ 'Évaluation'|trans }}
+
+
+
+
+
+
+
+
+
+ {{ evaluation.evaluation.title|localize_translatable_string }}
+
+
+ {{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}
+ {{ evaluation.startDate|format_date('short') }}
+
+ {% if evaluation.endDate %}
+
+ {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}
+ {{ evaluation.endDate|format_date('short') }}
+
+ {% endif %}
+ {% if evaluation.maxDate %}
+
+ {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }}
+ {{ evaluation.maxDate|format_date('short') }}
+
+ {% endif %}
+ {% if evaluation.warningInterval and evaluation.warningInterval.d > 0 %}
+
+ {% set days = (evaluation.warningInterval.d + evaluation.warningInterval.m * 30) %}
+ {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }}
+ {{ 'accompanying_course_work.%days% days before max_date'|trans({'%days%': days }) }}
+
+ {% endif %}
+
+ {% if evaluation.createdBy is not null %}
+ créé par
+ {{ evaluation.createdBy.username }}
+ {% endif %}
+ {% if evaluation.createdAt is not null %}
+ {{ 'le'|trans }}
+ {{ evaluation.createdAt|format_date('short') }}
+ {% endif %}
+
+
+ {% if evaluation.comment %}
+
+ {{ evaluation.comment }}
+
+ {% endif %}
+
+
+
+
+
+
+
+
+ {% import '@ChillPerson/Macro/updatedBy.html.twig' as macro %}
+ {{ macro.updatedBy(evaluation) }}
+
+
+
+
+{% if display_action is defined and display_action == true %}
+ {# TODO add acl #}
+
+{% endif %}
diff --git a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php
index 98dc14110..c046c8947 100644
--- a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php
+++ b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php
@@ -15,7 +15,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
-use Chill\PersonBundle\Templating\Entity\PersonRender;
+use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@@ -39,7 +39,7 @@ class SimilarPersonMatcher
protected PersonNotDuplicateRepository $personNotDuplicateRepository;
- protected PersonRender $personRender;
+ protected PersonRenderInterface $personRender;
/**
* @var TokenStorageInterface
@@ -51,7 +51,7 @@ class SimilarPersonMatcher
AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage,
PersonNotDuplicateRepository $personNotDuplicateRepository,
- PersonRender $personRender
+ PersonRenderInterface $personRender
) {
$this->em = $em;
$this->authorizationHelper = $authorizationHelper;
diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php
new file mode 100644
index 000000000..7ce259714
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php
@@ -0,0 +1,62 @@
+accessDecisionManager = $accessDecisionManager;
+ }
+
+ protected function supports($attribute, $subject)
+ {
+ return $subject instanceof AccompanyingPeriodWorkEvaluationDocument
+ && self::SEE === $attribute;
+ }
+
+ /**
+ * @param string $attribute
+ * @param AccompanyingPeriodWorkEvaluationDocument $subject
+ *
+ * @return bool|void
+ */
+ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
+ {
+ switch ($attribute) {
+ case self::SEE:
+ return $this->accessDecisionManager->decide(
+ $token,
+ [AccompanyingPeriodWorkEvaluationVoter::SEE],
+ $subject->getAccompanyingPeriodWorkEvaluation()
+ );
+
+ default:
+ throw new UnexpectedValueException("The attribute {$attribute} is not supported");
+ }
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php
new file mode 100644
index 000000000..4680d9fa7
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php
@@ -0,0 +1,124 @@
+workRepository = $workRepository;
+ $this->em = $em;
+ }
+
+ public function denormalize($data, $type, $format = null, array $context = [])
+ {
+ $evaluation = $this->denormalizer->denormalize($data, $type, $format, array_merge(
+ $context,
+ ['skip' => self::class]
+ ));
+
+ $this->handleDocumentCollection($data, $evaluation, $format, $context);
+
+ return $evaluation;
+ }
+
+ public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
+ {
+ return AccompanyingPeriodWorkEvaluation::class === $type
+ && self::class !== ($context['skip'] ?? null)
+ && is_array($data)
+ && array_key_exists('type', $data)
+ && 'accompanying_period_work_evaluation' === $data['type'];
+ }
+
+ private function handleDocumentCollection(array $data, AccompanyingPeriodWorkEvaluation $evaluation, string $format, array $context)
+ {
+ $dataById = [];
+ $dataWithoutId = [];
+
+ foreach ($data['documents'] as $e) {
+ if (array_key_exists('id', $e)) {
+ $dataById[$e['id']] = $e;
+ } else {
+ $dataWithoutId[] = $e;
+ }
+ }
+
+ //partition the separate kept documents and removed one
+ [$kept, $removed] = $evaluation->getDocuments()
+ ->partition(
+ static fn (int $key, AccompanyingPeriodWorkEvaluationDocument $a) => array_key_exists($a->getId(), $dataById)
+ );
+
+ // remove the document from evaluation
+ foreach ($removed as $r) {
+ $evaluation->removeDocument($r);
+ }
+
+ // handle the documents kept
+ foreach ($kept as $k) {
+ $this->denormalizer->denormalize(
+ $dataById[$k->getId()],
+ AccompanyingPeriodWorkEvaluationDocument::class,
+ $format,
+ array_merge(
+ $context,
+ [
+ 'groups' => ['write'],
+ AbstractNormalizer::OBJECT_TO_POPULATE => $k,
+ ]
+ )
+ );
+ }
+ // create new document
+ foreach ($dataWithoutId as $newData) {
+ $document = $this->denormalizer->denormalize(
+ $newData,
+ AccompanyingPeriodWorkEvaluationDocument::class,
+ $format,
+ array_merge(
+ $context,
+ ['groups' => ['accompanying_period_work_evaluation:create']]
+ )
+ );
+ $evaluation->addDocument($document);
+ }
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php
new file mode 100644
index 000000000..cf3033e65
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php
@@ -0,0 +1,71 @@
+entityWorkflowRepository = $entityWorkflowRepository;
+ $this->metadataExtractor = $metadataExtractor;
+ $this->registry = $registry;
+ }
+
+ public function normalize($object, ?string $format = null, array $context = []): array
+ {
+ $initial = $this->normalizer->normalize($object, $format, array_merge($context, [
+ self::SKIP => spl_object_hash($object),
+ ]));
+
+ $initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(
+ AccompanyingPeriodWorkEvaluationDocument::class,
+ $object->getId()
+ );
+
+ $workflows = $this->entityWorkflowRepository->findBy([
+ 'relatedEntityClass' => AccompanyingPeriodWorkEvaluationDocument::class,
+ 'relatedEntityId' => $object->getId(),
+ ]);
+ $initial['workflows'] = $this->normalizer->normalize($workflows, 'json', $context);
+
+ return $initial;
+ }
+
+ public function supportsNormalization($data, ?string $format = null, array $context = [])
+ {
+ return $data instanceof AccompanyingPeriodWorkEvaluationDocument
+ && 'json' === $format
+ && (
+ !array_key_exists(self::SKIP, $context)
+ || spl_object_hash($data) !== $context[self::SKIP]
+ );
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php
index 1e4649dd7..fc9b6003a 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php
@@ -49,6 +49,15 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz
[self::IGNORE_EVALUATION => spl_object_hash($object)]
));
+ // due to bug: https://api-platform.com/docs/core/serialization/#collection-relation
+ // and also: https://github.com/symfony/symfony/issues/36965
+ // we have to rewrite the documents as a collection
+ $initial['documents'] = $this->normalizer->normalize(
+ $object->getDocuments()->getValues(),
+ $format,
+ $context
+ );
+
// then, we add normalization for things which are not into the entity
$initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php
index 25f45d9df..4a110125e 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php
@@ -16,6 +16,7 @@ use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
+use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
@@ -56,6 +57,15 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
[self::IGNORE_WORK => spl_object_hash($object)]
));
+ // due to bug: https://api-platform.com/docs/core/serialization/#collection-relation
+ // and also: https://github.com/symfony/symfony/issues/36965
+ // we have to rewrite the evaluations as a collection
+ $initial['accompanyingPeriodWorkEvaluations'] = $this->normalizer->normalize(
+ $object->getAccompanyingPeriodWorkEvaluations()->getValues(),
+ $format,
+ $context
+ );
+
// then, we add normalization for things which are not into the entity
$initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(
@@ -67,10 +77,15 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
AccompanyingPeriodWorkEvaluation::class
);
+ $initial['workflows_availables_evaluation_documents'] = $this->metadataExtractor->availableWorkflowFor(
+ AccompanyingPeriodWorkEvaluationDocument::class
+ );
+
$workflows = $this->entityWorkflowRepository->findBy([
'relatedEntityClass' => AccompanyingPeriodWork::class,
'relatedEntityId' => $object->getId(),
]);
+
$initial['workflows'] = $this->normalizer->normalize($workflows, 'json', $context);
return $initial;
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php
index 4dd32aa54..c19b35b57 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php
@@ -19,7 +19,7 @@ use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\PersonAltName;
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
-use Chill\PersonBundle\Templating\Entity\PersonRender;
+use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
@@ -37,7 +37,7 @@ class PersonDocGenNormalizer implements
{
use NormalizerAwareTrait;
- private PersonRender $personRender;
+ private PersonRenderInterface $personRender;
private RelationshipRepository $relationshipRepository;
@@ -46,7 +46,7 @@ class PersonDocGenNormalizer implements
private TranslatorInterface $translator;
public function __construct(
- PersonRender $personRender,
+ PersonRenderInterface $personRender,
RelationshipRepository $relationshipRepository,
TranslatorInterface $translator,
TranslatableStringHelper $translatableStringHelper
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php
index e91748de8..451171cb6 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php
@@ -23,21 +23,15 @@ use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
-use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
-use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
use function array_key_exists;
/**
* Serialize a Person entity.
*/
-class PersonJsonNormalizer implements
- DenormalizerAwareInterface,
- DenormalizerInterface,
- NormalizerAwareInterface,
- NormalizerInterface
+class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwareInterface, PersonJsonNormalizerInterface
{
use DenormalizerAwareTrait;
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizerInterface.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizerInterface.php
new file mode 100644
index 000000000..fd41752a8
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizerInterface.php
@@ -0,0 +1,24 @@
+ $options['customArea'] ?? [],
'addDeath' => $options['addDeath'] ?? true,
'addAgeBadge' => $options['addAgeBadge'] ?? false,
+ 'suffixText' => $options['suffixText'] ?? [],
];
return
diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRenderInterface.php b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRenderInterface.php
new file mode 100644
index 000000000..631402851
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRenderInterface.php
@@ -0,0 +1,21 @@
+render = $render;
}
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php
index 73c29b1b3..f9f88debe 100644
--- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php
@@ -13,7 +13,7 @@ namespace Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod;
use Chill\MainBundle\Util\DateRangeCovering;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
-use Chill\PersonBundle\Templating\Entity\PersonRender;
+use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraint;
@@ -26,11 +26,11 @@ class ParticipationOverlapValidator extends ConstraintValidator
{
private const MAX_PARTICIPATION = 1;
- private PersonRender $personRender;
+ private PersonRenderInterface $personRender;
private ThirdPartyRender $thirdpartyRender;
- public function __construct(PersonRender $personRender, ThirdPartyRender $thirdPartyRender)
+ public function __construct(PersonRenderInterface $personRender, ThirdPartyRender $thirdPartyRender)
{
$this->personRender = $personRender;
$this->thirdpartyRender = $thirdPartyRender;
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php
index 3b84137fb..daf4d67f7 100644
--- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php
@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
-use Chill\PersonBundle\Templating\Entity\PersonRender;
+use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
@@ -24,11 +24,11 @@ use function in_array;
class ResourceDuplicateCheckValidator extends ConstraintValidator
{
- private PersonRender $personRender;
+ private PersonRenderInterface $personRender;
private ThirdPartyRender $thirdpartyRender;
- public function __construct(PersonRender $personRender, ThirdPartyRender $thirdPartyRender)
+ public function __construct(PersonRenderInterface $personRender, ThirdPartyRender $thirdPartyRender)
{
$this->personRender = $personRender;
$this->thirdpartyRender = $thirdPartyRender;
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php
index c357cb138..eba6fd87e 100644
--- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php
@@ -13,7 +13,7 @@ namespace Chill\PersonBundle\Validator\Constraints\Household;
use Chill\MainBundle\Util\DateRangeCovering;
use Chill\PersonBundle\Entity\Person;
-use Chill\PersonBundle\Templating\Entity\PersonRender;
+use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
@@ -26,9 +26,9 @@ use function count;
*/
class HouseholdMembershipSequentialValidator extends ConstraintValidator
{
- private PersonRender $render;
+ private PersonRenderInterface $render;
- public function __construct(PersonRender $render)
+ public function __construct(PersonRenderInterface $render)
{
$this->render = $render;
}
diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php
new file mode 100644
index 000000000..eac460ee5
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php
@@ -0,0 +1,96 @@
+repository = $repository;
+ $this->translatableStringHelper = $translatableStringHelper;
+ $this->translator = $translator;
+ }
+
+ public function getEntityData(EntityWorkflow $entityWorkflow, array $options = []): array
+ {
+ $doc = $this->getRelatedEntity($entityWorkflow);
+
+ return [
+ 'persons' => $doc->getAccompanyingPeriodWorkEvaluation()
+ ->getAccompanyingPeriodWork()->getPersons(),
+ ];
+ }
+
+ public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
+ {
+ $doc = $this->getRelatedEntity($entityWorkflow);
+
+ return $this->translator->trans(
+ 'workflow.Doc for evaluation (n°%eval%)',
+ ['%eval%' => $entityWorkflow->getRelatedEntityId()]
+ ) . ' - ' . $this->translatableStringHelper->localize($doc->getAccompanyingPeriodWorkEvaluation()
+ ->getEvaluation()->getTitle());
+ }
+
+ public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluationDocument
+ {
+ return $this->repository->find($entityWorkflow->getRelatedEntityId());
+ }
+
+ public function getRoleShow(EntityWorkflow $entityWorkflow): ?string
+ {
+ return AccompanyingPeriodWorkEvaluationDocumentVoter::SEE;
+ }
+
+ public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string
+ {
+ return '@ChillPerson/Workflow/_evaluation_document.html.twig';
+ }
+
+ public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array
+ {
+ $doc = $this->getRelatedEntity($entityWorkflow);
+
+ return [
+ 'entity_workflow' => $entityWorkflow,
+ 'evaluation' => $doc->getAccompanyingPeriodWorkEvaluation(),
+ 'doc' => $doc,
+ ];
+ }
+
+ public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool
+ {
+ return $entityWorkflow->getRelatedEntityClass() === AccompanyingPeriodWorkEvaluationDocument::class;
+ }
+
+ public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool
+ {
+ return false;
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php
index 1be9f87bf..5af305ac5 100644
--- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php
+++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Workflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository;
@@ -22,11 +23,17 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH
{
private AccompanyingPeriodWorkEvaluationRepository $repository;
+ private TranslatableStringHelperInterface $translatableStringHelper;
+
private TranslatorInterface $translator;
- public function __construct(AccompanyingPeriodWorkEvaluationRepository $repository, TranslatorInterface $translator)
- {
+ public function __construct(
+ AccompanyingPeriodWorkEvaluationRepository $repository,
+ TranslatableStringHelperInterface $translatableStringHelper,
+ TranslatorInterface $translator
+ ) {
$this->repository = $repository;
+ $this->translatableStringHelper = $translatableStringHelper;
$this->translator = $translator;
}
@@ -41,7 +48,12 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
{
- return $this->translator->trans('workflow.Evaluation (n°%eval%)', ['%eval%' => $entityWorkflow->getRelatedEntityId()]);
+ $evaluation = $this->getRelatedEntity($entityWorkflow);
+
+ return $this->translator->trans(
+ 'workflow.Evaluation (n°%eval%)',
+ ['%eval%' => $entityWorkflow->getRelatedEntityId()]
+ ) . ' - ' . $this->translatableStringHelper->localize($evaluation->getEvaluation()->getTitle());
}
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluation
@@ -67,16 +79,6 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH
];
}
- public function getTemplateTitle(EntityWorkflow $entityWorkflow, array $options = []): string
- {
- return '@ChillPerson/Workflow/_evaluation.title.html.twig';
- }
-
- public function getTemplateTitleData(EntityWorkflow $entityWorkflow, array $options = []): array
- {
- return $this->getTemplateData($entityWorkflow, $options);
- }
-
public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool
{
return $entityWorkflow->getRelatedEntityClass() === AccompanyingPeriodWorkEvaluation::class;
diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php
index 3b6a1e9aa..1385cb841 100644
--- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php
+++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Workflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
@@ -21,11 +22,17 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
{
private AccompanyingPeriodWorkRepository $repository;
+ private TranslatableStringHelperInterface $translatableStringHelper;
+
private TranslatorInterface $translator;
- public function __construct(AccompanyingPeriodWorkRepository $repository, TranslatorInterface $translator)
- {
+ public function __construct(
+ AccompanyingPeriodWorkRepository $repository,
+ TranslatableStringHelperInterface $translatableStringHelper,
+ TranslatorInterface $translator
+ ) {
$this->repository = $repository;
+ $this->translatableStringHelper = $translatableStringHelper;
$this->translator = $translator;
}
@@ -39,7 +46,11 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
{
- return $this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()]);
+ $work = $this->getRelatedEntity($entityWorkflow);
+
+ return
+ $this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()])
+ . ' - ' . $this->translatableStringHelper->localize($work->getSocialAction()->getTitle());
}
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWork
@@ -65,16 +76,6 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
];
}
- public function getTemplateTitle(EntityWorkflow $entityWorkflow, array $options = []): string
- {
- return '@ChillPerson/Workflow/_accompanying_period_work.title.html.twig';
- }
-
- public function getTemplateTitleData(EntityWorkflow $entityWorkflow, array $options = []): array
- {
- return $this->getTemplateData($entityWorkflow, $options);
- }
-
public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool
{
return $entityWorkflow->getRelatedEntityClass() === AccompanyingPeriodWork::class;
diff --git a/src/Bundle/ChillPersonBundle/config/services/security.yaml b/src/Bundle/ChillPersonBundle/config/services/security.yaml
index ca719b0b6..af81b42e2 100644
--- a/src/Bundle/ChillPersonBundle/config/services/security.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/security.yaml
@@ -34,6 +34,10 @@ services:
autowire: true
autoconfigure: true
+ Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkEvaluationDocumentVoter:
+ autowire: true
+ autoconfigure: true
+
Chill\PersonBundle\Security\Authorization\HouseholdVoter:
autowire: true
autoconfigure: true
diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220224145951.php b/src/Bundle/ChillPersonBundle/migrations/Version20220224145951.php
new file mode 100644
index 000000000..75712f458
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/migrations/Version20220224145951.php
@@ -0,0 +1,38 @@
+addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP title');
+ }
+
+ public function getDescription(): string
+ {
+ return 'Add title to AccompanyingPeriodWorkEvaluationDocument';
+ }
+
+ public function up(Schema $schema): void
+ {
+ $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD title TEXT NOT NULL DEFAULT \'\'');
+ $this->addSql('UPDATE chill_person_accompanying_period_work_evaluation_document SET title=name->>\'fr\'
+ FROM chill_docgen_template cdt WHERE cdt.id = chill_person_accompanying_period_work_evaluation_document.template_id');
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
index c4d163a16..3b1aea377 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
@@ -571,3 +571,6 @@ Linked evaluations: Évaluations associées
# Accompanying period per user
My accompanying periods: Mes parcours
My accompanying periods in draft: Mes parcours brouillons
+
+workflow:
+ Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval%
diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
index 1981d6daf..124f5b7f3 100644
--- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
+++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
@@ -126,6 +126,21 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
],
],
],
+ [
+ 'class' => \Chill\ThirdPartyBundle\Entity\ThirdPartyProfession::class,
+ // 'controller' => \Chill\MainBundle\Controller\ProfessionApiController::class,
+ 'name' => 'profession',
+ 'base_path' => '/api/1.0/thirdparty/professions',
+ 'base_role' => 'ROLE_USER',
+ 'actions' => [
+ '_index' => [
+ 'methods' => [
+ Request::METHOD_GET => true,
+ Request::METHOD_HEAD => true,
+ ],
+ ],
+ ],
+ ],
],
]);
}
diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
index 593d1c14c..25ef1be65 100644
--- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
+++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
@@ -161,13 +161,14 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @var Civility
* @ORM\ManyToOne(targetEntity=Civility::class)
* ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
- * @Groups({"docgen:read", "read", "docgen:read:3party:parent"})
+ * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
*/
private ?Civility $civility = null;
/**
* @ORM\Column(name="comment", type="text", nullable=true)
+ * @Groups({"read", "write"})
*/
private ?string $comment = null;
@@ -200,7 +201,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
- * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
+ * @Groups({"read", "docgen:read", "docgen:read:3party:parent"})
*/
private ?int $id = null;
@@ -235,7 +236,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
*
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
- * @Groups({"read", "docgen:read"})
+ * @Groups({"read", "write", "docgen:read"})
* @Context(normalizationContext={"groups": "docgen:read:3party:parent"}, groups={"docgen:read"})
*/
private ?ThirdParty $parent = null;
@@ -246,7 +247,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @var ThirdPartyProfession
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
- * @Groups({"docgen:read", "docgen:read:3party:parent"})
+ * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
*/
private ?ThirdPartyProfession $profession = null;
@@ -706,7 +707,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @return $this
*/
- public function setCivility(Civility $civility): ThirdParty
+ public function setCivility(?Civility $civility): ThirdParty
{
$this->civility = $civility;
@@ -811,7 +812,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @return $this
*/
- public function setProfession(ThirdPartyProfession $profession): ThirdParty
+ public function setProfession(?ThirdPartyProfession $profession): ThirdParty
{
$this->profession = $profession;
diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php
index 1963b34a7..896888a73 100644
--- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php
+++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php
@@ -18,11 +18,14 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_3party.party_profession")
* @ORM\Entity(repositoryClass=ThirdPartyProfessionRepository::class)
+ * @Serializer\DiscriminatorMap(typeProperty="type", mapping={
+ * "third_party_profession": ThirdPartyProfession::class})
*/
class ThirdPartyProfession
{
/**
* @ORM\Column(type="boolean")
+ * @Serializer\Groups({"read"})
*/
private bool $active = true;
@@ -30,13 +33,13 @@ class ThirdPartyProfession
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
- * @Serializer\Groups({"docgen:read"})
+ * @Serializer\Groups({"docgen:read", "read", "write"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json")
- * @Serializer\Groups({"docgen:read"})
+ * @Serializer\Groups({"docgen:read", "read"})
*/
private array $name = [];
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue
index fb466f929..7f5727050 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue
@@ -34,33 +34,45 @@