add a list of suggested persons on activity

This commit is contained in:
Julien Fastré 2021-08-22 00:50:37 +02:00
parent 2a3f869882
commit d6135641c5
2 changed files with 207 additions and 182 deletions

View File

@ -10,6 +10,14 @@
</persons-bloc>
</div>
<div v-if="getContext === 'accompanyingCourse' && filterSuggestedPersons.length > 0">
<ul>
<li v-for="p in filterSuggestedPersons" @click="addNewPerson(p)">
{{ p.text }}
</li>
</ul>
</div>
<add-persons
buttonTitle="activity.add_persons"
modalTitle="activity.add_persons"
@ -23,7 +31,7 @@
</template>
<script>
import { mapState } from 'vuex';
import { mapState, mapGetters } from 'vuex';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import PersonsBloc from './ConcernedGroups/PersonsBloc.vue';
@ -79,6 +87,9 @@ export default {
users: state => state.activity.users,
accompanyingCourse: state => state.activity.accompanyingPeriod
}),
...mapGetters([
'filterSuggestedPersons'
]),
getContext() {
return (this.accompanyingCourse) ? "accompanyingCourse" : "person";
},
@ -161,7 +172,11 @@ export default {
this.$refs.addPersons.resetSearch(); // to cast child method
modal.showModal = false;
this.setPersonsInBloc();
}
},
addNewPerson(person) {
this.$store.dispatch('addPersonsInvolved', { result: person, type: 'person' });
this.setPersonsInBloc();
},
}
}
</script>

View File

@ -25,8 +25,18 @@ const store = createStore({
socialIssuesOther: [],
socialActionsList: [],
},
getters: {
filterSuggestedPersons(state) {
if (typeof(state.activity.accompanyingPeriod) === 'undefined') {
return [];
}
let existingPersonIds = state.activity.persons.map(p => p.id);
return state.activity.accompanyingPeriod.participations.filter(p => p.endDate === null)
.map(p => p.person)
.filter(p => !existingPersonIds.includes(p.id))
}
},
mutations: {
// SocialIssueAcc
addIssueInList(state, issue) {
//console.log('add issue list', issue.id);