activity component split added persons between 'Usagers du parcours' and 'Tiers non pros.'

This commit is contained in:
Mathieu Jaumotte 2021-05-28 19:27:27 +02:00
parent e123ee5d03
commit 66776eed01

View File

@ -80,16 +80,26 @@ export default {
this.setPersonsInBloc(); this.setPersonsInBloc();
}, },
setPersonsInBloc() { setPersonsInBloc() {
this.courseParticipations(); let participations = this.getCourseParticipations();
console.log('setPersonsInBloc'); let personsAssociated = [];
let personsNotAssociated = this.persons;
this.persons.forEach(person => {
participations.forEach(participation => {
if (person.id === participation.id) {
personsAssociated.push(person);
personsNotAssociated = personsNotAssociated.filter(p => p !== person);
}
});
});
this.personsBlocs.forEach(bloc => { this.personsBlocs.forEach(bloc => {
switch (bloc.key) { switch (bloc.key) {
case 'personsAssociated': case 'personsAssociated':
bloc.persons = this.persons; bloc.persons = personsAssociated;
break; break;
case 'personsNotAssociated': case 'personsNotAssociated':
//bloc.persons = this.persons; bloc.persons = personsNotAssociated;
break; break;
case 'thirdparty': case 'thirdparty':
bloc.persons = this.thirdParties; bloc.persons = this.thirdParties;
@ -100,12 +110,14 @@ export default {
} }
}); });
}, },
courseParticipations() { getCourseParticipations() {
let participations = [];
this.accompanyingCourse.participations.forEach(participation => { this.accompanyingCourse.participations.forEach(participation => {
if (participation.endDate) { if (participation.endDate) {
console.log('usager du parcours', participation.person.text); participations.push(participation.person);
} }
}); });
return participations;
} }
} }
} }