mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
Add public workflow view functionality
Introduced the ability to render public views for workflows, including new templates, handlers, and metadata support. Updated entity interfaces and translations to enhance the public sharing of workflow documents.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
{% extends '@ChillMain/Workflow/workflow_view_send_public_layout.html.twig' %}
|
||||
|
||||
{% block css %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_link_tags('mod_document_download_button') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('mod_document_download_button') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{{ 'workflow.public_link.title'|trans }} - {{ title }}{% endblock %}
|
||||
|
||||
{% block public_content %}
|
||||
<h1>{{ 'workflow.public_link.shared_doc'|trans }}</h1>
|
||||
|
||||
{% set previous = send.entityWorkflowStepChained.previous %}
|
||||
{% if previous is not null %}
|
||||
{% if previous.transitionBy is not null %}
|
||||
<p>{{ 'workflow.public_link.doc_shared_by_at_explanation'|trans({'byUser': previous.transitionBy|chill_entity_render_string( { 'at_date': previous.transitionAt } ), 'at': previous.transitionAt }) }}</p>
|
||||
{% else %}
|
||||
<p>{{ 'workflow.public_link.doc_shared_automatically_at_explanation'|trans({'at': previous.transitionAt}) }}</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6 col-md-4">
|
||||
<div class="card"">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{{ title }}</h2>
|
||||
<h3>{{ 'workflow.public_link.main_document'|trans }}</h3>
|
||||
|
||||
<ul class="record_actions slim small">
|
||||
<li>
|
||||
{{ storedObject|chill_document_download_only_button(storedObject.title(), false) }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@@ -16,20 +16,24 @@ use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSend;
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowWithPublicViewInterface;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowWithStoredObjectHandlerInterface;
|
||||
use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @implements EntityWorkflowWithStoredObjectHandlerInterface<AccompanyingCourseDocument>
|
||||
*/
|
||||
readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowWithStoredObjectHandlerInterface
|
||||
final readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowWithStoredObjectHandlerInterface, EntityWorkflowWithPublicViewInterface
|
||||
{
|
||||
public function __construct(
|
||||
private TranslatorInterface $translator,
|
||||
private EntityWorkflowRepository $workflowRepository,
|
||||
private AccompanyingCourseDocumentRepository $repository,
|
||||
private WorkflowWithPublicViewDocumentHelper $publicViewDocumentHelper,
|
||||
) {}
|
||||
|
||||
public function getDeletionRoles(): array
|
||||
@@ -136,4 +140,9 @@ readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkfl
|
||||
|
||||
return $this->workflowRepository->findByRelatedEntity(AccompanyingCourseDocument::class, $object->getId());
|
||||
}
|
||||
|
||||
public function renderPublicView(EntityWorkflowSend $entityWorkflowSend, EntityWorkflowViewMetadataDTO $metadata): string
|
||||
{
|
||||
return $this->publicViewDocumentHelper->render($entityWorkflowSend, $metadata, $this);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSend;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowWithStoredObjectHandlerInterface;
|
||||
use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO;
|
||||
use Twig\Environment;
|
||||
|
||||
class WorkflowWithPublicViewDocumentHelper
|
||||
{
|
||||
public function __construct(private readonly Environment $twig) {}
|
||||
|
||||
public function render(EntityWorkflowSend $send, EntityWorkflowViewMetadataDTO $metadata, EntityWorkflowHandlerInterface&EntityWorkflowWithStoredObjectHandlerInterface $handler): string
|
||||
{
|
||||
$entityWorkflow = $send->getEntityWorkflowStep()->getEntityWorkflow();
|
||||
$storedObject = $handler->getAssociatedStoredObject($entityWorkflow);
|
||||
|
||||
if (null === $storedObject) {
|
||||
return 'document removed';
|
||||
}
|
||||
|
||||
$title = $handler->getEntityTitle($entityWorkflow);
|
||||
|
||||
return $this->twig->render(
|
||||
'@ChillDocStore/Workflow/public_view_with_document_render.html.twig',
|
||||
[
|
||||
'title' => $title,
|
||||
'storedObject' => $storedObject,
|
||||
'send' => $send,
|
||||
'metadata' => $metadata,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,3 +1,11 @@
|
||||
acc_course_document:
|
||||
duplicated_at: >-
|
||||
Dupliqué le {at, date, long} à {at, time, short}
|
||||
|
||||
workflow:
|
||||
public_link:
|
||||
doc_shared_by_at_explanation: >-
|
||||
Le document a été partagé avec vous par {byUser}, le {at, date, long} à {at, time, short}.
|
||||
doc_shared_automatically_at_explanation: >-
|
||||
Le document a été partagé avec vous le {at, date, long} à {at, time, short}
|
||||
|
||||
|
@@ -80,6 +80,10 @@ online_edit_document: Éditer en ligne
|
||||
|
||||
workflow:
|
||||
Document deleted: Document supprimé
|
||||
public_link:
|
||||
shared_doc: Document partagé
|
||||
title: Document partagé
|
||||
main_document: Document principal
|
||||
|
||||
# ROLES
|
||||
accompanyingCourseDocument: Documents dans les parcours d'accompagnement
|
||||
|
Reference in New Issue
Block a user