From a3e43fcaaaf3a888c8758a9a70a60015c0a97bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 30 Sep 2021 23:27:56 +0200 Subject: [PATCH 01/15] [person form] accept sms is not required --- CHANGELOG.md | 4 ++++ src/Bundle/ChillPersonBundle/Form/PersonType.php | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf27b41f2..34302129a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to * [Household editor][UI] Update how household suggestion and addresses are picked; * [AddAddress] Handle address suggestion; +* [Person form] "accept sms" not required: + + https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/37 + https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/221 ## Test release yyyy-mm-dd diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 376310965..8bc982713 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -129,8 +129,7 @@ class PersonType extends AbstractType $builder ->add('mobilenumber', TelType::class, array('required' => false)) ->add('acceptSMS', CheckboxType::class, array( - 'value' => false, - 'required' => true + 'required' => false )); } From 0d5d4b3f0582a69d09dd966731e8c1430a1cc9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 1 Oct 2021 09:50:13 +0200 Subject: [PATCH 02/15] add accompanying period where the person is requestor + badge in results --- .../Entity/AccompanyingPeriod.php | 2 +- .../AccompanyingPeriodParticipation.php | 39 ++++---- .../ChillPersonBundle/Entity/Person.php | 94 ++++++++++++++++++- .../views/Person/list_with_period.html.twig | 40 ++++---- .../translations/messages+intl-icu.fr.yaml | 7 ++ .../translations/messages.fr.yml | 1 - 6 files changed, 145 insertions(+), 38 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 14fb26f1a..c71136d88 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -213,7 +213,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface private $scopes; /** - * @ORM\ManyToOne(targetEntity=Person::class) + * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodRequested") * @ORM\JoinColumn(nullable=true) */ private $requestorPerson; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php index 70c5a0505..c873e527a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php @@ -47,86 +47,91 @@ class AccompanyingPeriodParticipation * @Groups({"read"}) */ private $id; - + /** * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations") * @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) * @Groups({"read"}) */ private $person; - + /** * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"}) * @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false) */ private $accompanyingPeriod; - + /** * @ORM\Column(type="date", nullable=false) * @Groups({"read"}) */ private $startDate; - + /** * @ORM\Column(type="date", nullable=true) * @Groups({"read"}) */ private $endDate = null; - + public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person) { $this->startDate = new \DateTimeImmutable('now'); $this->accompanyingPeriod = $accompanyingPeriod; $this->person = $person; } - + public function getId(): ?int { return $this->id; } - + public function getPerson(): ?Person { return $this->person; } - + public function setPerson(?Person $person): self { $this->person = $person; - + return $this; } - + public function getAccompanyingPeriod(): ?AccompanyingPeriod { return $this->accompanyingPeriod; } - + public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self { $this->accompanyingPeriod = $accompanyingPeriod; - + return $this; } - + public function getStartDate(): ?\DateTimeInterface { return $this->startDate; } - + /* * public function setStartDate(\DateTimeInterface $startDate): self { $this->startDate = $startDate; return $this; } */ - + public function getEndDate(): ?\DateTimeInterface { return $this->endDate; } - + public function setEndDate(?\DateTimeInterface $endDate): self { $this->endDate = $endDate; - + return $this; } + + public function isOpen(): bool + { + return $this->endDate === null; + } } diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 69429219f..9aaad8c04 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -28,9 +28,9 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\MaritalStatus; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\Address; @@ -329,6 +329,15 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI */ private $accompanyingPeriodParticipations; + /** + * The accompanying period requested by the Person + * + * @ORM\OneToMany(targetEntity=AccompanyingPeriod::class, + * mappedBy="requestorPerson") + * @var Collection|AccompanyingPeriod[] + */ + private Collection $accompanyingPeriodRequested; + /** * A remark over the person * @var string @@ -478,6 +487,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI $this->genderComment = new CommentEmbeddable(); $this->maritalStatusComment = new CommentEmbeddable(); $this->periodLocatedOn = new ArrayCollection(); + $this->accompanyingPeriodRequested = new ArrayCollection(); } /** @@ -605,6 +615,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * Get AccompanyingPeriodParticipations Collection + * + * @return AccompanyingPeriodParticipation[]|Collection */ public function getAccompanyingPeriodParticipations(): Collection { @@ -614,6 +626,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * Return a collection of participation, where the participation * is still opened, not a draft, and the period is still opened + * + * @return AccompanyingPeriodParticipation[]|Collection */ public function getOpenedParticipations(): Collection { @@ -1650,6 +1664,84 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this; } + /** + * @return AccompanyingPeriod[]|Collection + */ + public function getAccompanyingPeriodRequested(): Collection + { + return $this->accompanyingPeriodRequested; + } + + /** + * Return a list of all accompanying period where the person is involved: + * + * * as requestor; + * * as participant, only for opened participation; + * + * @param bool $asParticipantOpen add participation which are still opened + * @param bool $asRequestor add accompanying period where the person is requestor + * @return AccompanyingPeriod[]|Collection + */ + public function getAccompanyingPeriodInvolved( + bool $asParticipantOpen = true, + bool $asRequestor = true + ): Collection + { + $result = new ArrayCollection(); + + if ($asParticipantOpen) { + foreach ($this->getOpenedParticipations() + ->map(fn (AccompanyingPeriodParticipation $app) => + $app->getAccompanyingPeriod()) + as $period + ) { + if (!$result->contains($period)) { + $result->add($period); + } + } + } + + if ($asRequestor) { + foreach ($this->accompanyingPeriodRequested as $period) { + if (!$result->contains($period)) { + $result->add($period); + } + } + } + + return $result; + } + + /** + * Handy method to get the AccompanyingPeriodParticipation + * matching a given AccompanyingPeriod. + * + * Used in template, to find the participation when iterating on a list + * of period. + * + * @param \Chill\PersonBundle\Entity\AccompanyingPeriod $period + * @return AccompanyingPeriodParticipation + */ + public function findParticipationForPeriod(AccompanyingPeriod $period): ?AccompanyingPeriodParticipation + { + $closeCandidates = []; + + foreach ($this->getAccompanyingPeriodParticipations() as $participation) { + if ($participation->getAccompanyingPeriod() === $period) { + if ($participation->isOpen()) { + return $participation; + } + $closeCandidates[] = $participation; + } + } + + if (0 < count($closeCandidates)) { + return $closeCandidates[0]; + } + + return null; + } + public function getCreatedBy(): ?User { return $this->createdBy; 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 f586d7ac0..2fd1de9c1 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 @@ -59,47 +59,51 @@ 'customButtons': { 'after': _self.button_person(person) } }) }} - {#- 'apps' is for AccompanyingPeriodParticipationS #} - {%- set apps = [] %} - {%- for app in person.openedParticipations %} - {%- if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', app.accompanyingPeriod) %} - {%- set apps = apps|merge([app]) %} + {#- 'acps' is for AcCompanyingPeriodS #} + {%- set acps = [] %} + {%- for acp in person.accompanyingPeriodInvolved %} + {%- if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', acp) %} + {%- set acps = acps|merge([acp]) %} {%- endif %} {%- endfor %} - {% if apps|length > 0 %} + {# add as requestor #} + + {% if acps|length > 0 %}
- {% for app in apps %} + {% for acp in acps %} + {% set app = person.findParticipationForPeriod(acp) %}
- {{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }} + {% if acp.requestorPerson == person %} + + {{ 'Requestor'|trans({'gender': person.gender}) }} + + {% endif %} + {% if app != null %} + {{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }} + {% endif %}
- {% if app.accompanyingPeriod.user is not null %} + {% if acp.user is not null %}
ref: - {{ app.accompanyingPeriod.user|chill_entity_render_box }} + {{ acp.user|chill_entity_render_box }}
{% endif %}
- {% for issue in app.accompanyingPeriod.socialIssues %} + {% for issue in acp.socialIssues %} {{ issue|chill_entity_render_box }} {% endfor %} - {# ^^ display all socialIssues, or slice vv - |slice(0,2) - {% if app.accompanyingPeriod.socialIssues|length > 2 %} - {{ 'and %number% other'|transchoice(app.accompanyingPeriod.socialIssues|length-2) }} - {% endif %} - #}
  • - diff --git a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml index cea908ccf..32ce0ff45 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml +++ b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml @@ -5,6 +5,13 @@ Born the date: >- other {Né·e le {birthdate}} } +Requestor: >- + {gender, select, + man {Demandeur} + woman {Demandeuse} + other {Demandeur·euse} + } + household: Household: Ménage Household number: Ménage {household_num} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 8b6b6db58..2e0f518be 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -189,7 +189,6 @@ Create an accompanying course: Créer un parcours This accompanying course is still a draft: Ce parcours est à l'état brouillon Associated peoples: Usagers concernés Resources: Interlocuteurs privilégiés -Requestor: Demandeur Any requestor to this accompanying course: Aucun demandeur pour ce parcours Social actions: Actions d'accompagnement Social issues: Problématiques sociales From c42b7c014bacbdb40ce89e2053be4e3d22f0610b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 1 Oct 2021 11:00:25 +0200 Subject: [PATCH 03/15] udpate changelog [ci-skip] --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf27b41f2..f2ad6b2ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,15 @@ and this project adheres to * [Household editor][UI] Update how household suggestion and addresses are picked; * [AddAddress] Handle address suggestion; +* [Person results] Add requestor into search results: + + * a badge "requestor" is shown into search results; + * periods where the person is only requestor (without participating) are also shown; + + Issues: + + * https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/13 + * https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/199 ## Test release yyyy-mm-dd From ad72904aa9af471d6608e895367e9f87932c1722 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 27 Sep 2021 15:12:50 +0200 Subject: [PATCH 04/15] resume accourse: simplify alerts with simple link to edit page --- .../_join_household.html.twig | 49 ++++--------- .../AccompanyingCourse/_still_draft.html.twig | 16 +++++ .../_warning_address.html.twig | 70 +++++-------------- .../views/AccompanyingCourse/index.html.twig | 38 ++++------ .../translations/messages.fr.yml | 2 +- 5 files changed, 59 insertions(+), 116 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_still_draft.html.twig diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig index c57d12f1e..7ef2de466 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig @@ -1,41 +1,16 @@ -
    -
    -
    - {{ 'Some peoples does not belong to any household currently. Add them to an household soon'|trans }} -
    -
      -
    • - -
    • -
    -
    - -
    -
    - -

    {{ 'household.Select people to move'|trans }}

    -
      - {% for p in withoutHousehold %} -
    • - - {{ p|chill_entity_render_box }} -
    • - {% endfor %} -
    - - - - -
      +
      +
      +
      + - -
      +
      + {{ 'Some peoples does not belong to any household currently. Add them to an household soon'|trans }} +
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_still_draft.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_still_draft.html.twig new file mode 100644 index 000000000..8e843e284 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_still_draft.html.twig @@ -0,0 +1,16 @@ +
    +
    + +

    {{ 'This accompanying course is still a draft'|trans }}

    +
    +
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig index 490a91b59..f04a8a376 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig @@ -1,61 +1,23 @@ {%- set countPersonLocation = accompanyingCourse.availablePersonLocation|length -%} -{%- set hasPersonLocation = countPersonLocation|length > 0 -%} -{% macro quickLocationForm(accompanyingCourse, person, whichButton) %} -
    - - - {% if whichButton == 'string' %} - - {% elseif whichButton == 'icon' %} - - {% endif %} -
    -{% endmacro %} -
    -
    -
    - {{ 'This course is located at a temporarily address. You should locate this course to an user'|trans }} - {% if not hasPersonLocation %} - {{ 'Associate at least one member with an household, and set an address to this household'|trans }} - {% endif %} -
    - - {% if 1 == countPersonLocation %} +{%- set hasPersonLocation = countPersonLocation > 0 -%} +
    +
    +
    • - {{ _self.quickLocationForm(accompanyingCourse, accompanyingCourse.availablePersonLocation.first, 'string') }} + + + Corriger +
    - {% elseif 1 < countPersonLocation %} -
      -
    • - -
    • -
    - {% endif %} -
    - - {% if 1 < countPersonLocation %} -
    -

    {{ 'Locate by'|trans }}:

    - -
    - {% for p in accompanyingCourse.availablePersonLocation %} -
    - {{ p|chill_entity_render_box({ - 'render': 'bloc', 'addLink': false, 'addInfo': true, 'addAltNames': false, 'customButtons': { - 'replace': _self.quickLocationForm(accompanyingCourse, p, 'icon') - } - }) }} -
    - {% endfor %} -
    - {% endif %} +

    + {{ 'This course is located at a temporarily address. You should locate this course to an user'|trans }}

    + {% if not hasPersonLocation %} +

    + {{ 'Associate at least one member with an household, and set an address to this household'|trans }}

    + {% endif %} +
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig index be66abe73..a063fbb34 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig @@ -23,20 +23,22 @@ {% block content %}
    - {% if 'DRAFT' == accompanyingCourse.step %} -
    - - {{ 'This accompanying course is still a draft'|trans }} - - {{ 'Edit & activate accompanying course'|trans }} - - -
    - {% endif %} -
    WIP .. AccompanyingCourse Resume dashboard
    - {# + {% if 'DRAFT' == accompanyingCourse.step %} + {% include '@ChillPerson/AccompanyingCourse/_still_draft.html.twig' %} + {% endif %} + {% if 'DRAFT' != accompanyingCourse.step %} + {% if withoutHousehold|length > 0 %} + {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' %} + {% endif %} + {% endif %} + {% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %} + {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' %} + {% endif %} + + + {# DISABLED

    {{ 'Resume Accompanying Course'|trans }}

    @@ -53,13 +55,6 @@ {% endif %} {% endfor %}
    - #} - {% if 'DRAFT' != accompanyingCourse.step %} - {% if withoutHousehold|length > 0 %} - {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %} - {% endif %} - {% endif %} - {#
    @@ -80,11 +75,6 @@
    {% endif %} - #} - {% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %} - {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' with {} %} - {% endif %} - {#
    diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 8b6b6db58..f8c1207ee 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -186,7 +186,7 @@ No accompanying user: Aucun accompagnant No data given: Pas d'information Participants: Personnes impliquées Create an accompanying course: Créer un parcours -This accompanying course is still a draft: Ce parcours est à l'état brouillon +This accompanying course is still a draft: Ce parcours est encore à l'état brouillon. Associated peoples: Usagers concernés Resources: Interlocuteurs privilégiés Requestor: Demandeur From 2a7e3c0334193b326f6a04261907b47e2067b240 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 11:11:12 +0200 Subject: [PATCH 05/15] resume: display associated persons from accourse --- .../AccompanyingCourse/_concerned.html.twig | 13 +++++++ .../views/AccompanyingCourse/index.html.twig | 37 +++++++++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig new file mode 100644 index 000000000..2cfbff27a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig @@ -0,0 +1,13 @@ + + +{% for p in accompanyingCourse.participations %} + + + + {{ p.person|chill_entity_render_box }} + + +{% endfor %} +{{ dump() }} + diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig index a063fbb34..0fb9115eb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig @@ -21,21 +21,44 @@ {% endblock %} {% block content %} -
    +
    -
    WIP .. AccompanyingCourse Resume dashboard
    +
    + {% include '@ChillPerson/AccompanyingCourse/_concerned.html.twig' with {} %} +
    + +
    + {% if accompanyingCourse.locationStatus == 'person' %} +
    {{ 'This course is located by'|trans }}
    +

    {{ accompanyingCourse.personLocation|chill_entity_render_string }}

    + {% elseif accompanyingCourse.locationStatus == 'address' %} +

    {{ 'This course has a temporarily location'|trans }}

    + {% endif %} + + {% if accompanyingCourse.locationStatus != 'none' %} + {{ accompanyingCourse.location|chill_entity_render_box }} + {% endif %} +
    {% if 'DRAFT' == accompanyingCourse.step %} - {% include '@ChillPerson/AccompanyingCourse/_still_draft.html.twig' %} +
    + {% include '@ChillPerson/AccompanyingCourse/_still_draft.html.twig' %} +
    {% endif %} + + {% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %} +
    + {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' %} +
    + {% endif %} + {% if 'DRAFT' != accompanyingCourse.step %} {% if withoutHousehold|length > 0 %} - {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' %} +
    + {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' %} +
    {% endif %} {% endif %} - {% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %} - {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' %} - {% endif %} {# DISABLED From db9a203df054b06a983b2048226719ae333f9f25 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 12:18:40 +0200 Subject: [PATCH 06/15] otf: prepare to create vue root component: moving files --- .../{_components/OnTheFly => OnTheFly/components}/Create.vue | 0 .../vuejs/{_components => OnTheFly/components}/OnTheFly.vue | 2 +- .../components/PersonsAssociated/ParticipationItem.vue | 2 +- .../public/vuejs/AccompanyingCourse/components/Requestor.vue | 2 +- .../AccompanyingCourse/components/Resources/ResourceItem.vue | 2 +- .../Resources/public/vuejs/_components/AddPersons.vue | 2 +- .../public/vuejs/_components/AddPersons/TypePerson.vue | 2 +- .../public/vuejs/_components/AddPersons/TypeThirdParty.vue | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename src/Bundle/ChillMainBundle/Resources/public/vuejs/{_components/OnTheFly => OnTheFly/components}/Create.vue (100%) rename src/Bundle/ChillMainBundle/Resources/public/vuejs/{_components => OnTheFly/components}/OnTheFly.vue (99%) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue rename to src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue similarity index 99% rename from src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue rename to src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index a87940ba3..ee58aa202 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -61,7 +61,7 @@ + diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/i18n.js new file mode 100644 index 000000000..3cba67149 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/i18n.js @@ -0,0 +1,24 @@ +const ontheflyMessages = { + fr: { + onthefly: { + show: { + person: "Détails de l'usager", + thirdparty: "Détails du tiers", + file_person: "Ouvrir la fiche de l'usager", + file_thirdparty: "Voir le Tiers", + }, + edit: { + person: "Modifier un usager", + thirdparty: "Modifier un tiers" + }, + create: { + button: "Créer \"{q}\"", + title: "Création d'un nouvel usager ou d'un tiers professionnel", + person: "un nouvel usager", + thirdparty: "un nouveau tiers professionnel" + }, + } + } +} + +export { ontheflyMessages }; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js new file mode 100644 index 000000000..2b78a569a --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js @@ -0,0 +1,28 @@ +import { createApp } from "vue"; +import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'; +import { ontheflyMessages } from './i18n.js'; +import App from "./App.vue"; + +const i18n = _createI18n( ontheflyMessages ); + +let containers = document.querySelectorAll('.onthefly-container'); + +containers.forEach((container) => { + + const app = createApp({ + template: ``, + data() { + return { + onTheFly: { + context: {}, + options: {} + } + } + } + }) + .use(i18n) + .component('app', App) + .mount(container); + + console.log('container dataset', container.dataset); +}); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js index 5e001a21b..c16b4c65d 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js @@ -53,24 +53,6 @@ const messages = { top: "Haut", bottom: "Bas", }, - onthefly: { - show: { - person: "Détails de l'usager", - thirdparty: "Détails du tiers", - file_person: "Ouvrir la fiche de l'usager", - file_thirdparty: "Voir le Tiers", - }, - edit: { - person: "Modifier un usager", - thirdparty: "Modifier un tiers" - }, - create: { - button: "Créer \"{q}\"", - title: "Création d'un nouvel usager ou d'un tiers professionnel", - person: "un nouvel usager", - thirdparty: "un nouveau tiers professionnel" - }, - }, renderbox: { person: "Usager", birthday: { diff --git a/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig new file mode 100644 index 000000000..f43101bbb --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig @@ -0,0 +1,13 @@ +{# + This Twig template include load vue_onthefly component. + It push all variables from context in OnTheFly/App.vue. + + OPTIONS + * +#} +
    + +{{ encore_entry_script_tags('vue_onthefly') }} +{{ encore_entry_link_tags('vue_onthefly') }} diff --git a/src/Bundle/ChillMainBundle/chill.webpack.config.js b/src/Bundle/ChillMainBundle/chill.webpack.config.js index 7ba42ed97..0204166d0 100644 --- a/src/Bundle/ChillMainBundle/chill.webpack.config.js +++ b/src/Bundle/ChillMainBundle/chill.webpack.config.js @@ -61,5 +61,6 @@ module.exports = function(encore, entries) // Vue entrypoints encore.addEntry('vue_address', __dirname + '/Resources/public/vuejs/Address/index.js'); + encore.addEntry('vue_onthefly', __dirname + '/Resources/public/vuejs/OnTheFly/index.js'); }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index 5d1451ff3..f742a6ea0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -1,6 +1,7 @@ import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'; import { thirdpartyMessages } from 'ChillThirdPartyAssets/vuejs/_js/i18n'; import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n'; +import { ontheflyMessages } from 'ChillMainAssets/vuejs/OnTheFly/i18n'; const appMessages = { fr: { @@ -142,7 +143,7 @@ const appMessages = { } }; -Object.assign(appMessages.fr, personMessages.fr, thirdpartyMessages.fr, addressMessages.fr); +Object.assign(appMessages.fr, personMessages.fr, thirdpartyMessages.fr, addressMessages.fr, ontheflyMessages.fr); export { appMessages From 65782d3a6bab379f66846cc739b653340e16f376 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 13:11:34 +0200 Subject: [PATCH 08/15] fix js syntax --- .../Resources/public/vuejs/OnTheFly/components/OnTheFly.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index ee58aa202..7cfb04651 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -174,10 +174,10 @@ export default { this.modal.showModal = false; }, buildLocation(id, type) { - if (type == 'person') { + if (type === 'person') { // TODO i18n return `/fr/person/${id}/general`; - } else if (type == 'thirdparty') { + } else if (type === 'thirdparty') { return `/fr/thirdparty/thirdparty/${id}/show`; } } From 75348f6ba7e09f3b1bf9a2af1837befe8d07b06b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 14:03:58 +0200 Subject: [PATCH 09/15] otf: add data attributes and pass them in vue component --- .../Resources/public/vuejs/OnTheFly/App.vue | 17 ++++------------- .../Resources/public/vuejs/OnTheFly/index.js | 10 ++++++++-- .../OnTheFly/_insert_vue_onthefly.html.twig | 11 ++++++++++- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue index 0f566f464..ac7d30b36 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue @@ -1,8 +1,9 @@ @@ -22,16 +23,6 @@ export default { }, options() { return this.onTheFly.options; - }, - // temp - action() { - return 'show'; // 'edit', 'create' - }, - type() { - return 'person'; // 'thirdparty' - }, - id() { - return 1613 } }, mounted() { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js index 2b78a569a..46320b091 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js @@ -14,8 +14,14 @@ containers.forEach((container) => { data() { return { onTheFly: { - context: {}, - options: {} + context: { + action: container.dataset.action, + type: container.dataset.targetName, + id: parseInt(container.dataset.targetId), + }, + options: { + buttonText: container.dataset.buttonText || null + } } } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig index f43101bbb..03b4094f7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig @@ -3,10 +3,19 @@ It push all variables from context in OnTheFly/App.vue. OPTIONS - * + * targetEntity { + name: string 'person', 'thirdparty' + id: integer + } + * action 'show', 'edit', 'create' + #}
    {{ encore_entry_script_tags('vue_onthefly') }} From abd60f7ddfccd06052af1e34e0d8e0bb9b104873 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 14:06:15 +0200 Subject: [PATCH 10/15] resume: include _insert_vue_onthefly template --- .../views/AccompanyingCourse/_concerned.html.twig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig index 2cfbff27a..5ff6d5583 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig @@ -1,13 +1,17 @@ - - {% for p in accompanyingCourse.participations %} + + {# - {{ p.person|chill_entity_render_box }} -{% endfor %} -{{ dump() }} + #} + + A + {# include vue_onthefly component #} + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { targetEntity: { name: 'person', id: p.person.id }, action: 'show' } %} + +{% endfor %} From 9ee679a3b3139ccb42a20ebc472758ed63369770 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 14:11:03 +0200 Subject: [PATCH 11/15] fix vue syntax error --- .../ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue index ac7d30b36..63c1ad5bd 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue @@ -13,9 +13,9 @@ import OnTheFly from './components/OnTheFly.vue'; export default { name: "App", - components: [ - 'OnTheFly' - ], + components: { + OnTheFly + }, props: ['onTheFly'], computed: { context() { From fbd17a1de62f60394ef4cddd138ac25f55d87573 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 17:38:19 +0200 Subject: [PATCH 12/15] OnTheFly: adding displayBadge option to replace button by badge When using displayBadge=true, you need to pass buttonText=string with badge content. Limitation: onTheFly cannot use directly PersonRenderBox to display badge, because it don't have person object in props ! --- .../Resources/public/vuejs/OnTheFly/App.vue | 1 + .../vuejs/OnTheFly/components/OnTheFly.vue | 18 ++++++++++--- .../Resources/public/vuejs/OnTheFly/index.js | 5 ++-- .../OnTheFly/_insert_vue_onthefly.html.twig | 27 ++++++++++++++----- .../AccompanyingCourse/_concerned.html.twig | 17 ------------ .../views/AccompanyingCourse/index.html.twig | 12 ++++++++- 6 files changed, 50 insertions(+), 30 deletions(-) delete mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue index 63c1ad5bd..c4c014e19 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue @@ -4,6 +4,7 @@ :id="context.id" :action="context.action" :buttonText="options.buttonText" + :displayBadge="options.displayBadge === 'true'" @saveFormOnTheFly="saveFormOnTheFly"> diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index 7cfb04651..237166e62 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -1,6 +1,11 @@