diff --git a/CHANGELOG.md b/CHANGELOG.md index 5edb4fd4f..dcd149841 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to * [parcours]: component added to change the opening date of a parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/411) +* [search]: listing of parcours display changed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/410) +* [user]: page with accompanying periods to which is user is referent (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/408) + ## Test releases @@ -24,6 +27,7 @@ and this project adheres to * [person] name suggestions within create person form when person is created departing from a search input (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/377) * [person] Add residential address entity, form and list for each person * [aside_activity]: dynamicUserPickerType used (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/399) +* dispatching list ### test release 2021-01-26 @@ -32,7 +36,6 @@ and this project adheres to * [person]: possibility to add person resources (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/382) * [person ressources]: module added * [parcours] bugfix if deathdate is not defined (eg. for a thirdparty) parcours is still displayed. Gave error before. -* dispatching list ### test release 2022-01-24 diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 1fd6b34f7..4cc917502 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -19,6 +19,12 @@ function loadDynamicPicker(element) { input = element.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'), picked = (isMultiple) ? (JSON.parse(input.value)) : ((input.value === '[]') ? (null) : ([JSON.parse(input.value)])); + if (!isMultiple) { + if (input.value === '[]'){ + input.value = null; + } + } + const app = createApp({ template: 'setSelectKey('user') ->setSelectJsonbMetadata("jsonb_build_object('id', u.id)") - ->setSelectPertinence('GREATEST(SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical), - SIMILARITY(LOWER(UNACCENT(?)), u.emailcanonical))', [$pattern, $pattern]) + ->setSelectPertinence('GREATEST(SIMILARITY(LOWER(UNACCENT(?)), u.label), + SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical))', [$pattern, $pattern]) ->setFromClause('users AS u') - ->setWhereClauses('SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical) > 0.15 - OR - SIMILARITY(LOWER(UNACCENT(?)), u.emailcanonical) > 0.15 - ', [$pattern, $pattern]); + ->setWhereClauses(' + SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical) > 0.15 + OR u.usernamecanonical LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\' + OR SIMILARITY(LOWER(UNACCENT(?)), LOWER(UNACCENT(u.label))) > 0.15 + OR u.label LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\' + ', [$pattern, $pattern, $pattern, $pattern]); return $query; } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php index e5a37c430..bd812e036 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php @@ -55,7 +55,7 @@ class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterfa $user = $this->userRepository->find($object->getUserId()); return [ - 'comment' => (string) $object->getComment(), + 'comment' => $object->getComment(), 'isNull' => false, 'date' => $this->normalizer->normalize($object->getDate(), $format, array_merge($context, [ 'docgen:expects' => DateTime::class, diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index 577a271e8..210b507e5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -148,8 +148,6 @@ final class PersonResourceController extends AbstractController $comment = $form['comment']->getData(); $kind = $form['kind']->getData(); - dump($person); - $personResource->setKind($kind); $personResource->setPerson($person); $personResource->setThirdParty($thirdparty); diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php new file mode 100644 index 000000000..ddaf1b856 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -0,0 +1,50 @@ +accompanyingPeriodRepository = $accompanyingPeriodRepository; + $this->paginatorFactory = $paginatorFactory; + } + + /** + * @Route("/{_locale}/accompanying-periods", name="chill_person_accompanying_period_user") + */ + public function listAction(Request $request) + { + $total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser()]); + $pagination = $this->paginatorFactory->create($total); + $accompanyingPeriods = $this->accompanyingPeriodRepository->findBy(['user' => $this->getUser()], + ['openingDate' => 'DESC'], $pagination->getItemsPerPage(), $pagination->getCurrentPageFirstItemNumber()); + + return $this->render('@ChillPerson/AccompanyingPeriod/user_periods_list.html.twig', [ + 'accompanyingPeriods' => $accompanyingPeriods, + 'pagination' => $pagination, + ]); + + } +} diff --git a/src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php new file mode 100644 index 000000000..3e56b423c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php @@ -0,0 +1,57 @@ +authorizationChecker = $authorizationChecker; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + if ($this->authorizationChecker->isGranted('ROLE_USER')) { + $menu->addChild('My accompanying periods', [ + 'route' => 'chill_person_accompanying_period_user', + ]) + ->setExtras([ + 'order' => 20, + 'icon' => 'tasks', + ]); + } + } + + public static function getMenuIds(): array + { + return ['user']; + } +} diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php index b21431554..9554f2a3b 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php @@ -49,6 +49,11 @@ final class AccompanyingPeriodRepository implements ObjectRepository return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } + public function countBy(array $criteria): int + { + return $this->repository->count($criteria); + } + public function findOneBy(array $criteria): ?AccompanyingPeriod { return $this->findOneBy($criteria); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig new file mode 100644 index 000000000..d30997bac --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig @@ -0,0 +1,30 @@ +{% extends "@ChillMain/layout.html.twig" %} + +{% set activeRouteKey = 'chill_person_accompanying_period_user_list' %} + +{% block title %}{{ 'My accompanying periods'|trans }}{% endblock title %} + +{% macro recordAction(period) %} +
  • + +
  • +{% endmacro %} + + +{% block content %} + +
    +

    {{ 'My accompanying periods'|trans }}

    + +
    + {% for period in accompanyingPeriods %} + {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, 'recordAction': _self.recordAction(period)} %} + {% endfor %} +
    + + {{ chill_pagination(pagination) }} + +
    + +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig index cc83dc6ed..6f107a593 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig @@ -78,16 +78,11 @@ {% set app = person.findParticipationForPeriod(acp) %}
    - -
    @@ -97,28 +92,37 @@ {{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}
    {% endif %} - + {% set notif_counter = chill_count_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod', acp.id) %} {% if notif_counter.total > 0 %} {{ chill_counter_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod', acp.id) }} {% endif %}
    + {% if acp.requestorPerson == person %} + + {{ 'Requestor'|trans({'gender': person.gender}) }} + + {% endif %} {% if acp.emergency %} {{- 'Emergency'|trans|upper -}} {% endif %} - + {% if acp.confidential %} {{- 'Confidential'|trans|upper -}} {% endif %} - + {% if acp.step == 'DRAFT' %} {{ 'course.draft'|trans }} {% endif %} + + {% if acp.step == 'CLOSED' %} + {{ 'course.closed'|trans }} + {% endif %}
    - + {% if acp.user is not null %}
    @@ -131,7 +135,7 @@
    {% endif %} - + {% if acp.socialIssues|length > 0 %}
    @@ -144,24 +148,7 @@
    {% endif %} - - {# ???? - {% if acp.requestorPerson == person %} -
    -
    -

    - -

    -
    -
    - - {{ 'Requestor'|trans({'gender': person.gender}) }} - -
    -
    - {% endif %} - #} - + {% if acp.currentParticipations|length > 1 %}
    @@ -190,7 +177,16 @@
    {% endif %} - + + + {% if (acp.requestorPerson is not null and acp.requestorPerson.id != person.id) or acp.requestorThirdParty is not null %}
    @@ -222,7 +218,7 @@
    {% endif %} - + {% endfor %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig index 5964cef54..820da9179 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -52,9 +52,7 @@ {% if resource.comment.comment is not empty %}
    -
    -
    {{ resource.comment.comment }}
    -
    +
    {{ resource.comment|chill_entity_render_box }}
    {% endif %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index bea29ef58..a2a5121a6 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -558,3 +558,6 @@ household_composition: # docgen Linked evaluations: Évaluations associées + +# Accompanying period per user +My accompanying periods: Mes parcours