mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Feature: [admin][ActivityReason] improve administration for activity reason
* list alphabetically; * show "active" in index
This commit is contained in:
parent
e99fb75ebd
commit
25dd65fbd8
@ -13,15 +13,24 @@ namespace Chill\ActivityBundle\Controller;
|
|||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
use Chill\ActivityBundle\Form\ActivityReasonType;
|
use Chill\ActivityBundle\Form\ActivityReasonType;
|
||||||
|
use Chill\ActivityBundle\Repository\ActivityReasonRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityReason controller.
|
* ActivityReason controller.
|
||||||
*/
|
*/
|
||||||
class ActivityReasonController extends AbstractController
|
class ActivityReasonController extends AbstractController
|
||||||
{
|
{
|
||||||
|
private ActivityReasonRepository $activityReasonRepository;
|
||||||
|
|
||||||
|
public function __construct(ActivityReasonRepository $activityReasonRepository)
|
||||||
|
{
|
||||||
|
$this->activityReasonRepository = $activityReasonRepository;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ActivityReason entity.
|
* Creates a new ActivityReason entity.
|
||||||
*/
|
*/
|
||||||
@ -56,8 +65,8 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
$entity = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->find($id);
|
$entity = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->find($id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (null === $entity) {
|
||||||
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
|
throw new NotFoundHttpException('Unable to find ActivityReason entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
$editForm = $this->createEditForm($entity);
|
||||||
@ -75,7 +84,7 @@ class ActivityReasonController extends AbstractController
|
|||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$entities = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->findAll();
|
$entities = $this->activityReasonRepository->findAll();
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:index.html.twig', [
|
return $this->render('ChillActivityBundle:ActivityReason:index.html.twig', [
|
||||||
'entities' => $entities,
|
'entities' => $entities,
|
||||||
|
@ -63,10 +63,8 @@ class ActivityReason
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get category.
|
* Get category.
|
||||||
*
|
|
||||||
* @return ActivityReasonCategory
|
|
||||||
*/
|
*/
|
||||||
public function getCategory()
|
public function getCategory(): ?ActivityReasonCategory
|
||||||
{
|
{
|
||||||
return $this->category;
|
return $this->category;
|
||||||
}
|
}
|
||||||
@ -107,6 +105,11 @@ class ActivityReason
|
|||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isActiveAndParentActive(): bool
|
||||||
|
{
|
||||||
|
return $this->active && null !== $this->getCategory() && $this->getCategory()->getActive();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set active.
|
* Set active.
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategoryType;
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
@ -25,13 +26,13 @@ class ActivityReasonType extends AbstractType
|
|||||||
$builder
|
$builder
|
||||||
->add('name', TranslatableStringFormType::class)
|
->add('name', TranslatableStringFormType::class)
|
||||||
->add('active', CheckboxType::class, ['required' => false])
|
->add('active', CheckboxType::class, ['required' => false])
|
||||||
->add('category', TranslatableActivityReasonCategory::class);
|
->add('category', TranslatableActivityReasonCategoryType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => 'Chill\ActivityBundle\Entity\ActivityReason',
|
'data_class' => ActivityReason::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,17 +14,38 @@ namespace Chill\ActivityBundle\Repository;
|
|||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method ActivityReason|null find($id, $lockMode = null, $lockVersion = null)
|
* @method ActivityReason|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method ActivityReason|null findOneBy(array $criteria, array $orderBy = null)
|
* @method ActivityReason|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method ActivityReason[] findAll()
|
|
||||||
* @method ActivityReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method ActivityReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
*/
|
*/
|
||||||
class ActivityReasonRepository extends ServiceEntityRepository
|
class ActivityReasonRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
private RequestStack $requestStack;
|
||||||
{
|
|
||||||
|
public function __construct(
|
||||||
|
ManagerRegistry $registry,
|
||||||
|
RequestStack $requestStack
|
||||||
|
) {
|
||||||
parent::__construct($registry, ActivityReason::class);
|
parent::__construct($registry, ActivityReason::class);
|
||||||
|
|
||||||
|
$this->requestStack = $requestStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ActivityReason[]
|
||||||
|
*/
|
||||||
|
public function findAll(): array
|
||||||
|
{
|
||||||
|
$qb = $this->createQueryBuilder('ar');
|
||||||
|
$qb->select(['ar'])
|
||||||
|
->leftJoin('ar.category', 'category')
|
||||||
|
->addOrderBy('JSON_EXTRACT(category.name, :lang)')
|
||||||
|
->addOrderBy('JSON_EXTRACT(ar.name, :lang)')
|
||||||
|
->setParameter('lang', $this->requestStack->getCurrentRequest()->getLocale() ?? 'fr');
|
||||||
|
|
||||||
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,22 +7,34 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ 'Name'|trans }}</th>
|
<th>{{ 'Name'|trans }}</th>
|
||||||
|
<th>{{ 'Active'|trans }}</th>
|
||||||
<th>{{ 'Actions'|trans }}</th>
|
<th>{{ 'Actions'|trans }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr class="{% if entity.active %}active{% else %}inactive{% endif %}">
|
<tr class="{% if entity.active %}active{% else %}inactive{% endif %}">
|
||||||
<td><a href="{{ path('chill_activity_activityreason_show', { 'id': entity.id }) }}">{{ entity.name|localize_translatable_string }}</a></td>
|
|
||||||
<td>
|
<td>
|
||||||
<ul class="record_actions">
|
{% if entity.category is not null -%}
|
||||||
<li>
|
{{ entity.category.name|localize_translatable_string }} >
|
||||||
<a href="{{ path('chill_activity_activityreason_show', { 'id': entity.id }) }}" class="btn btn-show" title="{{ 'show'|trans }}"></a>
|
{% endif -%}
|
||||||
</li>
|
{{ entity.name|localize_translatable_string }}
|
||||||
<li>
|
</td>
|
||||||
<a href="{{ path('chill_activity_activityreason_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'edit'|trans }}"></a>
|
<td>
|
||||||
</li>
|
<i class="fa {% if entity.active %}fa-check-square-o{% else %}fa-square-o{% endif %}"></i>
|
||||||
</ul>
|
{% if entity.active and not entity.isActiveAndParentActive %}
|
||||||
|
<span class="badge text-bg-danger text-white">{{ 'Associated activity reason category is inactive'|trans }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_activity_activityreason_show', { 'id': entity.id }) }}" class="btn btn-show" title="{{ 'show'|trans }}"></a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_activity_activityreason_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'edit'|trans }}"></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ 'Name'|trans }}</th>
|
<th>{{ 'Name'|trans }}</th>
|
||||||
|
<th>{{ 'Active'|trans }}</th>
|
||||||
<th>{{ 'Actions'|trans }}</th>
|
<th>{{ 'Actions'|trans }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -14,7 +15,11 @@
|
|||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ path('chill_activity_activityreasoncategory_show', { 'id': entity.id }) }}">{{ entity.name|localize_translatable_string }}</a></td>
|
{{ entity.name|localize_translatable_string }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<i class="fa {% if entity.active %}fa-check-square-o{% else %}fa-square-o{% endif %}"></i>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
Chill\ActivityBundle\Controller\ActivityController:
|
_defaults:
|
||||||
autowire: true
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
|
||||||
|
Chill\ActivityBundle\Controller\:
|
||||||
|
resource: '../../Controller/'
|
||||||
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
|
Chill\ActivityBundle\Controller\ActivityController:
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
---
|
---
|
||||||
services:
|
services:
|
||||||
chill.activity.form.type.translatableactivityreasoncategory:
|
Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategoryType:
|
||||||
class: Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory
|
autowire: true
|
||||||
arguments:
|
autoconfigure: true
|
||||||
- "@request_stack"
|
|
||||||
tags:
|
|
||||||
- { name: form.type, alias: translatable_activity_reason_category }
|
|
||||||
|
|
||||||
chill.activity.form.type.translatableactivityreason:
|
chill.activity.form.type.translatableactivityreason:
|
||||||
class: Chill\ActivityBundle\Form\Type\TranslatableActivityReason
|
class: Chill\ActivityBundle\Form\Type\TranslatableActivityReason
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
---
|
---
|
||||||
services:
|
services:
|
||||||
|
Chill\ActivityBundle\Repository\ActivityReasonRepository:
|
||||||
|
autowire: true
|
||||||
|
|
||||||
chill_activity.repository.activity_type: '@Chill\ActivityBundle\Repository\ActivityTypeRepository'
|
chill_activity.repository.activity_type: '@Chill\ActivityBundle\Repository\ActivityTypeRepository'
|
||||||
chill_activity.repository.reason: '@Chill\ActivityBundle\Repository\ActivityReasonRepository'
|
chill_activity.repository.reason: '@Chill\ActivityBundle\Repository\ActivityReasonRepository'
|
||||||
chill_activity.repository.reason_category: '@Chill\ActivityBundle\Repository\ActivityReasonCategoryRepository'
|
chill_activity.repository.reason_category: '@Chill\ActivityBundle\Repository\ActivityReasonCategoryRepository'
|
||||||
|
@ -117,6 +117,7 @@ Activity Reasons: Sujets d'une activité
|
|||||||
Activity Reasons Category: Catégories de sujet d'activités
|
Activity Reasons Category: Catégories de sujet d'activités
|
||||||
Activity Types Categories: Catégories des types d'activité
|
Activity Types Categories: Catégories des types d'activité
|
||||||
Activity Presences: Presences aux activités
|
Activity Presences: Presences aux activités
|
||||||
|
Associated activity reason category is inactive: La catégorie de sujet attachée est inactive
|
||||||
|
|
||||||
|
|
||||||
# Crud
|
# Crud
|
||||||
@ -276,7 +277,7 @@ Creators: Créateurs
|
|||||||
Filter activity by userscope: Filtrer les activités par service du créateur
|
Filter activity by userscope: Filtrer les activités par service du créateur
|
||||||
'Filtered activity by userscope: only %scopes%': "Filtré par service du créateur: uniquement %scopes%"
|
'Filtered activity by userscope: only %scopes%': "Filtré par service du créateur: uniquement %scopes%"
|
||||||
Accepted userscope: Services
|
Accepted userscope: Services
|
||||||
|
|
||||||
Filter acp which has no activity: Filtrer les parcours qui n’ont pas d’activité
|
Filter acp which has no activity: Filtrer les parcours qui n’ont pas d’activité
|
||||||
Filtered acp which has no activities: Filtrer les parcours sans activité associée
|
Filtered acp which has no activities: Filtrer les parcours sans activité associée
|
||||||
Group acp by activity number: Grouper les parcours par nombre d’activité
|
Group acp by activity number: Grouper les parcours par nombre d’activité
|
||||||
|
@ -42,6 +42,8 @@ by_user: "par "
|
|||||||
lifecycleUpdate: Evenements de création et mise à jour
|
lifecycleUpdate: Evenements de création et mise à jour
|
||||||
address_fields: Données liées à l'adresse
|
address_fields: Données liées à l'adresse
|
||||||
|
|
||||||
|
inactive: inactif
|
||||||
|
|
||||||
Edit: Modifier
|
Edit: Modifier
|
||||||
Update: Mettre à jour
|
Update: Mettre à jour
|
||||||
Back to the list: Retour à la liste
|
Back to the list: Retour à la liste
|
||||||
|
Loading…
x
Reference in New Issue
Block a user