mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
FEATURE [absence][render] add absence tag to renderbox and renderstring
This commit is contained in:
parent
2c5c815f68
commit
5bbe5af124
@ -6,4 +6,9 @@
|
||||
{%- if opts['main_scope'] and user.mainScope is not null %}
|
||||
<span class="main-scope">({{ user.mainScope.name|localize_translatable_string }})</span>
|
||||
{%- endif -%}
|
||||
{%- if opts['absence'] and user.absenceStart is not null %}
|
||||
{%- if date(user.absenceStart) < date() %}
|
||||
<span class="user-absence">({{ 'absence.Absent'|trans }})</span>
|
||||
{%- endif %}
|
||||
{%- endif -%}
|
||||
</span>
|
||||
|
@ -13,8 +13,10 @@ namespace Chill\MainBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use DateTimeImmutable;
|
||||
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function array_merge;
|
||||
|
||||
class UserRender implements ChillEntityRenderInterface
|
||||
@ -22,16 +24,20 @@ class UserRender implements ChillEntityRenderInterface
|
||||
public const DEFAULT_OPTIONS = [
|
||||
'main_scope' => true,
|
||||
'user_job' => true,
|
||||
'absence' => true,
|
||||
];
|
||||
|
||||
private EngineInterface $engine;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine, TranslatorInterface $translator)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->engine = $engine;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function renderBox($entity, array $options): string
|
||||
@ -63,6 +69,12 @@ class UserRender implements ChillEntityRenderInterface
|
||||
->localize($entity->getMainScope()->getName()) . ')';
|
||||
}
|
||||
|
||||
$current_date = new DateTimeImmutable();
|
||||
|
||||
if (null !== $entity->getAbsenceStart() && $entity->getAbsenceStart() < $current_date && $opts['main_scope']) {
|
||||
$str .= ' (' . $this->translator->trans('absence.Absent') . ')';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
@ -580,3 +580,4 @@ absence:
|
||||
Unset absence: Supprimer la date d'absence
|
||||
Set absence date: Indiquer date d'absence
|
||||
Absence start: Absence à partir de
|
||||
Absent: Absent
|
||||
|
Loading…
x
Reference in New Issue
Block a user