FEATURE [genericDoc][activity] finalize implementation

This commit is contained in:
Julie Lenaerts 2023-05-31 16:53:38 +02:00
parent eea5cedc5f
commit ba55fa349b
5 changed files with 45 additions and 59 deletions

View File

@ -98,15 +98,4 @@ class ActivityRepository extends ServiceEntityRepository
return $qb->getQuery()->getResult(); return $qb->getQuery()->getResult();
} }
public function findOneByDocument(int $documentId): Activity
{
$qb = $this->createQueryBuilder('a');
$qb->select('a');
$qb->innerJoin('a.documents', 'd', Expr\Join::WITH, 'd.storedobject_id = :documentId');
$qb->setParameter('documentId', $documentId);
return $qb->getQuery()->getResult();
}
} }

View File

@ -2,25 +2,30 @@
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %} {% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %}
{% set a = document.calendar %} {% set person_id = null %}
{% if activity.person %}
{% set person_id = activity.person.id %}
{% endif %}
<div class="item-bloc"> {% set accompanying_course_id = null %}
{% if activity.accompanyingPeriod %}
{% set accompanying_course_id = activity.accompanyingPeriod.id %}
{% endif %}
<div class="item-bloc activity-item{% if itemBlocClass is defined %} {{ itemBlocClass }}{% endif %}">
<div class="item-row"> <div class="item-row">
<div class="item-col" style="width: unset"> <div class="item-col" style="width: unset">
{% if document.storedObject.isPending %} {% if document.isPending %}
<div class="badge text-bg-info" data-docgen-is-pending="{{ document.storedObject.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div> <div class="badge text-bg-info" data-docgen-is-pending="{{ document.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div>
{% elseif document.storedObject.isFailure %} {% elseif document.isFailure %}
<div class="badge text-bg-warning">{{ 'docgen.Doc generation failed'|trans }}</div> <div class="badge text-bg-warning">{{ 'docgen.Doc generation failed'|trans }}</div>
{% endif %} {% endif %}
<div class="denomination h2"> <div class="denomination h2">
{{ document.storedObject.title }} {{ document.title }}
</div> </div>
{% if document.hasTemplate %}
<div> <div>
{{ 'chill_calendar.Document'|trans }} <p>{{ document.template.name|localize_translatable_string }}</p>
</div>
{% if document.storedObject.hasTemplate %}
<div>
<p>{{ document.storedObject.template.name|localize_translatable_string }}</p>
</div> </div>
{% endif %} {% endif %}
</div> </div>
@ -28,7 +33,7 @@
<div class="item-col"> <div class="item-col">
<div class="container"> <div class="container">
<div class="dates row text-end"> <div class="dates row text-end">
<span>{{ document.storedObject.createdAt|format_date('short') }}</span> <span>{{ document.createdAt|format_date('short') }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -36,15 +41,15 @@
<div class="item-row separator"> <div class="item-row separator">
<div class="item-col"> <div class="item-col">
<p class="date-label"> <h2 class="badge-title">
{% if c.endDate.diff(c.startDate).days >= 1 %} <span class="title_label"></span>
{{ c.startDate|format_datetime('short', 'short') }} <span class="title_action">
- {{ c.endDate|format_datetime('short', 'short') }} {{ activity.type.name | localize_translatable_string }}
{% else %} {% if activity.emergency %}
{{ c.startDate|format_datetime('short', 'short') }} <span class="badge bg-danger rounded-pill fs-6 float-end">{{ 'Emergency'|trans|upper }}</span>
- {{ c.endDate|format_datetime('none', 'short') }}
{% endif %} {% endif %}
</p> </span>
</h2>
</div> </div>
</div> </div>
@ -53,17 +58,19 @@
{{ mmm.createdBy(document) }} {{ mmm.createdBy(document) }}
</div> </div>
<ul class="item-col record_actions flex-shrink-1"> <ul class="item-col record_actions flex-shrink-1">
{% if is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %}
<li> <li>
{{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} {{ document|chill_document_button_group(document.title, is_granted('CHILL_ACTIVITY_UPDATE', activity), {small: false}) }}
</li>
{% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %}
<li>
{{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }}
</li> </li>
{% endif %} {% endif %}
{% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %} {% if is_granted('CHILL_ACTIVITY_SEE', activity)%}
<li> <li>
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_edit', {'id': c.id, 'docId': document.id}) }}" class="btn btn-edit"></a> <a href="{{ chill_path_add_return_path('chill_activity_activity_show', {'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="btn btn-show"></a>
</li>
{% endif %}
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
<li>
<a href="{{ chill_path_add_return_path('chill_activity_activity_edit', {'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}" class="btn btn-edit"></a>
</li> </li>
{% endif %} {% endif %}
</ul> </ul>

View File

@ -27,32 +27,19 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo
{ {
public const KEY = 'accompanying_period_activity_document'; public const KEY = 'accompanying_period_activity_document';
private EntityManagerInterface $em; public function __construct(
private EntityManagerInterface $em,
private Security $security; private Security $security
){
public function __construct(Security $security, EntityManagerInterface $entityManager)
{
$this->em = $entityManager;
$this->security = $security;
} }
/**
* @param AccompanyingPeriod $accompanyingPeriod
* @param DateTimeImmutable|null $startDate
* @param DateTimeImmutable|null $endDate
* @param string|null $content
* @param string|null $origin
* @return FetchQueryInterface
* @throws MappingException
*/
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
{ {
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
$query = new FetchQuery( $query = new FetchQuery(
self::KEY, self::KEY,
"jsonb_build_object('id', doc_obj.id)", "jsonb_build_object('id', doc_obj.id, 'activity_id', activity.id)",
'doc_obj.'.$storedObjectMetadata->getColumnName('createdAt'), 'doc_obj.'.$storedObjectMetadata->getColumnName('createdAt'),
$storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName().' AS doc_obj' $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName().' AS doc_obj'
); );

View File

@ -36,13 +36,13 @@ final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRe
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
{ {
return '@ChillCalendar/GenericDoc/activity_document.html.twig'; return '@ChillActivity/GenericDoc/activity_document.html.twig';
} }
public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array
{ {
return [ return [
'activity' => $this->activityRepository->findOneByDocument($genericDocDTO->identifiers['id']), 'activity' => $this->activityRepository->find($genericDocDTO->identifiers['activity_id']),
'document' => $this->objectRepository->find($genericDocDTO->identifiers['id']) 'document' => $this->objectRepository->find($genericDocDTO->identifiers['id'])
]; ];
} }

View File

@ -38,3 +38,6 @@ services:
Chill\ActivityBundle\Service\EntityInfo\: Chill\ActivityBundle\Service\EntityInfo\:
resource: '../Service/EntityInfo/' resource: '../Service/EntityInfo/'
Chill\ActivityBundle\Service\GenericDoc\:
resource: '../Service/GenericDoc/'