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 {
name: "ButtonLocation",
components: {
import AddressRenderBox from,
AddressRenderBox,
Modal,
},
props: ['person'],

View File

@ -9,7 +9,8 @@
addAge : false,
hLevel : 3,
}"
:person="participation.person">
:person="participation.person"
:returnPath="getAccompanyingCourseReturnPath">
<template v-slot:record-actions>
<ul class="record_actions">
@ -40,11 +41,17 @@
<li>
<button v-if="!participation.endDate"
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)">
</button>
<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>
</ul>
@ -86,6 +93,9 @@ export default {
return true;
}
return false;
},
getAccompanyingCourseReturnPath() {
return `fr/parcours/${this.$store.state.accompanyingCourse.id}/edit#section-10`;
}
}
}
@ -93,10 +103,7 @@ export default {
/*
* dates of participation
*
* :title="$t('persons_associated.date_start_to_end', {
* start: $d(participation.startDate.datetime, 'short'),
* end: $d(participation.endDate.datetime, 'short')
* })"
*
*
* <tr>
* <td><span v-if="participation.startDate">

View File

@ -42,6 +42,9 @@ const appMessages = {
enddate: "Date de sortie",
add_persons: "Ajouter des usagers",
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: {
title: "Demandeur",

View File

@ -46,6 +46,13 @@
<li v-if="person.current_household_address">
<i class="fa fa-li fa-map-marker"></i>
<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 v-else-if="options.addNoData">
<i class="fa fa-li fa-map-marker"></i>
@ -116,7 +123,7 @@ export default {
components: {
AddressRenderBox
},
props: ['person', 'options', 'render'],
props: ['person', 'options', 'render', 'returnPath'],
computed: {
getGender: function() {
return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
@ -153,6 +160,9 @@ export default {
},
getUrl() {
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;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
@ -61,6 +62,9 @@ class PersonNormalizer implements
public function normalize($person, string $format = null, array $context = array())
{
/** @var Household $household */
$household = $person->getCurrentHousehold();
/** @var Person $person */
return [
'type' => 'person',
@ -76,6 +80,7 @@ class PersonNormalizer implements
'gender' => $person->getGender(),
'gender_numeric' => $person->getGenderNumeric(),
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()),
'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null,
];
}