activity: group locations by type in the selector

This commit is contained in:
nobohan 2021-11-24 14:43:07 +01:00
parent 0bd0487801
commit d13d42b9bf

View File

@ -16,6 +16,8 @@
:placeholder="$t('activity.choose_location')"
:custom-label="customLabel"
:options="locations"
group-values="locations"
group-label="locationGroup"
v-model="location"
>
</VueMultiselect>
@ -69,10 +71,17 @@ export default {
const concernedThirdPartiesLocation =
this.makeConcernedThirdPartiesLocation(thirdpartyLocationType);
this.locations = [
personLocation,
...concernedPersonsLocation,
...concernedThirdPartiesLocation,
...response.results,
{
locationGroup: 'Localisation du parcours',
locations: [personLocation]
},
{
locationGroup: 'Parties concernées',
locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation]},
{
locationGroup: 'Autres localisations',
locations: response.results
}
];
if (window.default_location_id) {
let location = this.locations.filter(
@ -90,7 +99,7 @@ export default {
},
methods: {
labelAccompanyingCourseLocation(value) {
return `${value.address.text} (Localisation du parcours)`
return `${value.address.text}`
},
customLabel(value) {
return value.name ?
@ -106,6 +115,7 @@ export default {
if (e.type === 'person' && e.current_household_address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: {
@ -122,9 +132,11 @@ export default {
let locations = [];
this.suggestedEntities.forEach(
(e) => {
console.log(this.suggestedEntities.indexOf(e))
if (e.type === 'thirdparty' && e.address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: { id: e.address.address_id },
@ -139,6 +151,7 @@ export default {
const accPeriodLocation = this.activity.accompanyingPeriod.location;
return {
type: 'location',
id: -1,
onthefly: true,
name: '__AccompanyingCourseLocation__',
address: {