[admin][templates] move job/scope history in an unique template and display history for a given user

This commit is contained in:
Mathieu Jaumotte 2023-10-04 12:13:10 +02:00
parent b4e5618e00
commit c526973475
12 changed files with 167 additions and 216 deletions

View File

@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
class UserJobHistoryController extends CRUDController
{
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
$query
->addOrderBy('e.startDate', 'DESC')
->addOrderBy('e.user', 'ASC')
;
return parent::orderQuery($action, $query, $request, $paginator);
}
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Twig\Environment;
class UserJobScopeHistoriesController extends AbstractController
{
public function __construct(
private readonly Environment $engine,
) {}
/**
* @Route("/{_locale}/admin/main/user/{id}/job-scope-history", name="admin_user_job_scope_history")
*/
public function indexAction(User $user): Response
{
$jobHistories = $user->getUserJobHistories();
$scopeHistories = $user->getMainScopeHistories();
return new Response(
$this->engine->render('@ChillMain/User/history.html.twig', [
'user' => $user,
'jobHistories' => $jobHistories,
'scopeHistories' => $scopeHistories,
]
));
}
}

View File

@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
class UserScopeHistoryController extends CRUDController
{
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
$query
->addOrderBy('e.startDate', 'DESC')
->addOrderBy('e.user', 'ASC')
;
return parent::orderQuery($action, $query, $request, $paginator);
}
}

View File

@ -375,32 +375,6 @@ class ChillMainExtension extends Extension implements
],
],
],
[
'class' => UserJobHistory::class,
'controller' => UserJobHistoryController::class,
'name' => 'admin_user_job_history',
'base_path' => '/admin/main/user-job-history',
'base_role' => 'ROLE_ADMIN',
'actions' => [
'index' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/UserJob/history.html.twig',
],
],
],
[
'class' => UserScopeHistory::class,
'controller' => UserScopeHistoryController::class,
'name' => 'admin_user_scope_history',
'base_path' => '/admin/main/user-scope-history',
'base_role' => 'ROLE_ADMIN',
'actions' => [
'index' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/Scope/history.html.twig',
],
],
],
[
'class' => User::class,
'controller' => UserController::class,

View File

@ -1,51 +0,0 @@
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
{% block admin_content %}
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% block table_entities_thead_tr %}
<th>{{ 'crud.admin_user_scope_history.index.start'|trans }}</th>
<th>{{ 'crud.admin_user_scope_history.index.end'|trans }}</th>
<th>{{ 'crud.admin_user_scope_history.index.user'|trans }}</th>
<th>{{ 'crud.admin_user_scope_history.index.scope'|trans }}</th>
{% endblock %}
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<td>{{ entity.startDate|format_datetime('medium') }}</td>
<td>
{% if entity.endDate is not null %}
{{ entity.endDate|format_datetime('medium') }}
{% else %}
<i class="opacity-50">{{ "crud.admin_user_scope_history.index.today"|trans }}</i>
{% endif %}
</td>
<td>{{ entity.user.usernameCanonical }}</td>
<td>
{% if entity.scope %}
{{ entity.scope.name|localize_translatable_string }}
{% else %}
<i class="opacity-50">{{ 'crud.admin_user_scope_history.index.undefined'|trans }}</i>
{% endif %}
</td>
</tr>
{% endfor %}
{% endblock %}
{% block actions_before %}
<li class='cancel'>
<a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans }}</a>
</li>
{% endblock %}
{% block list_actions %}
<ul class="record_actions sticky-form-buttons">
<li class='cancel'>
<a href="{{ path('admin_scope') }}" class="btn btn-cancel">{{'crud.admin_user_scope_history.Back to user scope'|trans }}</a>
</li>
</ul>
{% endblock %}
{% endembed %}
{% endblock %}

View File

@ -48,9 +48,6 @@
<li class='cancel'>
<a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans}}</a>
</li>
<li>
<a href="{{ path('chill_crud_admin_user_scope_history_index') }}" class="btn btn-show">{{ 'crud.admin_user_scope_history.Show scope history'|trans }}</a>
</li>
<li>
<a href="{{ path('admin_scope_new') }}" class="btn btn-create">{{ 'Create a new circle'|trans }}</a>
</li>

View File

@ -1,7 +1,8 @@
{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
{% block admin_content -%}
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
{% block crud_content_after_form %}
{% if access_permissions_group_list %}
<h2 class="mt-5">{{ 'Permissions granted'|trans }}</h2>
@ -54,5 +55,14 @@
{% endblock %}
{% block content_form_actions_save_and_show %}{% endblock %}
{% block content_form_actions_view %}
<li>
<a href="{{ path('admin_user_job_scope_history', {id: entity.id}) }}" class="btn btn-show">
{{ 'admin.users.job_scope_histories.Show history'|trans }}
</a>
</li>
{% endblock %}
{% endembed %}
{% endblock %}

View File

@ -0,0 +1,81 @@
{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
{% block title %}{{ 'admin.users.job_scope_histories.index.histories'|trans }}{% endblock title %}
{% block admin_content %}
<h2>{{ user.usernameCanonical }}</h2>
<h1>{{ 'admin.users.job_scope_histories.index.histories'|trans }}</h1>
<h3 class="mt-5">{{ 'admin.users.job_scope_histories.index.job_history.title'|trans }}</h3>
<table class="records_list table table-bordered border-dark">
<thead>
<tr>
<th class="w-25">{{ 'admin.users.job_scope_histories.index.job_history.start'|trans }}</th>
<th class="w-25">{{ 'admin.users.job_scope_histories.index.job_history.end'|trans }}</th>
<th>{{ 'admin.users.job_scope_histories.index.job_history.job'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entity in jobHistories|reverse %}
<tr>
<td>{{ entity.startDate|format_datetime('medium') }}</td>
<td>
{% if entity.endDate is not null %}
{{ entity.endDate|format_datetime('medium') }}
{% else %}
<i class="opacity-50">{{ "admin.users.job_scope_histories.index.job_history.today"|trans }}</i>
{% endif %}
</td>
<td>
{% if entity.job %}
{{ entity.job.label|localize_translatable_string }}
{% else %}
<i class="opacity-50">{{ 'admin.users.job_scope_histories.index.job_history.undefined'|trans }}</i>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<h3 class="mt-5">{{ 'admin.users.job_scope_histories.index.scope_history.title'|trans }}</h3>
<table class="records_list table table-bordered border-dark">
<thead>
<tr>
<th class="w-25">{{ 'admin.users.job_scope_histories.index.scope_history.start'|trans }}</th>
<th class="w-25">{{ 'admin.users.job_scope_histories.index.scope_history.end'|trans }}</th>
<th>{{ 'admin.users.job_scope_histories.index.scope_history.scope'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entity in scopeHistories|reverse %}
<tr>
<td>{{ entity.startDate|format_datetime('medium') }}</td>
<td>
{% if entity.endDate is not null %}
{{ entity.endDate|format_datetime('medium') }}
{% else %}
<i class="opacity-50">{{ "admin.users.job_scope_histories.index.scope_history.today"|trans }}</i>
{% endif %}
</td>
<td>
{% if entity.scope %}
{{ entity.scope.name|localize_translatable_string }}
{% else %}
<i class="opacity-50">{{ 'admin.users.job_scope_histories.index.scope_history.undefined'|trans }}</i>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul class="record_actions sticky-form-buttons">
<li class='cancel'>
<a href="{{ path('chill_crud_admin_user_edit', {id: user.id}) }}" class="btn btn-cancel">
{{'admin.users.job_scope_histories.index.Back to user job'|trans }}
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,51 +0,0 @@
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
{% block admin_content %}
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% block table_entities_thead_tr %}
<th>{{ 'crud.admin_user_job_history.index.start'|trans }}</th>
<th>{{ 'crud.admin_user_job_history.index.end'|trans }}</th>
<th>{{ 'crud.admin_user_job_history.index.user'|trans }}</th>
<th>{{ 'crud.admin_user_job_history.index.job'|trans }}</th>
{% endblock %}
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<td>{{ entity.startDate|format_datetime('medium') }}</td>
<td>
{% if entity.endDate is not null %}
{{ entity.endDate|format_datetime('medium') }}
{% else %}
<i class="opacity-50">{{ "crud.admin_user_job_history.index.today"|trans }}</i>
{% endif %}
</td>
<td>{{ entity.user.usernameCanonical }}</td>
<td>
{% if entity.job %}
{{ entity.job.label|localize_translatable_string }}
{% else %}
<i class="opacity-50">{{ 'crud.admin_user_job_history.index.undefined'|trans }}</i>
{% endif %}
</td>
</tr>
{% endfor %}
{% endblock %}
{% block actions_before %}
<li class='cancel'>
<a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans }}</a>
</li>
{% endblock %}
{% block list_actions %}
<ul class="record_actions sticky-form-buttons">
<li class='cancel'>
<a href="{{ path('chill_crud_admin_user_job_index') }}" class="btn btn-cancel">{{'crud.admin_user_job_history.Back to user job'|trans }}</a>
</li>
</ul>
{% endblock %}
{% endembed %}
{% endblock %}

View File

@ -37,9 +37,6 @@
<li class='cancel'>
<a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans }}</a>
</li>
<li>
<a href="{{ path('chill_crud_admin_user_job_history_index') }}" class="btn btn-show">{{ 'crud.admin_user_job_history.Show job history'|trans }}</a>
</li>
{% endblock %}
{% endembed %}

View File

@ -389,28 +389,6 @@ crud:
add_new: Créer
title_new: Nouveau métier
title_edit: Modifier un métier
admin_user_job_history:
index:
title: Historique des métiers
start: Du
end: Jusque
today: en cours
undefined: non défini
user: Utilisateur
job: Métier
Show job history: Voir l'historique
Back to user job: Revenir aux métiers
admin_user_scope_history:
index:
title: Historique des cercles
start: Du
end: Jusque
today: en cours
undefined: non défini
user: Utilisateur
scope: Cercle
Show scope history: Voir l'historique
Back to user scope: Revenir aux cercles
main_location_type:
index:
title: Liste des types de localisations
@ -673,3 +651,24 @@ admin:
center_name: Centre
permissionsGroup_id: Identifiant du groupe de permissions
permissionsGroup_name: Groupe de permissions
job_scope_histories:
Show history: Voir l'historique
index:
histories: Historique des services et des métiers
Back to user job: Revenir à l'utilisateur
job_history:
title: Historique des métiers
start: Du
end: Jusque
today: en cours
undefined: non défini
user: Utilisateur
job: Métier
scope_history:
title: Historique des services
start: Du
end: Jusque
today: en cours
undefined: non défini
user: Utilisateur
scope: Service

View File

@ -36,7 +36,17 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class HouseholdCompositionController extends AbstractController
{
public function __construct(private readonly Security $security, private readonly HouseholdCompositionRepository $householdCompositionRepository, private readonly HouseholdRepository $householdRepository, private readonly PaginatorFactory $paginatorFactory, private readonly FormFactoryInterface $formFactory, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly UrlGeneratorInterface $urlGenerator) {}
public function __construct(
private readonly Security $security,
private readonly HouseholdCompositionRepository $householdCompositionRepository,
private readonly HouseholdRepository $householdRepository,
private readonly PaginatorFactory $paginatorFactory,
private readonly FormFactoryInterface $formFactory,
private readonly EntityManagerInterface $entityManager,
private readonly TranslatorInterface $translator,
private readonly \Twig\Environment $engine,
private readonly UrlGeneratorInterface $urlGenerator
) {}
/**
* @Route("/{_locale}/person/household/{household_id}/composition/{composition_id}/delete", name="chill_person_household_composition_delete")