mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 13:06:13 +00:00
FEATURE [genericDoc][activity] finalize implementation
This commit is contained in:
parent
eea5cedc5f
commit
ba55fa349b
@ -98,15 +98,4 @@ class ActivityRepository extends ServiceEntityRepository
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -2,25 +2,30 @@
|
||||
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
|
||||
{% 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-col" style="width: unset">
|
||||
{% if document.storedObject.isPending %}
|
||||
<div class="badge text-bg-info" data-docgen-is-pending="{{ document.storedObject.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div>
|
||||
{% elseif document.storedObject.isFailure %}
|
||||
{% if document.isPending %}
|
||||
<div class="badge text-bg-info" data-docgen-is-pending="{{ document.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div>
|
||||
{% elseif document.isFailure %}
|
||||
<div class="badge text-bg-warning">{{ 'docgen.Doc generation failed'|trans }}</div>
|
||||
{% endif %}
|
||||
<div class="denomination h2">
|
||||
{{ document.storedObject.title }}
|
||||
{{ document.title }}
|
||||
</div>
|
||||
<div>
|
||||
{{ 'chill_calendar.Document'|trans }}
|
||||
</div>
|
||||
{% if document.storedObject.hasTemplate %}
|
||||
{% if document.hasTemplate %}
|
||||
<div>
|
||||
<p>{{ document.storedObject.template.name|localize_translatable_string }}</p>
|
||||
<p>{{ document.template.name|localize_translatable_string }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
@ -28,7 +33,7 @@
|
||||
<div class="item-col">
|
||||
<div class="container">
|
||||
<div class="dates row text-end">
|
||||
<span>{{ document.storedObject.createdAt|format_date('short') }}</span>
|
||||
<span>{{ document.createdAt|format_date('short') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -36,15 +41,15 @@
|
||||
|
||||
<div class="item-row separator">
|
||||
<div class="item-col">
|
||||
<p class="date-label">
|
||||
{% if c.endDate.diff(c.startDate).days >= 1 %}
|
||||
{{ c.startDate|format_datetime('short', 'short') }}
|
||||
- {{ c.endDate|format_datetime('short', 'short') }}
|
||||
{% else %}
|
||||
{{ c.startDate|format_datetime('short', 'short') }}
|
||||
- {{ c.endDate|format_datetime('none', 'short') }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<h2 class="badge-title">
|
||||
<span class="title_label"></span>
|
||||
<span class="title_action">
|
||||
{{ activity.type.name | localize_translatable_string }}
|
||||
{% if activity.emergency %}
|
||||
<span class="badge bg-danger rounded-pill fs-6 float-end">{{ 'Emergency'|trans|upper }}</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -53,17 +58,19 @@
|
||||
{{ mmm.createdBy(document) }}
|
||||
</div>
|
||||
<ul class="item-col record_actions flex-shrink-1">
|
||||
<li>
|
||||
{{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }}
|
||||
</li>
|
||||
{% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %}
|
||||
{% if is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %}
|
||||
<li>
|
||||
{{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }}
|
||||
{{ document|chill_document_button_group(document.title, is_granted('CHILL_ACTIVITY_UPDATE', activity), {small: false}) }}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %}
|
||||
{% if is_granted('CHILL_ACTIVITY_SEE', activity)%}
|
||||
<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>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
@ -27,32 +27,19 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo
|
||||
{
|
||||
public const KEY = 'accompanying_period_activity_document';
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security, EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->em = $entityManager;
|
||||
$this->security = $security;
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private 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
|
||||
{
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
|
||||
$query = new FetchQuery(
|
||||
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'),
|
||||
$storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName().' AS doc_obj'
|
||||
);
|
||||
|
@ -36,13 +36,13 @@ final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRe
|
||||
|
||||
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
|
||||
{
|
||||
return [
|
||||
'activity' => $this->activityRepository->findOneByDocument($genericDocDTO->identifiers['id']),
|
||||
'activity' => $this->activityRepository->find($genericDocDTO->identifiers['activity_id']),
|
||||
'document' => $this->objectRepository->find($genericDocDTO->identifiers['id'])
|
||||
];
|
||||
}
|
||||
|
@ -38,3 +38,6 @@ services:
|
||||
|
||||
Chill\ActivityBundle\Service\EntityInfo\:
|
||||
resource: '../Service/EntityInfo/'
|
||||
|
||||
Chill\ActivityBundle\Service\GenericDoc\:
|
||||
resource: '../Service/GenericDoc/'
|
||||
|
Loading…
x
Reference in New Issue
Block a user