location: fix error when there is no defaultFor defined for locationType entities

This commit is contained in:
nobohan 2021-11-25 16:53:02 +01:00
parent aad4b6e5d0
commit f002d48efd

View File

@ -63,6 +63,7 @@ export default {
new Promise((resolve) => {
getLocationTypeByDefaultFor('person').then(
personLocationType => {
if (personLocationType) {
const personLocation = this.makeAccompanyingPeriodLocation(personLocationType);
const concernedPersonsLocation =
this.makeConcernedPersonsLocation(personLocationType);
@ -77,12 +78,23 @@ export default {
},
{
locationGroup: 'Parties concernées',
locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation]},
locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation]
},
{
locationGroup: 'Autres localisations',
locations: response.results
}
];
}
)
} else {
this.locations = [
{
locationGroup: 'Localisations',
locations: response.results
}
];
}
if (window.default_location_id) {
let location = this.locations.filter(
(l) => l.id === window.default_location_id
@ -92,8 +104,6 @@ export default {
resolve();
}
)
}
)
})
);
},
@ -102,11 +112,13 @@ export default {
return `${value.address.text} (${value.locationType.title.fr})`
},
customLabel(value) {
return value.name ?
value.name === '__AccompanyingCourseLocation__' ?
this.labelAccompanyingCourseLocation(value) :
`${value.name} (${value.locationType.title.fr})` :
value.locationType.title.fr;
return value.locationType
? value.name
? value.name === '__AccompanyingCourseLocation__'
? this.labelAccompanyingCourseLocation(value)
: `${value.name} (${value.locationType.title.fr})`
: value.locationType.title.fr
: '';
},
makeConcernedPersonsLocation(locationType) {
let locations = [];