FIX [render] use isAbsent method to render user as absent or not + place homepage msg above searchbar

This commit is contained in:
Julie Lenaerts 2023-01-27 11:10:17 +01:00
parent f76c031ff3
commit bb7d072cc8
5 changed files with 8 additions and 8 deletions

View File

@ -304,7 +304,7 @@ class User implements UserInterface
public function isAbsent(): bool
{
return null !== $this->getAbsenceStart() ? true : false;
return (null !== $this->getAbsenceStart() && $this->getAbsenceStart() <= new DateTimeImmutable('now')) ? true : false;
}
/**

View File

@ -6,7 +6,7 @@
{%- 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 opts['absence'] and user.isAbsent %}
{%- if date(user.absenceStart) < date() %}
<span class="fa-stack fa-holder" title="{{ 'absence.Absent'|trans }}">
<i class="fa fa-circle fa-stack-1x text-danger"></i>

View File

@ -1,10 +1,5 @@
<div class="col-10 mt-5">
{# vue component #}
{% if app.user.absenceStart is not null and date(app.user.absenceStart) < date() %}
<p class="alert alert-warning" role="alert">{{'absence.You are marked as being absent'|trans }}</p>
{% endif %}
<div id="homepage_widget"></div>
{% include '@ChillMain/Homepage/fast_actions.html.twig' %}

View File

@ -69,6 +69,11 @@
{% block content %}
<div class="col-8 main_search">
{% if app.user.isAbsent %}
<div class="row mb-5">
<p class="alert alert-warning" role="alert">{{'absence.You are marked as being absent'|trans }}</p>
</div>
{% endif %}
<h2>{{ 'Search'|trans }}</h2>
<form action="{{ path('chill_main_search') }}" method="get">

View File

@ -71,7 +71,7 @@ class UserRender implements ChillEntityRenderInterface
$current_date = new DateTimeImmutable();
if (null !== $entity->getAbsenceStart() && $entity->getAbsenceStart() < $current_date && $opts['main_scope']) {
if ($entity->isAbsent() && $opts['main_scope']) {
$str .= ' (' . $this->translator->trans('absence.Absent') . ')';
}