vue_accourse: adding current_household link on associated_persons

This commit is contained in:
Mathieu Jaumotte 2021-09-06 15:05:08 +02:00
parent 1262d8cc16
commit 93c08f7e18
5 changed files with 37 additions and 12 deletions

View File

@ -33,7 +33,7 @@ import AddressRenderBox from "ChillMainAssets/vuejs/_components/Entity/AddressRe
export default { export default {
name: "ButtonLocation", name: "ButtonLocation",
components: { components: {
import AddressRenderBox from, AddressRenderBox,
Modal, Modal,
}, },
props: ['person'], props: ['person'],

View File

@ -9,7 +9,8 @@
addAge : false, addAge : false,
hLevel : 3, hLevel : 3,
}" }"
:person="participation.person"> :person="participation.person"
:returnPath="getAccompanyingCourseReturnPath">
<template v-slot:record-actions> <template v-slot:record-actions>
<ul class="record_actions"> <ul class="record_actions">
@ -40,11 +41,17 @@
<li> <li>
<button v-if="!participation.endDate" <button v-if="!participation.endDate"
class="btn btn-sm btn-remove" class="btn btn-sm btn-remove"
v-bind:title="$t('action.remove')" v-bind:title="$t('persons_associated.leave_course')"
@click.prevent="$emit('close', participation)"> @click.prevent="$emit('close', participation)">
</button> </button>
<button v-else <button v-else
class="btn btn-sm btn-remove disabled"></button> class="btn btn-sm btn-secondary"
:title="$t('persons_associated.date_start_to_end', {
start: $d(participation.startDate.datetime, 'short'),
end: $d(participation.endDate.datetime, 'short')
})">
<i class="fa fa-fw fa-info"></i>
</button>
</li> </li>
</ul> </ul>
@ -86,6 +93,9 @@ export default {
return true; return true;
} }
return false; return false;
},
getAccompanyingCourseReturnPath() {
return `fr/parcours/${this.$store.state.accompanyingCourse.id}/edit#section-10`;
} }
} }
} }
@ -93,10 +103,7 @@ export default {
/* /*
* dates of participation * dates of participation
* *
* :title="$t('persons_associated.date_start_to_end', { *
* start: $d(participation.startDate.datetime, 'short'),
* end: $d(participation.endDate.datetime, 'short')
* })"
* *
* <tr> * <tr>
* <td><span v-if="participation.startDate"> * <td><span v-if="participation.startDate">

View File

@ -42,6 +42,9 @@ const appMessages = {
enddate: "Date de sortie", enddate: "Date de sortie",
add_persons: "Ajouter des usagers", add_persons: "Ajouter des usagers",
date_start_to_end: "Participation du {start} au {end}", date_start_to_end: "Participation du {start} au {end}",
leave_course: "L'usager quitte le parcours",
show_household_number: "Voir le ménage n° {id}",
show_household: "Voir le ménage"
}, },
requestor: { requestor: {
title: "Demandeur", title: "Demandeur",

View File

@ -44,8 +44,15 @@
<ul class="list-content fa-ul"> <ul class="list-content fa-ul">
<li v-if="person.current_household_address"> <li v-if="person.current_household_address">
<i class="fa fa-li fa-map-marker"></i> <i class="fa fa-li fa-map-marker"></i>
<address-render-box :address="person.current_household_address" :isMultiline="isMultiline"></address-render-box> <address-render-box :address="person.current_household_address" :isMultiline="isMultiline"></address-render-box>
<a :href="getCurrentHouseholdUrl" :title="$t('persons_associated.show_household_number', {id: person.current_household_id})">
<span class="badge rounded-pill bg-chill-beige">
<i class="fa fa-fw fa-home"></i>
<!--{{ $t('persons_associated.show_household') }}-->
</span>
</a>
<br>
</li> </li>
<li v-else-if="options.addNoData"> <li v-else-if="options.addNoData">
<i class="fa fa-li fa-map-marker"></i> <i class="fa fa-li fa-map-marker"></i>
@ -116,7 +123,7 @@ export default {
components: { components: {
AddressRenderBox AddressRenderBox
}, },
props: ['person', 'options', 'render'], props: ['person', 'options', 'render', 'returnPath'],
computed: { computed: {
getGender: function() { getGender: function() {
return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man'; return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
@ -153,6 +160,9 @@ export default {
}, },
getUrl() { getUrl() {
return `/fr/person/${this.person.id}/general`; return `/fr/person/${this.person.id}/general`;
},
getCurrentHouseholdUrl() {
return `/fr/person/household/${this.person.current_household_id}/summary?returnPath=${this.returnPath}`
} }
} }
} }

View File

@ -19,6 +19,7 @@
namespace Chill\PersonBundle\Serializer\Normalizer; namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
@ -61,6 +62,9 @@ class PersonNormalizer implements
public function normalize($person, string $format = null, array $context = array()) public function normalize($person, string $format = null, array $context = array())
{ {
/** @var Household $household */
$household = $person->getCurrentHousehold();
/** @var Person $person */ /** @var Person $person */
return [ return [
'type' => 'person', 'type' => 'person',
@ -76,6 +80,7 @@ class PersonNormalizer implements
'gender' => $person->getGender(), 'gender' => $person->getGender(),
'gender_numeric' => $person->getGenderNumeric(), 'gender_numeric' => $person->getGenderNumeric(),
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()), 'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()),
'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null,
]; ];
} }
@ -89,7 +94,7 @@ class PersonNormalizer implements
return $r; return $r;
} }
public function supportsNormalization($data, string $format = null): bool public function supportsNormalization($data, string $format = null): bool
{ {