mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Improve naming for 'at date' in user render component
This commit is contained in:
parent
4091efc72e
commit
d0ec6f9819
@ -274,13 +274,13 @@ class User implements UserInterface, \Stringable
|
|||||||
return $this->mainLocation;
|
return $this->mainLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMainScope(?\DateTimeImmutable $at = null): ?Scope
|
public function getMainScope(\DateTime $atDate = null): ?Scope
|
||||||
{
|
{
|
||||||
$at ??= new \DateTimeImmutable('now');
|
$atDate ??= new \DateTimeImmutable('now');
|
||||||
|
|
||||||
foreach ($this->scopeHistories as $scopeHistory) {
|
foreach ($this->scopeHistories as $scopeHistory) {
|
||||||
if ($at >= $scopeHistory->getStartDate() && (
|
if ($atDate >= $scopeHistory->getStartDate() && (
|
||||||
null === $scopeHistory->getEndDate() || $at < $scopeHistory->getEndDate()
|
null === $scopeHistory->getEndDate() || $atDate < $scopeHistory->getEndDate()
|
||||||
)) {
|
)) {
|
||||||
return $scopeHistory->getScope();
|
return $scopeHistory->getScope();
|
||||||
}
|
}
|
||||||
@ -326,13 +326,13 @@ class User implements UserInterface, \Stringable
|
|||||||
return $this->salt;
|
return $this->salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserJob(?\DateTimeImmutable $at = null): ?UserJob
|
public function getUserJob(\DateTime $atDate = null): ?UserJob
|
||||||
{
|
{
|
||||||
$at ??= new \DateTimeImmutable('now');
|
$atDate ??= new \DateTimeImmutable('now');
|
||||||
|
|
||||||
foreach ($this->jobHistories as $jobHistory) {
|
foreach ($this->jobHistories as $jobHistory) {
|
||||||
if ($at >= $jobHistory->getStartDate() && (
|
if ($atDate >= $jobHistory->getStartDate() && (
|
||||||
null === $jobHistory->getEndDate() || $at < $jobHistory->getEndDate()
|
null === $jobHistory->getEndDate() || $atDate < $jobHistory->getEndDate()
|
||||||
)) {
|
)) {
|
||||||
return $jobHistory->getJob();
|
return $jobHistory->getJob();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<span class="chill-entity entity-user">
|
<span class="chill-entity entity-user">
|
||||||
{{- user.label }}
|
{{- user.label }}
|
||||||
{%- if opts['user_job'] and user.userJob(opts['at']) is not null %}
|
{%- if opts['user_job'] and user.userJob(opts['at_date']) is not null %}
|
||||||
<span class="user-job">({{ user.userJob(opts['at']).label|localize_translatable_string }})</span>
|
<span class="user-job">({{ user.userJob(opts['at_date']).label|localize_translatable_string }})</span>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if opts['main_scope'] and user.mainScope(opts['at']) is not null %}
|
{%- if opts['main_scope'] and user.mainScope(opts['at_date']) is not null %}
|
||||||
<span class="main-scope">({{ user.mainScope(opts['at']).name|localize_translatable_string }})</span>
|
<span class="main-scope">({{ user.mainScope(opts['at_date']).name|localize_translatable_string }})</span>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if opts['absence'] and user.isAbsent %}
|
{%- if opts['absence'] and user.isAbsent %}
|
||||||
<span class="badge bg-danger rounded-pill" title="{{ 'absence.Absent'|trans|escape('html_attr') }}">{{ 'absence.A'|trans }}</span>
|
<span class="badge bg-danger rounded-pill" title="{{ 'absence.Absent'|trans|escape('html_attr') }}">{{ 'absence.A'|trans }}</span>
|
||||||
|
@ -24,7 +24,7 @@ class UserRender implements ChillEntityRenderInterface
|
|||||||
'main_scope' => true,
|
'main_scope' => true,
|
||||||
'user_job' => true,
|
'user_job' => true,
|
||||||
'absence' => true,
|
'absence' => true,
|
||||||
'at' => null,
|
'at_date' => null,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator)
|
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator)
|
||||||
@ -47,14 +47,14 @@ class UserRender implements ChillEntityRenderInterface
|
|||||||
|
|
||||||
$str = $entity->getLabel();
|
$str = $entity->getLabel();
|
||||||
|
|
||||||
if (null !== $entity->getUserJob($opts['at']) && $opts['user_job']) {
|
if (null !== $entity->getUserJob($opts['at_date']) && $opts['user_job']) {
|
||||||
$str .= ' ('.$this->translatableStringHelper
|
$str .= ' ('.$this->translatableStringHelper
|
||||||
->localize($entity->getUserJob($opts['at'])->getLabel()).')';
|
->localize($entity->getUserJob($opts['at_date'])->getLabel()).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $entity->getMainScope($opts['at']) && $opts['main_scope']) {
|
if (null !== $entity->getMainScope($opts['at_date']) && $opts['main_scope']) {
|
||||||
$str .= ' ('.$this->translatableStringHelper
|
$str .= ' ('.$this->translatableStringHelper
|
||||||
->localize($entity->getMainScope($opts['at'])->getName()).')';
|
->localize($entity->getMainScope($opts['at_date'])->getName()).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($entity->isAbsent() && $opts['absence']) {
|
if ($entity->isAbsent() && $opts['absence']) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user