From abede56d68aa5a6f7cf2070b1d108baf18e96e48 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 1 Jun 2021 16:18:01 +0200 Subject: [PATCH] activity vue corrections --- .../Resources/public/vuejs/Activity/App.vue | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue index fd1c093d7..cd99b8881 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue @@ -36,23 +36,27 @@ export default { data() { return { personsBlocs: [ - { key: 'personsAssociated', title: 'activity.bloc_persons_associated', + { key: 'personsAssociated', + title: 'activity.bloc_persons_associated', persons: [] }, - { key: 'personsNotAssociated', title: 'activity.bloc_persons_not_associated', + { key: 'personsNotAssociated', + title: 'activity.bloc_persons_not_associated', persons: [] }, - { key: 'thirdparty', title: 'activity.bloc_thirdparty', + { key: 'thirdparty', + title: 'activity.bloc_thirdparty', persons: [] }, - { key: 'users', title: 'activity.bloc_users', + { key: 'users', + title: 'activity.bloc_users', persons: [] }, ], addPersons: { key: 'activity', options: { - type: ['person', 'thirdparty'], // TODO 'user' + type: ['person', 'thirdparty'], // TODO add 'user' priority: null, uniq: false, } @@ -67,6 +71,9 @@ export default { accompanyingCourse: state => state.activity.accompanyingPeriod }) }, + mounted() { + this.setPersonsInBloc(); + }, methods: { addNewPersons({ selected, modal }) { console.log('@@@ CLICK button addNewPersons', selected); @@ -76,29 +83,29 @@ export default { ); this.$refs.addPersons.resetSearch(); // to cast child method modal.showModal = false; - this.setPersonsInBloc(); }, - setPersonsInBloc() { - let participations = this.getCourseParticipations(); + setPersonsInBloc() { let personsAssociated = []; let personsNotAssociated = this.persons; - + let participations = this.getCourseParticipations(); this.persons.forEach(person => { participations.forEach(participation => { if (person.id === participation.id) { + console.log(person.id); personsAssociated.push(person); personsNotAssociated = personsNotAssociated.filter(p => p !== person); } }); }); - this.personsBlocs.forEach(bloc => { switch (bloc.key) { case 'personsAssociated': + console.log('personsAssociated', personsAssociated); bloc.persons = personsAssociated; break; case 'personsNotAssociated': + console.log('personsNotAssociated', personsNotAssociated); bloc.persons = personsNotAssociated; break; case 'thirdparty': @@ -113,7 +120,7 @@ export default { getCourseParticipations() { let participations = []; this.accompanyingCourse.participations.forEach(participation => { - if (participation.endDate) { + if (!participation.endDate) { participations.push(participation.person); } });