admin: add CancelReason admin

This commit is contained in:
nobohan 2022-05-06 15:25:49 +02:00
parent 7907e4a050
commit a4f2d47c46
8 changed files with 215 additions and 2 deletions

View File

@ -0,0 +1,26 @@
<?php
/**
* 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.
*/
declare(strict_types=1);
namespace Chill\CalendarBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
class CancelReasonController extends CRUDController
{
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
$query->addOrderBy('e.id', 'ASC');
return parent::orderQuery($action, $query, $request, $paginator);
}
}

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\DependencyInjection; namespace Chill\CalendarBundle\DependencyInjection;
use Chill\CalendarBundle\Entity\CancelReason;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
@ -47,6 +48,29 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
protected function prependCruds(ContainerBuilder $container) protected function prependCruds(ContainerBuilder $container)
{ {
$container->prependExtensionConfig('chill_main', [ $container->prependExtensionConfig('chill_main', [
'cruds' => [
[
'class' => \Chill\CalendarBundle\Entity\CancelReason::class,
'name' => 'calendar_cancel-reason',
'base_path' => '/admin/calendar/cancel-reason',
'form_class' => \Chill\CalendarBundle\Form\CancelReasonType::class,
'controller' => \Chill\CalendarBundle\Controller\CancelReasonController::class,
'actions' => [
'index' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillCalendar/CancelReason/index.html.twig',
],
'new' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillCalendar/CancelReason/new.html.twig',
],
'edit' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillCalendar/CancelReason/edit.html.twig',
],
],
],
],
'apis' => [ 'apis' => [
[ [
'controller' => \Chill\CalendarBundle\Controller\CalendarRangeAPIController::class, 'controller' => \Chill\CalendarBundle\Controller\CalendarRangeAPIController::class,

View File

@ -0,0 +1,39 @@
<?php
/**
* 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.
*/
declare(strict_types=1);
namespace Chill\CalendarBundle\Form;
use Chill\CalendarBundle\Entity\CancelReason;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class CancelReasonType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TranslatableStringFormType::class)
->add('active', CheckboxType::class, [
'required' => false,
])
->add('canceledBy', TextType::class);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('class', CancelReason::class);
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* 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.
*/
declare(strict_types=1);
namespace Chill\CalendarBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class AdminMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{
$this->authorizationChecker = $authorizationChecker;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
return;
}
$menu->addChild('Calendar')
->setAttribute('class', 'list-group-item-header')
->setExtras(['order' => 6000, 'header' => true]);
$menu->addChild('Cancel reason', [
'route' => 'chill_crud_calendar_cancel-reason_index',
])->setExtras(['order' => 6010]);
}
public static function getMenuIds(): array
{
return ['admin_section'];
}
}

View File

@ -0,0 +1,11 @@
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
{% block title %}
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
{% endblock %}
{% block admin_content %}
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
{% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %}
{% endblock admin_content %}

View File

@ -0,0 +1,43 @@
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
{% block admin_content %}
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% block table_entities_thead_tr %}
<th>{{ 'Id'|trans }}</th>
<th>{{ 'Name'|trans }}</th>
<th>{{ 'canceledBy'|trans }}</th>
<th>{{ 'active'|trans }}</th>
<th>&nbsp;</th>
{% endblock %}
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<td>{{ entity.id }}</td>
<td>{{ entity.name|localize_translatable_string }}</td>
<td>{{ entity.canceledBy }}</td>
<td style="text-align:center;">
{%- if entity.active -%}
<i class="fa fa-check-square-o"></i>
{%- else -%}
<i class="fa fa-square-o"></i>
{%- endif -%}
</td>
<td>
<ul class="record_actions">
<li>
<a href="{{ chill_path_add_return_path('chill_crud_calendar_cancel-reason_edit', { 'id': entity.id }) }}" class="btn btn-edit"></a>
</li>
</ul>
</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 %}
{% endembed %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
{% block title %}
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
{% endblock %}
{% block admin_content %}
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
{% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %}
{% endblock admin_content %}

View File

@ -17,7 +17,7 @@ status: Statut du rendez-vous
calendar location: Localistion du rendez-vous calendar location: Localistion du rendez-vous
calendar comment: Remarque sur le rendez-vous calendar comment: Remarque sur le rendez-vous
sendSMS: Envoi d'un SMS sendSMS: Envoi d'un SMS
Send s m s: Envoi d'un SMS ? Send s m s: Envoi d'un SMS ?
Cancel reason: Motif d'annulation Cancel reason: Motif d'annulation
Add a new calendar: Ajouter un nouveau rendez-vous Add a new calendar: Ajouter un nouveau rendez-vous
"Success : calendar item updated!": "Rendez-vous mis à jour" "Success : calendar item updated!": "Rendez-vous mis à jour"
@ -25,4 +25,13 @@ Add a new calendar: Ajouter un nouveau rendez-vous
The calendar item has been successfully removed.: Le rendez-vous a été supprimé The calendar item has been successfully removed.: Le rendez-vous a été supprimé
From the day: Du From the day: Du
to the day: au to the day: au
Transform to activity: Transformer en échange Transform to activity: Transformer en échange
canceledBy: supprimé par
crud:
calendar_cancel-reason:
index:
title: Liste des motifs d'annulation
add_new: Ajouter un nouveau
title_new: Nouveau motif d'annulation
title_edit: Modifier le motif d'annulation