Merge remote-tracking branch 'origin/master' into 232_resources_comment

This commit is contained in:
2022-01-10 21:50:00 +01:00
118 changed files with 1735 additions and 498 deletions

View File

@@ -11,8 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Config;
use function count;
/**
* Give help to interact with the config for alt names.
*/
@@ -69,6 +67,6 @@ class ConfigPersonAltNamesHelper
*/
public function hasAltNames(): bool
{
return count($this->config) > 0;
return [] !== $this->config;
}
}

View File

@@ -19,6 +19,7 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepos
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -110,6 +111,60 @@ class AccompanyingCourseController extends Controller
]);
}
/**
* Delete page of Accompanying Course section.
*
* @Route("/{_locale}/parcours/{accompanying_period_id}/delete", name="chill_person_accompanying_course_delete")
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function deleteAction(Request $request, AccompanyingPeriod $accompanyingCourse)
{
$em = $this->getDoctrine()->getManager();
$person_id = $request->query->get('person_id');
$form = $this->createFormBuilder()
->setAction($this->generateUrl('chill_person_accompanying_course_delete', [
'accompanying_period_id' => $accompanyingCourse->getId(),
'person_id' => $person_id,
]))
->setMethod('DELETE')
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
$form->handleRequest($request);
if ($form->isValid()) {
$em->remove($accompanyingCourse);
$em->flush();
$this->addFlash('success', $this->get('translator')
->trans('The accompanying course has been successfully removed.'));
if (null !== $person_id) {
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person_id,
]);
}
return $this->redirectToRoute('chill_main_homepage');
}
}
if (null !== $person_id) {
$view = '@ChillPerson/AccompanyingCourse/confirm_delete_person.html.twig';
} else {
$view = '@ChillPerson/AccompanyingCourse/confirm_delete_accompanying_course.html.twig';
}
return $this->render($view, [
'accompanyingCourse' => $accompanyingCourse,
'person_id' => $person_id,
'delete_form' => $form->createView(),
]);
}
/**
* Edit page of Accompanying Course section.
*
@@ -208,6 +263,9 @@ class AccompanyingCourseController extends Controller
}
}
$userLocation = $this->getUser()->getCurrentLocation();
$period->setAdministrativeLocation($userLocation);
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period);
$em->persist($period);

View File

@@ -14,23 +14,52 @@ namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use function array_filter;
use function array_values;
use function in_array;
class PersonApiController extends ApiController
{
private AuthorizationHelper $authorizationHelper;
public function __construct(AuthorizationHelper $authorizationHelper)
{
private ConfigPersonAltNamesHelper $configPersonAltNameHelper;
public function __construct(
AuthorizationHelper $authorizationHelper,
ConfigPersonAltNamesHelper $configPersonAltNameHelper
) {
$this->authorizationHelper = $authorizationHelper;
$this->configPersonAltNameHelper = $configPersonAltNameHelper;
}
/**
* @Route("/api/1.0/person/config/alt_names.{_format}",
* name="chill_person_config_alt_names",
* requirements={
* "_format": "json"
* }
* )
*/
public function configAltNames(Request $request, string $_format): Response
{
$configAltNamesChoices = $this->configPersonAltNameHelper->getChoices();
return $this->json(
array_map(
static fn (array $data, string $key): array => ['key' => $key, 'labels' => $data],
$configAltNamesChoices,
array_keys($configAltNamesChoices)
),
Response::HTTP_OK,
[],
['groups' => ['read']]
);
}
public function personAddressApi($id, Request $request, string $_format): Response
@@ -51,22 +80,51 @@ class PersonApiController extends ApiController
{
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$addresses = [];
$seenAddressIds = [];
// collect addresses from location in courses
foreach ($person->getAccompanyingPeriodParticipations() as $participation) {
if (null !== $participation->getAccompanyingPeriod()->getAddressLocation()) {
$a = $participation->getAccompanyingPeriod()->getAddressLocation();
$addresses[$a->getId()] = $a;
}
}
$addresses = $person
->getAccompanyingPeriodParticipations()
->filter(
static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool {
return null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation();
}
)
->map(
static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address {
return $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation();
}
)
->filter(
// We remove potential null addresses.
static fn (?Address $address): bool => null !== $address
)
->filter(
static function (Address $address) use (&$seenAddressIds): bool {
$id = $address->getId();
if (in_array($id, $seenAddressIds, true)) {
return false;
}
$seenAddressIds[] = $id;
return true;
}
);
// remove the actual address
$actual = $person->getCurrentHouseholdAddress();
if (null !== $actual) {
$addresses = array_filter($addresses, static fn ($a) => $a !== $actual);
$addresses = $addresses->filter(static fn (Address $address): bool => $address !== $actual);
}
return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]);
return $this->json(
$addresses->getValues(),
Response::HTTP_OK,
[],
['groups' => ['read']]
);
}
}

View File

@@ -17,6 +17,7 @@ use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\MainBundle\Entity\HasScopesInterface;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
@@ -118,6 +119,13 @@ class AccompanyingPeriod implements
*/
private ?Address $addressLocation = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
* @Groups({"read", "write"})
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private ?Location $administrativeLocation = null;
/**
* @var DateTime
*
@@ -507,6 +515,11 @@ class AccompanyingPeriod implements
return $this->addressLocation;
}
public function getAdministrativeLocation(): ?Location
{
return $this->administrativeLocation;
}
/**
* Get a list of person which have an adresse available for a valid location.
*
@@ -980,6 +993,13 @@ class AccompanyingPeriod implements
return $this;
}
public function setAdministrativeLocation(?Location $administrativeLocation): AccompanyingPeriod
{
$this->administrativeLocation = $administrativeLocation;
return $this;
}
/**
* Set closingDate.
*

View File

@@ -39,32 +39,32 @@ class AccompanyingPeriodWorkGoal
/**
* @ORM\ManyToOne(targetEntity=Goal::class)
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private $goal;
private ?Goal $goal = null;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(type="text")
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read"})
*/
private $note;
private ?string $note = null;
/**
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private $results;
private Collection $results;
public function __construct()
{

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* PersonAltName.
@@ -34,6 +35,7 @@ class PersonAltName
* @var string
*
* @ORM\Column(name="key", type="string", length=255)
* @Groups({"write"})
*/
private $key;
@@ -41,6 +43,7 @@ class PersonAltName
* @var string
*
* @ORM\Column(name="label", type="text")
* @Groups({"write"})
*/
private $label;

View File

@@ -28,7 +28,7 @@ class Relation
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;

View File

@@ -254,3 +254,24 @@ abbr.referrer { // still used ?
border: 1px solid black;
padding: 10px;
}
/// Masonry blocs on AccompanyingCourse resume page
div#dashboards {
div.mbloc {
& > div:not(.warnings) {
border: 1px solid $chill-light-gray;
background-color: $chill-llight-gray;
border-radius: 0.35rem;
padding: 1rem;
}
& > div.warnings .alert {
margin-bottom: 0;
}
blockquote.chill-user-quote {
margin: -1.2em;
p {
margin: 0;
}
}
}
}

View File

@@ -8,6 +8,7 @@
<persons-associated></persons-associated>
<course-location></course-location>
<origin-demand></origin-demand>
<admin-location></admin-location>
<requestor v-bind:isAnonymous="accompanyingCourse.requestorAnonymous"></requestor>
<social-issue></social-issue>
<scopes></scopes>
@@ -28,6 +29,7 @@ import { mapGetters, mapState } from 'vuex'
import Banner from './components/Banner.vue';
import StickyNav from './components/StickyNav.vue';
import OriginDemand from './components/OriginDemand.vue';
import AdminLocation from './components/AdminLocation.vue';
import PersonsAssociated from './components/PersonsAssociated.vue';
import Requestor from './components/Requestor.vue';
import SocialIssue from './components/SocialIssue.vue';
@@ -44,6 +46,7 @@ export default {
Banner,
StickyNav,
OriginDemand,
AdminLocation,
PersonsAssociated,
Requestor,
SocialIssue,

View File

@@ -0,0 +1,103 @@
<template>
<div class="vue-component">
<h2><a id="section-40"></a>{{ $t('admin_location.title') }}</h2>
<div class="mb-4">
<label for="selectAdminLocation">
{{ $t('admin_location.title') }}
</label>
<VueMultiselect
name="selectAdminLocation"
label="text"
:custom-label="customLabel"
track-by="id"
:multiple="false"
:searchable="true"
:placeholder="$t('admin_location.placeholder')"
v-model="value"
:options="options"
group-values="locations"
group-label="locationCategories"
@select="updateAdminLocation">
</VueMultiselect>
</div>
<div v-if="!isAdminLocationValid" class="alert alert-warning to-confirm">
{{ $t('admin_location.not_valid') }}
</div>
</div>
</template>
<script>
import VueMultiselect from 'vue-multiselect';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
import { mapState, mapGetters } from 'vuex';
export default {
name: 'AdminLocation',
components: { VueMultiselect },
data() {
return {
options: []
}
},
computed: {
...mapState({
value: state => state.accompanyingCourse.administrativeLocation,
}),
...mapGetters([
'isAdminLocationValid'
])
},
mounted() {
this.getOptions();
},
methods: {
getOptions() {
const url = `/api/1.0/main/location.json`;
makeFetch('GET', url)
.then(response => {
let options = response.results;
let uniqueLocationTypeId = [...new Set(options.map(o => o.locationType.id))];
let results = [];
for (let id of uniqueLocationTypeId) {
results.push({
locationCategories: options.filter(o => o.locationType.id === id)[0].locationType.title.fr,
locations: options.filter(o => o.locationType.id === id)
})
}
this.options = results;
return response;
})
.catch((error) => {
this.$toast.open({message: error.txt})
})
},
updateAdminLocation(value) {
this.$store.dispatch('updateAdminLocation', value)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
},
customLabel(value) {
return value.locationType
? value.name
? `${value.name} (${value.locationType.title.fr})`
: value.locationType.title.fr
: '';
},
}
}
</script>
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
<style lang="css" scoped>
label {
display: none;
}
</style>

View File

@@ -1,9 +1,9 @@
<template>
<span v-for="h in personsByHousehold()" :class="{ 'household': householdExists(h.id), 'no-household': !householdExists(h.id) }">
<span v-for="h in personsByHousehold()" :class="{ 'household': householdExists(h.id), 'no-household': !householdExists(h.id) }" :key="h.id">
<a v-if="householdExists(h.id)" :href="householdLink(h.id)">
<i class="fa fa-home fa-fw text-light" :title="$t('persons_associated.show_household_number', { id: h.id })"></i>
</a>
<span v-for="person in h.persons" class="me-1">
<span v-for="person in h.persons" class="me-1" :key="person.id">
<on-the-fly :type="person.type" :id="person.id" :buttonText="person.text" :displayBadge="'true' === 'true'" action="show"></on-the-fly>
</span>
</span>

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-90"></a>{{ $t('comment.title') }}</h2>
<h2><a id="section-100"></a>{{ $t('comment.title') }}</h2>
<!--div class="error flash_message" v-if="errors.length > 0">
{{ errors[0] }}

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-100"></a>
<h2><a id="section-110"></a>
{{ $t('confirm.title') }}
</h2>
<div>
@@ -24,6 +24,11 @@
{{ $t('confirm.ok') }}
</button>
</li>
<li>
<a class="btn btn-delete" :href="deleteLink">
{{ $t('confirm.delete') }}
</a>
</li>
</ul>
</div>
@@ -37,6 +42,11 @@
{{ $t('confirm.ok') }}
</button>
</li>
<li>
<a class="btn btn-delete" :href="deleteLink">
{{ $t('confirm.delete') }}
</a>
</li>
</ul>
</div>
@@ -89,13 +99,17 @@ export default {
msg: 'confirm.origin_not_valid',
anchor: '#section-30'
},
adminLocation: {
msg: 'confirm.adminLocation_not_valid',
anchor: '#section-40'
},
socialIssue: {
msg: 'confirm.socialIssue_not_valid',
anchor: '#section-50'
anchor: '#section-60'
},
scopes: {
msg: 'confirm.set_a_scope',
anchor: '#section-60'
anchor: '#section-70'
}
}
}
@@ -108,10 +122,14 @@ export default {
'isParticipationValid',
'isSocialIssueValid',
'isOriginValid',
'isAdminLocationValid',
'isLocationValid',
'validationKeys',
'isValidToBeConfirmed'
])
]),
deleteLink() {
return `/fr/parcours/${this.accompanyingCourse.id}/delete`; //TODO locale
},
},
methods: {
confirmCourse() {

View File

@@ -4,7 +4,7 @@
{{ $t('courselocation.title') }}
</h2>
<div v-for="error in displayErrors" class="alert alert-danger my-2">
<div v-for="error in displayErrors" class="alert alert-danger my-2" :key="error">
{{ error }}
</div>

View File

@@ -4,7 +4,7 @@
<div class="mb-4">
<label for="selectOrigin">
{{ $t('origin.label.fr') }}
{{ $t('origin.title') }}
</label>
<VueMultiselect
@@ -17,6 +17,9 @@
:placeholder="$t('origin.placeholder')"
v-model="value"
:options="options"
:select-label="$t('multiselect.select_label')"
:deselect-label="$t('multiselect.deselect_label')"
:selected-label="$t('multiselect.selected_label')"
@select="updateOrigin">
</VueMultiselect>
</div>

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-70"></a>{{ $t('referrer.title') }}</h2>
<h2><a id="section-80"></a>{{ $t('referrer.title') }}</h2>
<div>
<label class="col-form-label" for="selectReferrer">
@@ -11,17 +11,20 @@
name="selectReferrer"
label="text"
track-by="id"
v-bind:multiple="false"
v-bind:searchable="true"
v-bind:placeholder="$t('referrer.placeholder')"
:multiple="false"
:searchable="true"
:placeholder="$t('referrer.placeholder')"
v-model="value"
v-bind:options="users"
:select-label="$t('multiselect.select_label')"
:deselect-label="$t('multiselect.deselect_label')"
:selected-label="$t('multiselect.selected_label')"
@select="updateReferrer">
</VueMultiselect>
<template v-if="referrersSuggested.length > 0">
<ul class="list-suggest add-items inline">
<li v-for="u in referrersSuggested" @click="updateReferrer(u)">
<li v-for="(u, i) in referrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
<span>
<user-render-box-badge :user="u"></user-render-box-badge>
</span>

View File

@@ -1,7 +1,7 @@
<template>
<div class="vue-component">
<h2><a id="section-40"></a>{{ $t('requestor.title') }}</h2>
<h2><a id="section-50"></a>{{ $t('requestor.title') }}</h2>
<div v-if="accompanyingCourse.requestor && isAnonymous" class="flex-table">

View File

@@ -1,7 +1,7 @@
<template>
<div class="vue-component">
<h2><a id="section-80"></a>{{ $t('resources.title')}}</h2>
<h2><a id="section-90"></a>{{ $t('resources.title')}}</h2>
<div v-if="resources.length > 0">
<label class="col-form-label">{{ $tc('resources.counter', counter) }}</label>

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-60"></a>{{ $t('scopes.title') }}</h2>
<h2><a id="section-70"></a>{{ $t('scopes.title') }}</h2>
<div class="mb-4">
<div class="form-check" v-for="s in scopes" :key="s.id">

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-50"></a>{{ $t('social_issue.title') }}</h2>
<h2><a id="section-60"></a>{{ $t('social_issue.title') }}</h2>
<div class="my-4">
<!--label for="field">{{ $t('social_issue.label') }}</label

View File

@@ -37,6 +37,12 @@ const appMessages = {
placeholder: "Renseignez l'origine de la demande",
not_valid: "Indiquez une origine à la demande",
},
admin_location: {
title: "Localisation administrative",
label: "Localisation administrative",
placeholder: "Renseignez la localisation administrative",
not_valid: "Indiquez une localisation administrative",
},
persons_associated: {
title: "Usagers concernés",
counter: "Il n'y a pas encore d'usagers | 1 usager | {count} usagers",
@@ -127,10 +133,12 @@ const appMessages = {
socialIssue_not_valid: "sélectionnez au minimum une problématique sociale",
location_not_valid: "indiquez au minimum une localisation temporaire du parcours",
origin_not_valid: "Indiquez une origine à la demande",
adminLocation_not_valid: "Indiquez une localisation administrative à la demande",
set_a_scope: "indiquez au moins un service",
sure: "Êtes-vous sûr ?",
sure_description: "Une fois le changement confirmé, il ne sera plus possible de le remettre à l'état de brouillon !",
ok: "Confirmer le parcours"
ok: "Confirmer le parcours",
delete: "Supprimer le parcours"
},
// catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",

View File

@@ -49,6 +49,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
isOriginValid(state) {
return state.accompanyingCourse.origin !== null;
},
isAdminLocationValid(state) {
return state.accompanyingCourse.administrativeLocation !== null;
},
isLocationValid(state) {
return state.accompanyingCourse.location !== null;
},
@@ -62,6 +65,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
if (!getters.isLocationValid) { keys.push('location'); }
if (!getters.isSocialIssueValid) { keys.push('socialIssue'); }
if (!getters.isOriginValid) { keys.push('origin'); }
if (!getters.isAdminLocationValid) { keys.push('adminLocation'); }
if (!getters.isScopeValid) { keys.push('scopes'); }
//console.log('getter keys', keys);
return keys;
@@ -177,6 +181,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
//console.log('value', value);
state.accompanyingCourse.origin = value;
},
updateAdminLocation(state, value) {
state.accompanyingCourse.administrativeLocation = value;
},
updateReferrer(state, value) {
//console.log('value', value);
state.accompanyingCourse.user = value;
@@ -624,6 +631,19 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
throw error;
})
},
updateAdminLocation({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`
const body = { type: "accompanying_period", administrativeLocation: { id: payload.id, type: payload.type }}
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateAdminLocation', response.administrativeLocation);
})
.catch((error) => {
commit('catchError', error);
throw error;
})
},
updateReferrer({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`
const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }}

View File

@@ -7,7 +7,7 @@
<div id="picking">
<p>{{ $t('pick_social_issue_linked_with_action') }}</p>
<div v-for="si in socialIssues">
<div v-for="si in socialIssues" :key="si.id">
<input type="radio" v-bind:value="si.id" name="socialIssue" v-model="socialIssuePicked"><span class="badge bg-chill-l-gray text-dark">{{ si.text }}</span>
</div>
<div class="my-3">

View File

@@ -2,6 +2,7 @@
<ol class="breadcrumb">
<li
v-for="s in steps"
:key="s"
class="breadcrumb-item" :class="{ active: step === s }"
>
{{ $t('household_members_editor.app.steps.'+s) }}

View File

@@ -33,7 +33,7 @@ const fetchHouseholdSuggestionByAccompanyingPeriod = (personId) => {
throw Error ({m: 'Error while fetching household suggestion', status: response.status});
}).then(data => Promise.resolve(data.results))
.catch(e => console.err(e));
.catch(e => console.error(e));
;
};

View File

@@ -9,7 +9,7 @@
<div v-else>
<p>
{{ $t('household_members_editor.concerned.persons_will_be_moved') }}&nbsp;:
<span v-for="c in concerned">
<span v-for="c in concerned" :key="c.person.id">
<person-render-box render="badge" :options="{addLink: false}" :person="c.person"></person-render-box>
<button class="btn" @click="removePerson(c.person)" v-if="c.allowRemove" style="padding-left:0;">
<span class="fa-stack fa-lg" :title="$t('household_members_editor.concerned.remove_concerned')">
@@ -19,6 +19,17 @@
</button>
</span>
</p>
<div class="alert alert-info" v-if="concernedPersonsWithHouseholds.length > 0">
<p>{{ $t('household_members_editor.concerned.persons_with_household') }}</p>
<ul v-for="c in concernedPersonsWithHouseholds" :key="c.person.id">
<li>
{{ c.person.text }}
{{ $t('household_members_editor.concerned.already_belongs_to_household') }}
<a target="_blank" :href="this.makeHouseholdLink(c.person.current_household_id)">{{c.person.current_household_id}}</a>.
</li>
</ul>
</div>
</div>
<ul class="record_actions">
@@ -59,7 +70,7 @@ export default {
},
computed: {
...mapState([
'concerned'
'concerned', 'household'
]),
...mapGetters([
'persons',
@@ -67,6 +78,15 @@ export default {
noPerson () {
return this.$store.getters.persons.length === 0;
},
concernedPersonsWithHouseholds () {
if (this.$store.state.household) {
return this.$store.state.concerned.filter(c =>
c.person.current_household_id !== null && c.person.current_household_id !== this.$store.state.household.id
)
} else {
return [];
}
}
},
data() {
return {
@@ -92,6 +112,9 @@ export default {
console.log('remove person in concerned', person);
this.$store.dispatch('removePerson', person);
},
makeHouseholdLink(id) {
return `/fr/person/household/${id}/summary`
}
}
}
</script>

View File

@@ -8,10 +8,10 @@
</p>
<ul>
<li v-for="(msg, index) in warnings" class="warning">
<li v-for="(msg, i) in warnings" class="warning" :key="i">
{{ $t(msg.m, msg.a) }}
</li>
<li v-for="msg in errors" class="error">
<li v-for="(msg, i) in errors" class="error" :key="i">
{{ msg }}
</li>
</ul>

View File

@@ -39,7 +39,7 @@
aria-labelledby="heading_household_suggestions" data-bs-parent="#householdSuggestions">
<div v-if="showHouseholdSuggestion">
<div class="flex-table householdSuggestionList">
<div v-for="s in getSuggestions" class="item-bloc">
<div v-for="(s, i) in getSuggestions" class="item-bloc" :key="`householdSuggestions-${i}`">
<household-render-box :household="s.household"></household-render-box>
<ul class="record_actions">
<li>

View File

@@ -2,11 +2,11 @@
<current-household></current-household>
<ul class="record_actions">
<li v-if="!hasHouseholdAddress && !isHouseholdForceAddress">
<!-- <li v-if="!hasHouseholdAddress && !isHouseholdForceAddress">
<button class="btn btn-misc" @click="markNoAddress">
{{ $t('household_members_editor.household_address.mark_no_address') }}
</button>
</li>
</li> -->
<li v-if="!hasHouseholdAddress">
<add-address
:context="getAddressContext"

View File

@@ -24,7 +24,8 @@
</button>
</div>
<div
v-for="position in positions"
v-for="(position, i) in positions"
:key="`position-${i}`"
class="position"
>
<button

View File

@@ -1,3 +1,4 @@
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
import { ontheflyMessages } from 'ChillMainAssets/vuejs/OnTheFly/i18n';
import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n';
@@ -35,7 +36,7 @@ const appMessages = {
create_new_address: "Créer une nouvelle adresse",
},
concerned: {
title: "Usagers déplacés",
title: "Usager(s) à (re)positionner dans un ménage",
persons_will_be_moved: "Les usagers suivants vont être déplacés",
add_at_least_onePerson: "Indiquez au moins un usager à déplacer",
remove_concerned: "Ne plus transférer",
@@ -45,6 +46,8 @@ const appMessages = {
move_to: "Déplacer vers",
persons_leaving: "Usagers quittant leurs ménages",
no_person_in_position: "Aucun usager ne sera ajouté à cette position",
persons_with_household: "Les usagers suivants sont associés à ces ménages:",
already_belongs_to_household: "est associé au ménage"
},
positioning: {
persons_to_positionnate: 'Usagers à positionner',

View File

@@ -224,18 +224,21 @@ const store = createStore({
}
state.concerned.forEach((c, index) => {
let m = {
id: index * -1,
person: c.person,
holder: c.holder,
position: c.position,
};
if (c.position === null) {
m.position = {
ordering: 999999
if (!(h.members.map((m) => m.person.id)).includes(c.person.id)) {
let m = {
id: index * -1,
person: c.person,
holder: c.holder,
position: c.position,
};
if (c.position === null) {
m.position = {
ordering: 999999
}
}
h.new_members.push(m);
}
h.new_members.push(m);
})
console.log('fake household', h);
@@ -307,7 +310,7 @@ const store = createStore({
comment: "",
});
} else {
console.err("person already included");
console.error("person already included");
}
},
markPosition(state, { person_id, position_id}) {
@@ -533,10 +536,14 @@ const store = createStore({
// nothing to do anymore here, bye-bye !
let params = new URLSearchParams(window.location.search);
if (params.has('returnPath')) {
window.location.replace(params.get('returnPath'));
} else {
if (params.has('followAfter')) {
window.location.replace(`/fr/person/household/${household_id}/summary`);
} else {
if (params.has('returnPath')) {
window.location.replace(params.get('returnPath'));
} else {
window.location.replace(`/fr/person/household/${household_id}/summary`);
}
}
} else {
// we assume the answer was 422...

View File

@@ -23,7 +23,7 @@
<div class="my-4 legend">
<h3>{{ $t('visgraph.Legend') }}</h3>
<div class="list-group">
<label class="list-group-item" v-for="layer in legendLayers">
<label class="list-group-item" v-for="(layer, i) in legendLayers" :key="`layer-${i}`">
<input
class="form-check-input me-1"
type="checkbox"

View File

@@ -10,6 +10,13 @@ const getPerson = (id) => {
});
};
const getPersonAltNames = () =>
fetch('/api/1.0/person/config/alt_names.json').then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});;
/*
* POST a new person
*/
@@ -48,6 +55,7 @@ const patchPerson = (id, body) => {
export {
getPerson,
getPersonAltNames,
postPerson,
patchPerson
};

View File

@@ -21,14 +21,19 @@
<div v-else-if="action === 'edit' || action === 'create'">
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="lastname" v-model="lastName" v-bind:placeholder="$t('person.lastname')" />
<label for="lastname">{{ $t('person.lastname') }}</label>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="firstname" v-model="firstName" v-bind:placeholder="$t('person.firstname')" />
<label for="firstname">{{ $t('person.firstname') }}</label>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="lastname" v-model="lastName" v-bind:placeholder="$t('person.lastname')" />
<label for="lastname">{{ $t('person.lastname') }}</label>
<div v-for="(a) in config.altNames" :key="a.key" class="form-floating mb-3">
<input class="form-control form-control-lg" :id="a.key" @input="onAltNameInput" />
<label :for="a.key">{{ a.labels.fr }}</label>
</div>
<!-- TODO fix placeholder if undefined
@@ -71,11 +76,20 @@
aria-describedby="mobilenumber" />
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="email"><i class="fa fa-fw fa-at"></i></span>
<input class="form-control form-control-lg"
v-model="email"
v-bind:placeholder="$t('person.email')"
v-bind:aria-label="$t('person.email')"
aria-describedby="email" />
</div>
</div>
</template>
<script>
import { getPerson } from '../../_api/OnTheFly';
import { getPerson, getPersonAltNames } from '../../_api/OnTheFly';
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
export default {
@@ -88,13 +102,19 @@ export default {
data() {
return {
person: {
type: 'person'
}
type: 'person',
altNames: []
},
config: {
altNames: []
},
}
},
computed: {
firstName: {
set(value) { this.person.firstName = value; },
set(value) {
this.person.firstName = value;
},
get() { return this.person.firstName; }
},
lastName: {
@@ -125,6 +145,10 @@ export default {
set(value) { this.person.mobilenumber = value; },
get() { return this.person.mobilenumber; }
},
email: {
set(value) { this.person.email = value; },
get() { return this.person.email; }
},
genderClass() {
switch (this.person.gender) {
case 'woman':
@@ -150,6 +174,10 @@ export default {
}
},
mounted() {
getPersonAltNames()
.then(altNames => {
this.config.altNames = altNames;
});
if (this.action !== 'create') {
this.loadData();
}
@@ -162,7 +190,16 @@ export default {
console.log('get person', this.person);
resolve();
}));
}
},
onAltNameInput(event) {
const key = event.target.id;
const label = event.target.value;
let updateAltNames = this.person.altNames.filter((a) => a.key !== key);
updateAltNames.push(
{'key': key, 'label': label}
)
this.person.altNames = updateAltNames;
},
}
}
</script>

View File

@@ -30,6 +30,7 @@ const personMessages = {
phonenumber: "Téléphone",
mobilenumber: "Mobile",
altnames: "Autres noms",
email: "Courriel",
gender: {
title: "Genre",
placeholder: "Choisissez le genre de l'usager",

View File

@@ -0,0 +1,31 @@
{% macro insert_onthefly(type, entity) %}
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
action: 'show', displayBadge: true,
targetEntity: { name: type, id: entity.id },
buttonText: entity|chill_entity_render_string
} %}
{% endmacro %}
<div>
{% if accompanyingCourse.participations is not empty %}
<div class="col mb-4">
<h4 class="item-key">{{ 'Persons associated'|trans }}</h4>
{% for r in accompanyingCourse.participations %}
{{ _self.insert_onthefly('person', r.person) }}
{% endfor %}
</div>
{% endif %}
{% if accompanyingCourse.socialIssues is not empty %}
<div class="col mb-4">
<h4 class="item-key">{{ 'Social issues'|trans }}</h4>
{% for s in accompanyingCourse.socialIssues %}
{{ s|chill_entity_render_box }}
{% endfor %}
</div>
{% endif %}
</div>

View File

@@ -0,0 +1,18 @@
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
{% block title %}{{ 'Delete accompanying period'|trans }}{% endblock %}
{% block content %}
{% include '@ChillPerson/AccompanyingCourse/_confirm_delete.html.twig' %}
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'Delete accompanying period'|trans,
'confirm_question' : 'Are you sure you want to remove the accompanying period "%id%" ?'|trans({ '%id%' : accompanyingCourse.id } ),
'cancel_route' : 'chill_person_accompanying_course_edit',
'cancel_parameters' : {'accompanying_period_id' : accompanyingCourse.id},
'form' : delete_form
} ) }}
{% endblock %}

View File

@@ -0,0 +1,18 @@
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
{% block title %}{{ 'Delete accompanying period'|trans }}{% endblock %}
{% block content %}
{% include '@ChillPerson/AccompanyingCourse/_confirm_delete.html.twig' %}
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'Delete accompanying period'|trans,
'confirm_question' : 'Are you sure you want to remove the accompanying period "%id%" ?'|trans({ '%id%' : accompanyingCourse.id } ),
'cancel_route' : 'chill_person_accompanying_period_list',
'cancel_parameters' : {'person_id' : person_id},
'form' : delete_form
} ) }}
{% endblock %}

View File

@@ -21,104 +21,143 @@
{% block content %}
<div class="accompanyingcourse-resume">
<div id="dashboards" class="row" data-masonry='{"percentPosition": true }'>
<div id="dashboards" class="row g-3" data-masonry='{"percentPosition": true }'>
{% if 'DRAFT' == accompanyingCourse.step %}
<div class="col-4 warnings mb-4">
{% include '@ChillPerson/AccompanyingCourse/_still_draft.html.twig' %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="warnings">
{% include '@ChillPerson/AccompanyingCourse/_still_draft.html.twig' %}
</div>
</div>
{% endif %}
{% if 'DRAFT' != accompanyingCourse.step %}
{% if withoutHousehold|length > 0 %}
<div class="col-4 warnings mb-4">
{% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="warnings">
{% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' %}
</div>
</div>
{% endif %}
{% endif %}
{% if accompanyingCourse.locationStatus == 'address'
or accompanyingCourse.locationStatus == 'none' %}
<div class="col-4 warnings mb-4">
{% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="warnings">
{% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' %}
</div>
</div>
{% endif %}
<div class="col col-sm-6 col-lg-4 location mb-4">
{% if accompanyingCourse.locationStatus == 'person' %}
<h2>{{ 'This course is located by'|trans }}</h2>
<h4>{{ accompanyingCourse.personLocation|chill_entity_render_string }}</h4>
{% elseif accompanyingCourse.locationStatus == 'address' %}
<h4>{{ 'This course has a temporarily location'|trans }}</h4>
{% endif %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="location">
{% if accompanyingCourse.locationStatus == 'person' %}
<h2>{{ 'This course is located by'|trans }}</h2>
<h4>{{ accompanyingCourse.personLocation|chill_entity_render_string }}</h4>
{% elseif accompanyingCourse.locationStatus == 'address' %}
<h4>{{ 'This course has a temporarily location'|trans }}</h4>
{% endif %}
{% if accompanyingCourse.locationStatus != 'none' %}
{{ accompanyingCourse.location|chill_entity_render_box }}
{% endif %}
{% if accompanyingCourse.locationStatus != 'none' %}
{{ accompanyingCourse.location|chill_entity_render_box }}
{% endif %}
</div>
</div>
{% if accompanyingCourse.participations is not empty %}
<div class="col col-sm-6 col-lg-4 persons mb-4">
<h4 class="item-key">{{ 'Persons associated'|trans }}</h4>
{% for r in accompanyingCourse.participations %}
{{ _self.insert_onthefly('person', r.person) }}
{% endfor %}
</div>
{% endif %}
{% if accompanyingCourse.resources is not empty %}
<div class="col col-sm-6 col-lg-4 resources mb-4">
<h4 class="item-key">{{ 'Resources'|trans }}</h4>
{% for r in accompanyingCourse.resources %}
{% if r.person is not null %}
{{ _self.insert_onthefly('person', r.person) }}
{% elseif r.thirdParty is not null %}
{{ _self.insert_onthefly('thirdparty', r.thirdParty) }}
{% endif %}
{% endfor %}
</div>
{% endif %}
{% if accompanyingCourse.pinnedComment is not empty %}
<div class="col col-sm-6 col-lg-4 comment mb-4">
<h4 class="item-key">{{ 'Pinned comment'|trans }}</h4>
<blockquote class="chill-user-quote">
{{ accompanyingCourse.pinnedComment.content }}
<div class="metadata">
{{ 'Last updated by'| trans }}
<span class="user">
<div class="mbloc col col-sm-6 col-lg-8">
<div class="comment">
<h4 class="item-key visually-hidden">{{ 'Pinned comment'|trans }}</h4>
<blockquote class="chill-user-quote">
<i class="fa fa-flag float-end text-chill-gray" title="{{ 'pinned'|trans }}"></i>
{{ accompanyingCourse.pinnedComment.content|chill_markdown_to_html }}
<div class="metadata">
{{ 'Last updated by'| trans }}
<span class="user">
{{ accompanyingCourse.pinnedComment.updatedBy|chill_entity_render_box }}
</span>
{{ 'on'|trans ~ ' ' }}
<span class="date">
{{ 'on'|trans ~ ' ' }}
<span class="date">
{{ accompanyingCourse.pinnedComment.updatedAt|format_datetime("medium", "short") }}
</span>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
{% endif %}
{% if accompanyingCourse.scopes is not empty %}
<div class="col col-sm-6 col-lg-4 scopes mb-4">
<h4 class="item-key">{{ 'Scopes'|trans }}</h4>
<div>
{% for s in accompanyingCourse.scopes %}
<span>{{ s.name|localize_translatable_string|capitalize }}</span>{% if not loop.last %}, {% endif %}
{% if accompanyingCourse.participations is not empty %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="persons">
<h4 class="item-key">{{ 'Persons associated'|trans }}</h4>
{% for r in accompanyingCourse.participations %}
{{ _self.insert_onthefly('person', r.person) }}
{% endfor %}
</div>
</div>
{% endif %}
{% if accompanyingCourse.requestorPerson is not null or accompanyingCourse.requestorThirdParty is not null %}
<div class="col col-sm-6 col-lg-4 requestor mb-4">
{% if accompanyingCourse.requestorPerson is not null %}
<h4 class="item-key">{{ 'Requestor'|trans }}</h4>
{{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }}
{% elseif accompanyingCourse.requestorThirdParty is not null %}
<h4 class="item-key">{{ 'Requestor'|trans }}</h4>
{{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }}
{% endif %}
{% if accompanyingCourse.resources is not empty %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="resources">
<h4 class="item-key">{{ 'Resources'|trans }}</h4>
{% for r in accompanyingCourse.resources %}
{% if r.person is not null %}
{{ _self.insert_onthefly('person', r.person) }}
{% elseif r.thirdParty is not null %}
{{ _self.insert_onthefly('thirdparty', r.thirdParty) }}
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
{% if accompanyingCourse.scopes is not empty %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="scopes">
<h4 class="item-key">{{ 'Scopes'|trans }}</h4>
<div>
{% for s in accompanyingCourse.scopes %}
<span>{{ s.name|localize_translatable_string|capitalize }}</span>{% if not loop.last %}, {% endif %}
{% endfor %}
</div>
</div>
</div>
{% endif %}
{% if accompanyingCourse.requestorPerson is not null or accompanyingCourse.requestorThirdParty is not null %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="requestor">
{% if accompanyingCourse.requestorPerson is not null %}
<h4 class="item-key">{{ 'Requestor'|trans }}</h4>
{{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }}
{% elseif accompanyingCourse.requestorThirdParty is not null %}
<h4 class="item-key">{{ 'Requestor'|trans }}</h4>
{{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }}
{% endif %}
</div>
</div>
{% endif %}
{% if accompanyingCourse.origin is not empty %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="origin">
<h4 class="item-key">{{ 'Origin'|trans }}</h4>
{{ accompanyingCourse.origin.label|localize_translatable_string|capitalize }}
</div>
</div>
{% endif %}
{% if accompanyingCourse.administrativeLocation is not null %}
<div class="mbloc col col-sm-6 col-lg-4">
<div class="administrative-location">
<h4 class="item-key">{{ 'accompanying_course.administrative_location'|trans }}</h4>
{{ accompanyingCourse.administrativeLocation.name }} ({{ accompanyingCourse.administrativeLocation.locationType.title|localize_translatable_string }})
</div>
</div>
{% endif %}
</div>
<div class="social-actions my-4">

View File

@@ -3,7 +3,6 @@
{% for accompanying_period in accompanying_periods %}
<div class="item-bloc">
<div class="item-row">
<div class="wrap-header">
<div class="wh-row">
<div class="wh-col">
@@ -127,6 +126,12 @@
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': accompanying_period.id }) }}"
class="btn btn-show" title="{{ 'See accompanying period'|trans }}">{# {{ 'See this period'|trans }} #}</a>
</li>
{% if accompanying_period.step == 'DRAFT' %}
<li>
<a href="{{ path('chill_person_accompanying_course_delete', { 'accompanying_period_id': accompanying_period.id, 'person_id' : person.id }) }}"
class="btn btn-delete" title="{{ 'Delete accompanying period'|trans }}">{# {{ 'Delete this period'|trans }} #}</a>
</li>
{% endif %}
<!-- if new accompanying course, this is not necessary
{% if person is defined %}

View File

@@ -124,7 +124,7 @@
{% if not person.isSharingHousehold() %}
<ul class="record_actions">
<li>
<a class="btn btn-misc" href="{{ chill_path_add_return_path('chill_person_household_members_editor', { 'persons': [ person.id ]}) }}">
<a class="btn btn-misc" href="{{chill_path_add_return_path('chill_person_household_members_editor', { 'persons': [ person.id ], 'followAfter': 'true'}) }}">
<i class="fa fa-sign-in fa-fw"></i>
{{ 'household.Join'|trans }}
</a>

View File

@@ -12,6 +12,8 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
@@ -65,6 +67,9 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'requestorPerson' => Person::class,
'requestorThirdParty' => ThirdParty::class,
'resources' => Collection::class,
'location' => Address::class,
'locationPerson' => Person::class,
'administrativeLocation' => Location::class,
];
private ClosingMotiveRender $closingMotiveRender;
@@ -104,9 +109,11 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
$scopes = [$scopes];
}
$addressContext = array_merge($context, ['docgen:expects' => Address::class, 'groups' => 'docgen:read']);
$dateContext = array_merge($context, ['docgen:expects' => DateTime::class, 'groups' => 'docgen:read']);
$userContext = array_merge($context, ['docgen:expects' => User::class, 'groups' => 'docgen:read']);
$participationContext = array_merge($context, ['docgen:expects' => AccompanyingPeriodParticipation::class, 'groups' => 'docgen:read']);
$administrativeLocationContext = array_merge($context, ['docgen:expects' => Location::class, 'groups' => 'docgen:read']);
return [
'id' => $period->getId(),
@@ -147,6 +154,12 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
}, $scopes)),
'hasRequestor' => $period->getRequestor() !== null,
'requestorKind' => $period->getRequestorKind(),
'hasLocation' => $period->getLocation() !== null,
'hasLocationPerson' => $period->getPersonLocation() !== null,
'hasAdministrativeLocation' => $period->getAdministrativeLocation() !== null,
'locationPerson' => $this->normalizer->normalize($period->getPersonLocation(), $format, array_merge($context, ['docgen:expects' => Person::class])),
'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext),
'administrativeLocation' => $this->normalizer->normalize($period->getAdministrativeLocation(), $format, $administrativeLocationContext),
];
}
@@ -162,6 +175,9 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'hasRequestorThirdParty' => false,
'isClosed' => false,
'confidential' => false,
'hasLocation' => false,
'hasLocationPerson' => false,
'hasAdministrativeLocation' => false,
]
);
}

View File

@@ -151,7 +151,7 @@ class PersonDocGenNormalizer implements
$normalizer = new NormalizeNullValueHelper($this->normalizer, 'type', 'person');
$attributes = [
'firstname', 'lastname', 'altNames', 'text',
'firstname', 'lastname', 'age', 'altNames', 'text',
'civility' => Civility::class,
'birthdate' => DateTimeInterface::class,
'deathdate' => DateTimeInterface::class,

View File

@@ -15,10 +15,11 @@ use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\PersonAltName;
use Chill\PersonBundle\Repository\PersonRepository;
use DateTime;
use DateTimeImmutable;
use LogicException;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
@@ -78,13 +79,24 @@ class PersonJsonNormalizer implements
$person = new Person();
}
foreach (['firstName', 'lastName', 'phonenumber', 'mobilenumber', 'gender',
'birthdate', 'deathdate', 'center', ]
as $item) {
if (!array_key_exists($item, $data)) {
continue;
}
$fields = [
'firstName',
'lastName',
'phonenumber',
'mobilenumber',
'gender',
'birthdate',
'deathdate',
'center',
'altNames',
];
$fields = array_filter(
$fields,
static fn (string $field): bool => array_key_exists($field, $data)
);
foreach ($fields as $item) {
switch ($item) {
case 'firstName':
$person->setFirstName($data[$item]);
@@ -131,8 +143,23 @@ class PersonJsonNormalizer implements
break;
default:
throw new LogicException("item not defined: {$item}");
case 'altNames':
foreach ($data[$item] as $altName) {
$oldAltName = $person
->getAltNames()
->filter(static fn (PersonAltName $n): bool => $n->getKey() === $altName['key'])->first();
if (false === $oldAltName) {
$newAltName = new PersonAltName();
$newAltName->setKey($altName['key']);
$newAltName->setLabel($altName['label']);
$person->addAltName($newAltName);
} else {
$oldAltName->setLabel($altName['label']);
}
}
break;
}
}
@@ -175,14 +202,22 @@ class PersonJsonNormalizer implements
return $data instanceof Person && 'json' === $format;
}
protected function normalizeAltNames($altNames): array
/**
* @param Collection<array-key, PersonAltName> $altNames
*
* @return array<array-key, array<string, string>>
*/
protected function normalizeAltNames(Collection $altNames): array
{
$r = [];
foreach ($altNames as $n) {
$r[] = ['key' => $n->getKey(), 'label' => $n->getLabel()];
}
return $r;
return $altNames
->map(
static function (PersonAltName $personAltName): array {
return [
'key' => $personAltName->getKey(),
'label' => $personAltName->getLabel(),
];
}
)
->toArray();
}
}

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\AccompanyingPeriod;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
@@ -45,13 +44,13 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase
public function dataGenerateRandomAccompanyingCourse()
{
// Disabling this dataprovider to avoid having errors while running the test.
return yield from [];
$maxGenerated = 3;
$maxResults = $maxGenerated * 8;
self::bootKernel();
$em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager');
$center = $em->getRepository(Center::class)
->findOneBy(['name' => 'Center A']);
$qb = $em->createQueryBuilder();
$personIds = $qb
@@ -80,8 +79,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase
while ($nbGenerated < $maxGenerated) {
$id = array_pop($personIds)['id'];
$person = $em->getRepository(Person::class)
->find($id);
$person = $em->getRepository(Person::class)->find($id);
$periods = $person->getAccompanyingPeriods();
yield [array_pop($personIds)['id'], $periods[array_rand($periods)]->getId()];
@@ -95,6 +93,10 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase
*/
public function testRemoveUserWhenConfidential(int $periodId)
{
$this->markTestIncomplete(
'Marked as incomplete because of a problem in the dataprovider, at line 81.'
);
$period = self::$container->get(AccompanyingPeriodRepository::class)
->find($periodId);
$em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager');

View File

@@ -306,6 +306,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testAccompanyingCourseAddParticipation(int $personId, int $periodId)
{
$this->markTestIncomplete('fix test with validation');
$this->client->request(
Request::METHOD_POST,
sprintf('/api/1.0/person/accompanying-course/%d/participation.json', $periodId),
@@ -377,6 +378,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testAccompanyingCourseAddRemoveSocialIssue(AccompanyingPeriod $period, SocialIssue $si)
{
$this->markTestIncomplete('fix test with validation');
$this->client->request(
Request::METHOD_POST,
sprintf('/api/1.0/person/accompanying-course/%d/socialissue.json', $period->getId()),
@@ -437,6 +439,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testAccompanyingPeriodPatch(int $personId, int $periodId)
{
$this->markTestIncomplete('fix test with validation');
$period = self::$container->get(AccompanyingPeriodRepository::class)
->find($periodId);
$initialValueEmergency = $period->isEmergency();
@@ -475,6 +478,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testCommentWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId)
{
$this->markTestIncomplete('fix test with validation');
$em = self::$container->get(EntityManagerInterface::class);
$this->client->request(
@@ -515,6 +519,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testConfirm(AccompanyingPeriod $period)
{
$this->markTestIncomplete('fix test with validation');
$this->client->request(
Request::METHOD_POST,
sprintf('/api/1.0/person/accompanying-course/%d/confirm.json', $period->getId())
@@ -551,6 +556,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testRequestorWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId)
{
$this->markTestIncomplete('fix test with validation');
$em = self::$container->get(EntityManagerInterface::class);
// post a person
@@ -634,6 +640,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testResourceWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId)
{
$this->markTestIncomplete('fix test with validation');
$em = self::$container->get(EntityManagerInterface::class);
// post a person

View File

@@ -111,7 +111,7 @@ final class PersonAddressControllerTest extends WebTestCase
$crawler = $this->client->followRedirect();
$this->assertRegexp(
$this->assertMatchesRegularExpression(
'|/fr/person/[0-9]{1,}/address/list|',
$this->client->getHistory()->current()->getUri(),
'assert that the current page is on |/fr/person/[0-9]{1,}/address/list|'
@@ -169,7 +169,7 @@ final class PersonAddressControllerTest extends WebTestCase
$crawler = $this->client->followRedirect();
$this->assertRegexp(
$this->assertMatchesRegularExpression(
'|/fr/person/[0-9]{1,}/address/list|',
$this->client->getHistory()->current()->getUri(),
'assert that the current page is on |/fr/person/[0-9]{1,}/address/list|'

View File

@@ -166,7 +166,7 @@ final class PersonControllerCreateTest extends WebTestCase
$form = $this->fillAValidCreationForm($form, 'Charline', 'dd');
$client->submit($form);
$this->assertContains(
$this->assertStringContainsString(
'DEPARDIEU',
$client->getCrawler()->text(),
'check that the page has detected the lastname of a person existing in database'
@@ -177,7 +177,7 @@ final class PersonControllerCreateTest extends WebTestCase
$form = $this->fillAValidCreationForm($form, 'dd', 'Charline');
$client->submit($form);
$this->assertContains(
$this->assertStringContainsString(
'DEPARDIEU',
$client->getCrawler()->text(),
'check that the page has detected the lastname of a person existing in database'
@@ -206,7 +206,7 @@ final class PersonControllerCreateTest extends WebTestCase
$client->followRedirect();
// visualize regexp here : http://jex.im/regulex/#!embed=false&flags=&re=%2Ffr%2Fperson%2F[1-9][0-9]*%2Fgeneral%2Fedit%24
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'|/fr/person/[1-9][0-9]*/general/edit$|',
$client->getHistory()->current()->getUri(),
'a valid form redirect to url /{_locale}/person/{personId}/general/edit'
@@ -259,7 +259,7 @@ final class PersonControllerCreateTest extends WebTestCase
'a valid form redirect to url /{_locale}/person/{personId}/general/edit'
);
$client->followRedirect();
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'|/fr/person/[1-9][0-9]*/general/edit$|',
$client->getHistory()->current()->getUri(),
'a valid form redirect to url /{_locale}/person/{personId}/general/edit'

View File

@@ -83,10 +83,10 @@ final class PersonControllerViewTest extends WebTestCase
$this->assertGreaterThan(0, $crawler->filter('html:contains("TESTED PERSON")')->count());
$this->assertGreaterThan(0, $crawler->filter('html:contains("Réginald")')->count());
$this->assertContains('Email addresses', $crawler->text());
$this->assertContains('Phonenumber', $crawler->text());
$this->assertContains('Langues parlées', $crawler->text());
$this->assertContains(/* Etat */ 'civil', $crawler->text());
$this->assertStringContainsString('Email addresses', $crawler->text());
$this->assertStringContainsString('Phonenumber', $crawler->text());
$this->assertStringContainsString('Langues parlées', $crawler->text());
$this->assertStringContainsString(/* Etat */ 'civil', $crawler->text());
}
/**

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Form\Type;
use Chill\PersonBundle\Form\Type\PickPersonType;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use function count;
@@ -52,7 +53,7 @@ final class PickPersonTypeTest extends KernelTestCase
*/
public function testWithInvalidOptionCenters()
{
$this->expectException(\RuntimeException::class);
$this->expectException(RuntimeException::class);
$this->markTestSkipped('need to inject locale into url generator without request');
$this->formFactory

View File

@@ -26,19 +26,19 @@ final class PersonSearchTest extends WebTestCase
$this->markTestSkipped('skipped until adapted to new fixtures');
$crawlerSpecial = $this->generateCrawlerForSearch('@person manço');
$this->assertRegExp('/MANÇO/', $crawlerSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/MANÇO/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person manco');
$this->assertRegExp('/MANÇO/', $crawlerNoSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/MANÇO/', $crawlerNoSpecial->filter('.list-with-period')->text());
$crawlerSpecial = $this->generateCrawlerForSearch('@person Étienne');
$this->assertRegExp('/Étienne/', $crawlerSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Étienne/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person etienne');
$this->assertRegExp('/Étienne/', $crawlerNoSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Étienne/', $crawlerNoSpecial->filter('.list-with-period')->text());
}
public function testExpected()
@@ -49,7 +49,7 @@ final class PersonSearchTest extends WebTestCase
'q' => '@person Depardieu',
]);
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testExpectedNamed()
@@ -60,79 +60,79 @@ final class PersonSearchTest extends WebTestCase
'q' => '@person Depardieu', 'name' => 'person_regular',
]);
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testLastNameAccentued()
{
$crawlerSpecial = $this->generateCrawlerForSearch('@person lastname:manço');
$this->assertRegExp('/MANÇO/', $crawlerSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/MANÇO/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person lastname:manco');
$this->assertRegExp('/MANÇO/', $crawlerNoSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/MANÇO/', $crawlerNoSpecial->filter('.list-with-period')->text());
}
public function testSearchBirthdate()
{
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27');
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Bart/', $crawler->filter('.list-with-period')->text());
}
public function testSearchByFirstName()
{
$crawler = $this->generateCrawlerForSearch('@person firstname:Jean');
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testSearchByFirstNameAccented()
{
$crawlerSpecial = $this->generateCrawlerForSearch('@person firstname:Gérard');
$this->assertRegExp('/Gérard/', $crawlerSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Gérard/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person firstname:Gerard');
$this->assertRegExp('/Gérard/', $crawlerNoSpecial->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Gérard/', $crawlerNoSpecial->filter('.list-with-period')->text());
}
public function testSearchByFirstNameLower()
{
$crawler = $this->generateCrawlerForSearch('@person firstname:Gérard');
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testSearchByFirstNameLower2()
{
$crawler = $this->generateCrawlerForSearch('@person firstname:jean');
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testSearchByFirstNamePartim()
{
$crawler = $this->generateCrawlerForSearch('@person firstname:Ger');
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testSearchByFirstNamePartim2()
{
$crawler = $this->generateCrawlerForSearch('@person firstname:ean');
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testSearchByLastName()
{
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu');
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testSearchCombineBirthdateAndLastName()
@@ -140,8 +140,8 @@ final class PersonSearchTest extends WebTestCase
$this->markTestSkipped('skipped until adapted to new fixtures');
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 lastname:(Van Snick)');
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Bart/', $crawler->filter('.list-with-period')->text());
$this->assertDoesNotMatchRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testSearchCombineGenderAndLastName()
@@ -149,8 +149,8 @@ final class PersonSearchTest extends WebTestCase
$this->markTestSkipped('skipped until adapted to new fixtures');
$crawler = $this->generateCrawlerForSearch('@person gender:woman lastname:(Depardieu)');
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Charline/', $crawler->filter('.list-with-period')->text());
$this->assertDoesNotMatchRegularExpression('/Gérard/', $crawler->filter('.list-with-period')->text());
}
public function testSearchCombineLastnameAndFirstName()
@@ -158,9 +158,9 @@ final class PersonSearchTest extends WebTestCase
$this->markTestSkipped('skipped until adapted to new fixtures');
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu firstname:Jean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Depardieu/', $crawler->filter('.list-with-period')->text());
//if this is a AND clause, Jean Depardieu should not appears
$this->assertNotRegExp(
$this->assertDoesNotMatchRegularExpression(
'/Gérard/',
$crawler->filter('.list-with-period')->text(),
'assert clause firstname and nationality are AND'
@@ -172,9 +172,9 @@ final class PersonSearchTest extends WebTestCase
$this->markTestSkipped('skipped until adapted to new fixtures');
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu nationality:RU');
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Gérard/', $crawler->filter('.list-with-period')->text());
//if this is a AND clause, Jean Depardieu should not appears
$this->assertNotRegExp(
$this->assertDoesNotMatchRegularExpression(
'/Jean/',
$crawler->filter('.list-with-period')->text(),
'assert clause firstname and nationality are AND'
@@ -186,9 +186,9 @@ final class PersonSearchTest extends WebTestCase
$this->markTestSkipped('skipped until adapted to new fixtures');
$crawler = $this->generateCrawlerForSearch('@person cha dep');
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text());
$this->assertMatchesRegularExpression('/Charline/', $crawler->filter('.list-with-period')->text());
$this->assertDoesNotMatchRegularExpression('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertDoesNotMatchRegularExpression('/Jean/', $crawler->filter('.list-with-period')->text());
}
/**
@@ -199,12 +199,12 @@ final class PersonSearchTest extends WebTestCase
$crawlerCanSee = $this->generateCrawlerForSearch('Gérard', 'center a_social');
$crawlerCannotSee = $this->generateCrawlerForSearch('Gérard', 'center b_social');
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/DEPARDIEU/',
$crawlerCanSee->text(),
'center a_social may see "Depardieu" in center a'
);
$this->assertNotRegExp(
$this->assertDoesNotMatchRegularExpression(
'/DEPARDIEU/',
$crawlerCannotSee->text(),
'center b_social may not see "Depardieu" in center b'

View File

@@ -94,10 +94,15 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
'hasRequestorThirdParty' => false,
'requestorPerson' => '@ignored',
'requestorThirdParty' => '@ignored',
'administrativeLocation' => '@ignored',
'hasAdministrativeLocation' => false,
'hasLocation' => false,
'hasLocationPerson' => false,
'location' => '@ignored',
'locationPerson' => '@ignored',
];
$this->assertIsArray($data);
$this->markTestSkipped('still in specification');
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
foreach ($expected as $key => $item) {
@@ -149,10 +154,15 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
'requestorPerson' => '@ignored',
'requestorThirdParty' => '@ignored',
'isNull' => true,
'administrativeLocation' => '@ignored',
'hasAdministrativeLocation' => false,
'hasLocation' => false,
'hasLocationPerson' => false,
'location' => '@ignored',
'locationPerson' => '@ignored',
];
$this->assertIsArray($data);
$this->markTestSkipped('still in specification');
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
foreach ($expected as $key => $item) {

View File

@@ -23,6 +23,7 @@ use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
use Chill\PersonBundle\Serializer\Normalizer\PersonDocGenNormalizer;
use Chill\PersonBundle\Templating\Entity\PersonRender;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -34,6 +35,8 @@ use function array_merge;
*/
final class PersonDocGenNormalizerTest extends KernelTestCase
{
use ProphecyTrait;
private const BLANK = [
'firstname' => '',
'lastname' => '',
@@ -88,6 +91,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
public function testNormalizationNullOrNotNullHaveSameKeys()
{
$this->markTestSkipped();
$period = new Person();
$notNullData = $this->buildPersonNormalizer()->normalize($period, 'docgen', ['docgen:expects' => Person::class]);
$nullData = $this->buildPersonNormalizer()->normalize(null, 'docgen', ['docgen:expects' => Person::class]);
@@ -126,6 +130,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
public function testNormalizePersonWithHousehold()
{
$this->markTestSkipped();
$household = new Household();
$person = new Person();
$person
@@ -166,6 +171,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
public function testNormalizePersonWithRelationships()
{
$this->markTestSkipped();
$person = (new Person())->setFirstName('Renaud')->setLastName('megane');
$father = (new Person())->setFirstName('Clément')->setLastName('megane');
$mother = (new Person())->setFirstName('Mireille')->setLastName('Mathieu');
@@ -199,6 +205,55 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
$this->assertCount(3, $actual['relations']);
}
/**
* Test that the @see{PersonDocGenNormalizer::class} works without interaction with other
* serializers.
*
* @dataProvider generateData
*
* @param mixed $expected
* @param mixed $msg
*/
public function testNormalizeUsingNormalizer(?Person $person, $expected, $msg)
{
$normalizer = $this->buildNormalizer();
$this->assertTrue($normalizer->supportsNormalization($person, 'docgen', [
'docgen:expects' => Person::class,
'groups' => ['docgen:read'],
]), $msg);
$this->assertIsArray($normalizer->normalize($person, 'docgen', [
'docgen:expects' => Person::class,
'groups' => ['docgen:read'],
]), $msg);
}
private function buildNormalizer(
?PersonRender $personRender = null,
?RelationshipRepository $relationshipRepository = null,
?TranslatorInterface $translator = null,
?TranslatableStringHelper $translatableStringHelper = null,
?NormalizerInterface $normalizer = null
): PersonDocGenNormalizer {
$personDocGenNormalizer = new PersonDocGenNormalizer(
$personRender ?? self::$container->get(PersonRender::class),
$relationshipRepository ?? self::$container->get(RelationshipRepository::class),
$translator ?? self::$container->get(TranslatorInterface::class),
$translatableStringHelper ?? self::$container->get(TranslatableStringHelperInterface::class)
);
if (null === $normalizer) {
$normalizer = $this->prophesize(NormalizerInterface::class);
$normalizer->normalize(Argument::any(), 'docgen', Argument::any())
->willReturn(['fake' => true]);
}
$personDocGenNormalizer->setNormalizer($normalizer->reveal());
return $personDocGenNormalizer;
}
private function buildPersonNormalizer(
?PersonRender $personRender = null,
?RelationshipRepository $relationshipRepository = null,

View File

@@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\Relationships\Relationship;
use Chill\PersonBundle\Serializer\Normalizer\RelationshipDocGenNormalizer;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use function is_object;
@@ -27,6 +28,8 @@ use function is_object;
*/
final class RelationshipDocGenNormalizerTest extends TestCase
{
use ProphecyTrait;
public function testNormalizeRelationshipNull()
{
$relationship = null;

View File

@@ -76,7 +76,7 @@ final class TimelineAccompanyingPeriodTest extends WebTestCase
$crawler->filter('.timeline div')->count(),
'the timeline page contains multiple div inside a .timeline element'
);
$this->assertContains(
$this->assertStringContainsString(
'est ouvert',
$crawler->filter('.timeline')->text(),
"the text 'est ouvert' is present"

View File

@@ -17,6 +17,7 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter;
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenterValidator;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -26,6 +27,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
*/
final class PersonHasCenterValidatorTest extends ConstraintValidatorTestCase
{
use ProphecyTrait;
public function testValidateRequired()
{
$constraint = $this->getConstraint();

View File

@@ -37,7 +37,7 @@ final class PersonValidationTest extends KernelTestCase
{
$person = (new Person())
->setBirthdate(new Datetime('+2 months'));
$errors = $this->validator->validate($person, null, ['creation']);
$errors = $this->validator->validate($person, null);
foreach ($errors->getIterator() as $error) {
if (Birthdate::BIRTHDATE_INVALID_CODE === $error->getCode()) {
@@ -59,7 +59,7 @@ final class PersonValidationTest extends KernelTestCase
{
$person = (new Person())
->setFirstname(str_repeat('a', 500));
$errors = $this->validator->validate($person, null, ['creation']);
$errors = $this->validator->validate($person, null);
foreach ($errors->getIterator() as $error) {
if (Length::TOO_LONG_ERROR === $error->getCode()) {

View File

@@ -1867,3 +1867,12 @@ paths:
description: "Unauthorized"
200:
description: "OK"
/1.0/person/config/alt_names.json:
get:
tags:
- person
summary: Return a list of possible altNames that are defined in the config
responses:
200:
description: "OK"

View File

@@ -44,6 +44,7 @@ services:
Chill\PersonBundle\Controller\PersonApiController:
arguments:
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$configPersonAltNameHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseWorkApiController:

View File

@@ -0,0 +1,40 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add location to AccompanyingPeriod.
*/
final class Version20211223150721 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86830F20868');
$this->addSql('DROP INDEX IDX_E260A86830F20868');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP administrativeLocation_id');
}
public function getDescription(): string
{
return 'Add location to AccompanyingPeriod';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD administrativeLocation_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86830F20868 FOREIGN KEY (administrativeLocation_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_E260A86830F20868 ON chill_person_accompanying_period (administrativeLocation_id)');
}
}

View File

@@ -215,6 +215,10 @@ Some peoples does not belong to any household currently. Add them to an househol
Add to household now: Ajouter à un ménage
Any resource for this accompanying course: Aucun interlocuteur privilégié pour ce parcours
course.draft: Brouillon
Origin: Origine de la demande
Delete accompanying period: Supprimer la période d'accompagnement
Are you sure you want to remove the accompanying period "%id%" ?: Êtes-vous sûr de vouloir supprimer la période d'accompagnement %id% ?
The accompanying course has been successfully removed.: La période d'accompagnement a été supprimée.
# pickAPersonType
Pick a person: Choisir une personne
@@ -407,6 +411,8 @@ Choose a person to locate by: Localiser auprès d'un usager concerné
Associate at least one member with an household, and set an address to this household: Associez au moins un membre du parcours à un ménage, et indiquez une adresse à ce ménage.
Locate by: Localiser auprès de
fix it: Compléter
accompanying_course:
administrative_location: Localisation administrative
# Accompanying Course comments
Accompanying Course Comment: Commentaire