From f449dcbda1466d7725a4c57f696c6bb8d74b8e69 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 10 May 2022 18:06:29 +0200 Subject: [PATCH] admin: refine social work admin form --- .../Controller/UserController.php | 48 ++++++++++++++++++- .../Resources/views/User/index.html.twig | 3 ++ .../ChillPersonExtension.php | 4 +- .../SocialWork/Evaluation/index.html.twig | 28 +++++++++++ .../views/SocialWork/Goal/index.html.twig | 12 +++++ .../SocialWork/SocialAction/edit.html.twig | 22 +++++++++ .../SocialWork/SocialAction/index.html.twig | 26 ++++++++++ .../SocialWork/SocialIssue/edit.html.twig | 22 +++++++++ .../SocialWork/SocialIssue/index.html.twig | 12 +++++ .../translations/messages.fr.yml | 4 ++ 10 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 61895eaa9..127519013 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -19,8 +19,11 @@ use Chill\MainBundle\Form\UserCurrentLocationType; use Chill\MainBundle\Form\UserPasswordType; use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Pagination\PaginatorInterface; +use Chill\MainBundle\Templating\Listing\FilterOrderHelper; +use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; use Psr\Log\LoggerInterface; use RuntimeException; +use LogicException; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Form; use Symfony\Component\Form\FormInterface; @@ -41,14 +44,57 @@ class UserController extends CRUDController private ValidatorInterface $validator; + private FilterOrderHelperFactoryInterface $filterOrderHelperFactory; + public function __construct( LoggerInterface $chillLogger, ValidatorInterface $validator, - UserPasswordEncoderInterface $passwordEncoder + UserPasswordEncoderInterface $passwordEncoder, + FilterOrderHelperFactoryInterface $filterOrderHelperFactory ) { $this->logger = $chillLogger; $this->validator = $validator; $this->passwordEncoder = $passwordEncoder; + $this->filterOrderHelperFactory = $filterOrderHelperFactory; + } + + + // public function index(Request $request) + // { + // dump($request); + + // //$filterOrder = $this->buildFilterOrderHelper('index', $request); + // return parent::indexEntityAction('index', $request); + // } + + // protected function buildFilterOrderHelper($action, $request): FilterOrderHelper + // { + // $filter_order = $this->filterOrderHelperFactory + // ->create(self::class) + // ->addSearchBox(['name']) + // ->build(); + // dump($filter_order); + // return $filter_order; + // } + + protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper + { + return $this->getFilterOrderHelperFactory() + ->create(self::class) + ->addSearchBox(['label']) + ->build(); + } + + protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int + { + if (null === $filterOrder) { + throw new LogicException('filterOrder should not be null'); + } + dump($filterOrder); + $count = parent::countEntities($action, $request, $filterOrder); + + dump($count); + return $count; } /** diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index 46fb7aa29..bab54d56e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -3,6 +3,9 @@ {% block admin_content %}

{{"Users"|trans}}

+ + {{ filter_order|chill_render_filter_order_helper }} + {% for entity in entities %}
diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 950715a2b..faf37b92c 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -286,7 +286,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], 'edit' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillPerson/SocialWork/edit.html.twig', + 'template' => '@ChillPerson/SocialWork/SocialIssue/edit.html.twig', ], ], ], @@ -307,7 +307,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], 'edit' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillPerson/SocialWork/edit.html.twig', + 'template' => '@ChillPerson/SocialWork/SocialAction/edit.html.twig', ], ], ], diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Evaluation/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Evaluation/index.html.twig index 0adc82788..556065e42 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Evaluation/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Evaluation/index.html.twig @@ -5,6 +5,8 @@ {% block table_entities_thead_tr %} {{ 'Id'|trans }} {{ 'Title'|trans }} + {{ 'evaluation.delay'|trans }} + {{ 'evaluation.notificationDelay'|trans }}   {% endblock %} @@ -13,6 +15,32 @@ {{ entity.id }} {{ entity.title|localize_translatable_string }} + + {% if entity.delay is not null %} + {% if entity.delay.d > 0 %} + {{ entity.delay.d }} {{'days'|trans}} + {% endif %} + {% if entity.delay.m > 0 %} + {{ entity.delay.m }} {{'months'|trans}} + {% endif %} + {% if entity.delay.y > 0 %} + {{ entity.delay.y }} {{'years'|trans}} + {% endif %} + {% endif %} + + + {% if entity.notificationDelay is not null %} + {% if entity.notificationDelay.d > 0 %} + {{ entity.notificationDelay.d }} {{'days'|trans}} + {% endif %} + {% if entity.notificationDelay.m > 0 %} + {{ entity.notificationDelay.m }} {{'months'|trans}} + {% endif %} + {% if entity.notificationDelay.y > 0 %} + {{ entity.notificationDelay.y }} {{'years'|trans}} + {% endif %} + {% endif %} +
  • diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig index 3bcff2b11..31db795be 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig @@ -5,6 +5,8 @@ {% block table_entities_thead_tr %} {{ 'Id'|trans }} {{ 'Title'|trans }} + {{ 'Social actions'|trans }} + {{ 'goal.desactivationDate'|trans }}   {% endblock %} @@ -13,6 +15,16 @@ {{ entity.id }} {{ entity.title|localize_translatable_string }} + + {% for sa in entity.socialActions %} + {{ sa.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %} + {% endfor %} + + + {% if entity.desactivationDate is not null %} + {{ entity.desactivationDate|date('Y-m-d') }} + {% endif %} +
    • diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig new file mode 100644 index 000000000..ffad69128 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig @@ -0,0 +1,22 @@ +{% 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 crud_content_form_rows %} + {% for f in form %} + {% if f.vars.name == 'parent' %} + {{ form_row(f, { 'attr':{'disabled':'disabled'}}) }} + {% else %} + {{ form_row(f) }} + {% endif %} + {% endfor %} + {% endblock crud_content_form_rows %} + + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig index 0497ee199..acfce6ee6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig @@ -5,6 +5,9 @@ {% block table_entities_thead_tr %} {{ 'Id'|trans }} {{ 'Title'|trans }} + {{ 'Parent'|trans }} + {{ 'goal.desactivationDate'|trans }} + {{ 'socialAction.defaultNotificationDelay'|trans }}   {% endblock %} @@ -13,6 +16,29 @@ {{ entity.id }} {{ entity.title|localize_translatable_string }} + + {% if entity.parent is not null %} + {{ entity.parent.title|localize_translatable_string }} + {% endif %} + + + {% if entity.desactivationDate is not null %} + {{ entity.desactivationDate|date('Y-m-d') }} + {% endif %} + + + {% if entity.defaultNotificationDelay is not null %} + {% if entity.defaultNotificationDelay.d > 0 %} + {{ entity.defaultNotificationDelay.d }} {{'days'|trans}} + {% endif %} + {% if entity.defaultNotificationDelay.m > 0 %} + {{ entity.defaultNotificationDelay.m }} {{'months'|trans}} + {% endif %} + {% if entity.defaultNotificationDelay.y > 0 %} + {{ entity.defaultNotificationDelay.y }} {{'years'|trans}} + {% endif %} + {% endif %} +
      • diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig new file mode 100644 index 000000000..ffad69128 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig @@ -0,0 +1,22 @@ +{% 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 crud_content_form_rows %} + {% for f in form %} + {% if f.vars.name == 'parent' %} + {{ form_row(f, { 'attr':{'disabled':'disabled'}}) }} + {% else %} + {{ form_row(f) }} + {% endif %} + {% endfor %} + {% endblock crud_content_form_rows %} + + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig index 3a08ab850..4682a5464 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig @@ -5,6 +5,8 @@ {% block table_entities_thead_tr %} {{ 'Id'|trans }} {{ 'Title'|trans }} + {{ 'Parent'|trans }} + {{ 'goal.desactivationDate'|trans }}   {% endblock %} @@ -13,6 +15,16 @@ {{ entity.id }} {{ entity.title|localize_translatable_string }} + + {% if entity.parent is not null %} + {{ entity.parent.title|localize_translatable_string }} + {% endif %} + + + {% if entity.desactivationDate is not null %} + {{ entity.desactivationDate|date('Y-m-d') }} + {% endif %} +
        • diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index ea22a2793..9e3409dfc 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -456,6 +456,10 @@ relation: title: Premier membre reverseTitle: Deuxième membre +days: jours +months: mois +years: années + # specific to closing motive closing_motive: any parent: Aucun parent