mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 14:36:13 +00:00
add accompanying period opening/closing to global timeline
This commit is contained in:
parent
73653744d7
commit
ea477a9842
@ -46,6 +46,11 @@ Back to the list: Retour à la liste
|
|||||||
#interval
|
#interval
|
||||||
Years: Années
|
Years: Années
|
||||||
|
|
||||||
|
# misc date
|
||||||
|
Since %date%: Depuis le %date%
|
||||||
|
since %date%: depuis le %date%
|
||||||
|
Until %date%: Jusqu'au %date%
|
||||||
|
until %date%: jusqu'au %date%
|
||||||
#elements used in software
|
#elements used in software
|
||||||
centers: centres
|
centers: centres
|
||||||
Centers: Centres
|
Centers: Centres
|
||||||
@ -78,6 +83,9 @@ Results %start%-%end% of %total%: Résultats %start%-%end% sur %total%
|
|||||||
See all results: Voir tous les résultats
|
See all results: Voir tous les résultats
|
||||||
Advanced search: Recherche avancée
|
Advanced search: Recherche avancée
|
||||||
|
|
||||||
|
# timeline
|
||||||
|
Global timeline: Historique global
|
||||||
|
|
||||||
#admin
|
#admin
|
||||||
Create: Créer
|
Create: Créer
|
||||||
show: voir
|
show: voir
|
||||||
|
@ -302,13 +302,9 @@ class AccompanyingPeriod
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRemark(string $remark): self
|
public function setRemark(string $remark = null): self
|
||||||
{
|
{
|
||||||
if ($remark === null) {
|
$this->remark = (string) $remark;
|
||||||
$remark = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->remark = $remark;
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
<span class="chill-entity chill-entity__person">
|
<span class="chill-entity chill-entity__person">
|
||||||
{% if addLink and is_granted('CHILL_PERSON_SEE', person) %}
|
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
|
||||||
{% set showLink = true %}
|
{%- set showLink = true -%}<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">{%- endif -%}
|
||||||
<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">
|
<span class="chill-entity__person__first-name">{{ person.firstName }}</span>
|
||||||
{% endif %}
|
|
||||||
<span class="chill-entity__person__first-name"> {{ person.firstName }}</span>
|
|
||||||
<span class="chill-entity__person__last-name">{{ person.lastName }}</span>
|
<span class="chill-entity__person__last-name">{{ person.lastName }}</span>
|
||||||
{% if addAltNames %}
|
{%- if addAltNames -%}
|
||||||
{% for n in person.altNames %}
|
{%- for n in person.altNames -%}
|
||||||
{% if loop.first %}({% else %} {% endif %}
|
{%- if loop.first -%}({% else %} {%- endif -%}
|
||||||
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}">
|
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}">
|
||||||
{{ n.label }}
|
{{ n.label }}
|
||||||
</span>
|
</span>
|
||||||
{% if loop.last %}){% endif %}
|
{%- if loop.last %}) {% endif -%}
|
||||||
{% endfor %}
|
{%- endfor -%}
|
||||||
{% endif %}
|
{%- endif -%}
|
||||||
{% if showLink is defined %}</a>{% endif %}
|
{%- if showLink is defined -%}</a>{%- endif -%}</span>
|
||||||
</span>
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<h3 class="single-line">
|
<div>
|
||||||
|
<h3 class="single-line">
|
||||||
{{ period.closingDate|format_date('long') }}
|
{{ period.closingDate|format_date('long') }}
|
||||||
<span class="person"> /
|
<span class="person"> / </span>
|
||||||
<a href="{{ path('chill_person_accompanying_period_list', { 'person_id': person.id } ) }}">
|
{{ 'An accompanying period ends'|trans }}
|
||||||
{{ 'Closing the accompanying period' | trans }}
|
</h3>
|
||||||
</a>
|
|
||||||
<span>
|
<div class="statement">
|
||||||
<span class="chill-red">
|
<dl class="chill_view_data">
|
||||||
<i class="fa fa-folder"></i>
|
<dd>{{ 'Participants'|trans }} :</dd>
|
||||||
</span>
|
<dt>
|
||||||
</h3>
|
<ul>
|
||||||
|
{% for p in period.participations %}
|
||||||
|
<li>{{ p.person|chill_entity_render_box({ 'addLink': true }) }}: {{ 'since %date%'|trans({'%date%': p.startDate|format_date("long") } ) }}, {{ 'until %date%'|trans({'%date%': (p.endDate is not null ? p.endDate : period.closingDate)|format_date("long") }) }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</dt>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<h3 class="single-line">
|
<div>
|
||||||
|
<h3 class="single-line">
|
||||||
{{ period.openingDate|format_date('long') }}
|
{{ period.openingDate|format_date('long') }}
|
||||||
<span class="person"> /
|
<span class="person"> / </span>
|
||||||
<a href="{{ path('chill_person_accompanying_period_list', { 'person_id': person.id } ) }}">
|
{{ 'An accompanying period starts'|trans }}
|
||||||
{{ 'Opening the accompanying period' | trans }}
|
</h3>
|
||||||
</a>
|
|
||||||
</span>
|
<div class="statement">
|
||||||
<span class="chill-green">
|
<dl class="chill_view_data">
|
||||||
<i class="fa fa-folder-open"></i>
|
<dd>{{ 'Participants'|trans }} :</dd>
|
||||||
</span>
|
<dt>
|
||||||
</h3>
|
<ul>
|
||||||
|
{% for p in period.participations %}
|
||||||
|
<li>{{ 'Since %date%'|trans( {'%date%': p.startDate|format_date("long") } ) }} : {{ p.person|chill_entity_render_box({ 'addLink': true }) }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</dt>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -21,6 +21,13 @@ namespace Chill\PersonBundle\Timeline;
|
|||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||||
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide method to build timeline for accompanying periods
|
* Provide method to build timeline for accompanying periods
|
||||||
@ -28,19 +35,22 @@ use Doctrine\ORM\EntityManager;
|
|||||||
* This class is resued by TimelineAccompanyingPeriodOpening (for opening)
|
* This class is resued by TimelineAccompanyingPeriodOpening (for opening)
|
||||||
* and TimelineAccompanyingPeriodClosing (for closing)
|
* and TimelineAccompanyingPeriodClosing (for closing)
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*/
|
*/
|
||||||
abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInterface
|
abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInterface
|
||||||
{
|
{
|
||||||
/**
|
protected EntityManager $em;
|
||||||
*
|
|
||||||
* @var EntityManager
|
private Security $security;
|
||||||
*/
|
|
||||||
protected $em;
|
private AuthorizationHelper $authorizationHelper;
|
||||||
|
|
||||||
|
private const SUPPORTED_CONTEXTS = [ 'person', 'center' ];
|
||||||
|
|
||||||
public function __construct(EntityManager $em)
|
public function __construct(EntityManager $em, Security $security, AuthorizationHelper $authorizationHelper)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
|
$this->security = $security;
|
||||||
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,25 +82,74 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt
|
|||||||
*/
|
*/
|
||||||
protected function basicFetchQuery($context, array $args)
|
protected function basicFetchQuery($context, array $args)
|
||||||
{
|
{
|
||||||
if ($context !== 'person') {
|
if (FALSE === \in_array($context, self::SUPPORTED_CONTEXTS)) {
|
||||||
throw new \LogicException('TimelineAccompanyingPeriod is not able '
|
throw new \LogicException('TimelineAccompanyingPeriod is not able '
|
||||||
. 'to render context '.$context);
|
. 'to render context '.$context);
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata = $this->em
|
$metadata = $this->em
|
||||||
->getClassMetadata('ChillPersonBundle:AccompanyingPeriod')
|
->getClassMetadata(AccompanyingPeriodParticipation::class)
|
||||||
;
|
;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'id' => $metadata->getColumnName('id'),
|
'id' => "{$metadata->getTableName()}.{$metadata->getColumnName('id')}",
|
||||||
'FROM' => $metadata->getTableName(),
|
'FROM' => $this->buildFromClause($context),
|
||||||
'WHERE' => sprintf('%s = %d',
|
'WHERE' => $this->buildWhereClause($context, $args)
|
||||||
$metadata
|
|
||||||
->getAssociationMapping('person')['joinColumns'][0]['name'],
|
|
||||||
$args['person']->getId())
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildFromClause($context)
|
||||||
|
{
|
||||||
|
$period = $this->em->getClassMetadata(AccompanyingPeriod::class);
|
||||||
|
$participation = $this->em->getClassMetadata(AccompanyingPeriodParticipation::class);
|
||||||
|
$person = $this->em->getClassMetadata(Person::class);
|
||||||
|
$join = $participation->getAssociationMapping('accompanyingPeriod')['joinColumns'][0];
|
||||||
|
$joinPerson = $participation->getAssociationMapping('person')['joinColumns'][0];
|
||||||
|
|
||||||
|
if ($context === 'person') {
|
||||||
|
return "{$period->getTableName()} ".
|
||||||
|
"JOIN {$participation->getTableName()} ".
|
||||||
|
"ON {$participation->getTableName()}.{$join['name']} = ".
|
||||||
|
"{$period->getTableName()}.{$join['referencedColumnName']}";
|
||||||
|
} else {
|
||||||
|
return "{$period->getTableName()} ".
|
||||||
|
"JOIN {$participation->getTableName()} ".
|
||||||
|
"ON {$participation->getTableName()}.{$join['name']} = ".
|
||||||
|
"{$period->getTableName()}.{$join['referencedColumnName']} ".
|
||||||
|
"JOIN {$person->getTableName()} ".
|
||||||
|
"ON {$participation->getTableName()}.{$joinPerson['name']} = ".
|
||||||
|
"{$person->getTableName()}.{$joinPerson['referencedColumnName']}"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildWhereClause($context, array $args): array
|
||||||
|
{
|
||||||
|
$participation = $this->em->getClassMetadata(AccompanyingPeriodParticipation::class);
|
||||||
|
$join = $participation->getAssociationMapping('person')['joinColumns'][0];
|
||||||
|
$person = $this->em->getClassMetadata(Person::class);
|
||||||
|
$joinCenter = $person->getAssociationMapping('center')['joinColumns'][0];
|
||||||
|
$allowedCenters = $this->authorizationHelper->filterReachableCenters($this->security->getUser(), $args['centers'], PersonVoter::SEE);
|
||||||
|
|
||||||
|
if ($context === 'center') {
|
||||||
|
$params = [];
|
||||||
|
$questionMarks = [];
|
||||||
|
$query = "{$person->getTableName()}.{$joinCenter['name']} IN (";
|
||||||
|
foreach ($allowedCenters as $c) {
|
||||||
|
$questionMarks[] = '?';
|
||||||
|
$params[] = $c->getId();
|
||||||
|
}
|
||||||
|
$query .= \implode(", ", $questionMarks).")";
|
||||||
|
|
||||||
|
return [$query, $params];
|
||||||
|
} elseif ($context === 'person') {
|
||||||
|
return [ "{$participation->getTableName()}.{$join['name']} = ?", [ $args['person']->getId() ]];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \LogicException("this context is not supported: $context");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the expected response for TimelineProviderInterface::getEntityTemplate
|
* return the expected response for TimelineProviderInterface::getEntityTemplate
|
||||||
*
|
*
|
||||||
@ -104,7 +163,7 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'template' => $template,
|
'template' => $template,
|
||||||
'template_data' => ['person' => $args['person'], 'period' => $entity]
|
'template_data' => ['period' => $entity, 'context' => $context]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ namespace Chill\PersonBundle\Timeline;
|
|||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide information for opening periods to timeline
|
* Provide information for opening periods to timeline
|
||||||
@ -46,22 +47,27 @@ class TimelineAccompanyingPeriodClosing extends AbstractTimelineAccompanyingPeri
|
|||||||
public function fetchQuery($context, array $args)
|
public function fetchQuery($context, array $args)
|
||||||
{
|
{
|
||||||
$metadata = $this->em
|
$metadata = $this->em
|
||||||
->getClassMetadata('ChillPersonBundle:AccompanyingPeriod');
|
->getClassMetadata(AccompanyingPeriod::class);
|
||||||
|
|
||||||
$data = $this->basicFetchQuery($context, $args);
|
$data = $this->basicFetchQuery($context, $args);
|
||||||
|
|
||||||
$data['type'] = 'accompanying_period_closing';
|
$data['type'] = 'accompanying_period_closing';
|
||||||
$data['date'] = $metadata->getColumnName('closingDate');
|
$data['date'] = $metadata->getColumnName('closingDate');
|
||||||
$data['WHERE'] = sprintf('%s = %d AND %s IS NOT NULL',
|
$data['WHERE'] = $this->buildWhereClause($context, $args);
|
||||||
$metadata
|
|
||||||
->getAssociationMapping('person')['joinColumns'][0]['name'],
|
|
||||||
$args['person']->getId(),
|
|
||||||
$metadata->getColumnName('closingDate'))
|
|
||||||
;
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function buildWhereClause($context, array $args): array
|
||||||
|
{
|
||||||
|
list($query, $params) = parent::buildWhereClause($context, $args);
|
||||||
|
$period = $this->em->getClassMetadata(AccompanyingPeriod::class);
|
||||||
|
|
||||||
|
$query .= " AND {$period->getColumnName('closingDate')} IS NOT NULL ";
|
||||||
|
|
||||||
|
return [ $query, $params ];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -21,11 +21,10 @@ namespace Chill\PersonBundle\Timeline;
|
|||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide information for opening periods to timeline
|
* Provide information for opening periods to timeline
|
||||||
*
|
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*/
|
*/
|
||||||
class TimelineAccompanyingPeriodOpening extends AbstractTimelineAccompanyingPeriod
|
class TimelineAccompanyingPeriodOpening extends AbstractTimelineAccompanyingPeriod
|
||||||
{
|
{
|
||||||
@ -46,7 +45,7 @@ class TimelineAccompanyingPeriodOpening extends AbstractTimelineAccompanyingPeri
|
|||||||
public function fetchQuery($context, array $args)
|
public function fetchQuery($context, array $args)
|
||||||
{
|
{
|
||||||
$metadata = $this->em
|
$metadata = $this->em
|
||||||
->getClassMetadata('ChillPersonBundle:AccompanyingPeriod');
|
->getClassMetadata(AccompanyingPeriod::class);
|
||||||
|
|
||||||
$data = $this->basicFetchQuery($context, $args);
|
$data = $this->basicFetchQuery($context, $args);
|
||||||
|
|
||||||
|
@ -16,17 +16,23 @@ services:
|
|||||||
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening
|
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening
|
||||||
arguments:
|
arguments:
|
||||||
- "@doctrine.orm.entity_manager"
|
- "@doctrine.orm.entity_manager"
|
||||||
|
- '@Symfony\Component\Security\Core\Security'
|
||||||
|
- '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||||
public: true
|
public: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.timeline, context: 'person' }
|
- { name: chill.timeline, context: 'person' }
|
||||||
|
- { name: chill.timeline, context: 'center' }
|
||||||
|
|
||||||
chill.person.timeline.accompanying_period_closing:
|
chill.person.timeline.accompanying_period_closing:
|
||||||
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodClosing
|
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodClosing
|
||||||
arguments:
|
arguments:
|
||||||
- "@doctrine.orm.entity_manager"
|
- "@doctrine.orm.entity_manager"
|
||||||
|
- '@Symfony\Component\Security\Core\Security'
|
||||||
|
- '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||||
public: true
|
public: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.timeline, context: 'person' }
|
- { name: chill.timeline, context: 'person' }
|
||||||
|
- { name: chill.timeline, context: 'center' }
|
||||||
|
|
||||||
chill.person.security.authorization.person:
|
chill.person.security.authorization.person:
|
||||||
class: Chill\PersonBundle\Security\Authorization\PersonVoter
|
class: Chill\PersonBundle\Security\Authorization\PersonVoter
|
||||||
|
@ -150,6 +150,8 @@ Update accompanying period: Mettre à jour une période d'accompagnement
|
|||||||
'Closing motive': 'Motif de clôture'
|
'Closing motive': 'Motif de clôture'
|
||||||
'Person details': 'Détails de la personne'
|
'Person details': 'Détails de la personne'
|
||||||
'Update details for %name%': 'Modifier détails de %name%'
|
'Update details for %name%': 'Modifier détails de %name%'
|
||||||
|
An accompanying period ends: Une periode d'accompagnement se clôture
|
||||||
|
An accompanying period starts: Une période d'accompagnement est ouverte
|
||||||
Any accompanying periods are open: Aucune période d'accompagnement ouverte
|
Any accompanying periods are open: Aucune période d'accompagnement ouverte
|
||||||
An accompanying period is open: Une période d'accompagnement est ouverte
|
An accompanying period is open: Une période d'accompagnement est ouverte
|
||||||
Accompanying period list: Périodes d'accompagnement
|
Accompanying period list: Périodes d'accompagnement
|
||||||
@ -162,11 +164,10 @@ Pediod closing form is not valid: Le formulaire n'est pas valide
|
|||||||
Accompanying user: Accompagnant
|
Accompanying user: Accompagnant
|
||||||
No accompanying user: Aucun accompagnant
|
No accompanying user: Aucun accompagnant
|
||||||
No data given: Pas d'information
|
No data given: Pas d'information
|
||||||
|
Participants: Personnes impliquées
|
||||||
# pickAPersonType
|
# pickAPersonType
|
||||||
Pick a person: Choisir une personne
|
Pick a person: Choisir une personne
|
||||||
|
|
||||||
#address
|
|
||||||
Since %date%: Depuis le %date%
|
|
||||||
No address given: Pas d'adresse renseignée
|
No address given: Pas d'adresse renseignée
|
||||||
The address has been successfully updated: L'adresse a été mise à jour avec succès
|
The address has been successfully updated: L'adresse a été mise à jour avec succès
|
||||||
Update address for %name%: Mettre à jour une adresse pour %name%
|
Update address for %name%: Mettre à jour une adresse pour %name%
|
||||||
|
Loading…
x
Reference in New Issue
Block a user