mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46:13 +00:00
person: init suggested entities in accompanying course
(working)
This commit is contained in:
parent
5fab0ffe27
commit
0ad7ca6235
@ -47,9 +47,9 @@
|
|||||||
</participation-item>
|
</participation-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="suggestedEntities.length > 0">
|
<div v-if="suggestedPersons.length > 0">
|
||||||
<ul class="list-suggest add-items">
|
<ul class="list-suggest add-items">
|
||||||
<li v-for="p in suggestedEntities" @click="addSuggestedEntity(p)">
|
<li v-for="p in suggestedPersons" :key="p.id" @click="addSuggestedPerson(p)">
|
||||||
<span class="badge bg-primary" style="cursor: pointer;">
|
<span class="badge bg-primary" style="cursor: pointer;">
|
||||||
<i class="fa fa-plus fa-fw text-success"></i>
|
<i class="fa fa-plus fa-fw text-success"></i>
|
||||||
{{ p.text }}
|
{{ p.text }}
|
||||||
@ -102,10 +102,15 @@ export default {
|
|||||||
...mapState({
|
...mapState({
|
||||||
courseId: state => state.accompanyingCourse.id,
|
courseId: state => state.accompanyingCourse.id,
|
||||||
participations: state => state.accompanyingCourse.participations,
|
participations: state => state.accompanyingCourse.participations,
|
||||||
suggestedEntities: state => [
|
suggestedPersons: state => [
|
||||||
state.accompanyingCourse.requestor,
|
state.accompanyingCourse.requestor,
|
||||||
...state.accompanyingCourse.resources.map(r => r.resource)
|
...state.accompanyingCourse.resources.map(r => r.resource)
|
||||||
].filter(e => e !== null)
|
]
|
||||||
|
.filter((e) => e !== null)
|
||||||
|
.filter((e) => e.type === 'person')
|
||||||
|
.filter(
|
||||||
|
(p) => !state.accompanyingCourse.participations.map((p) => p.person.id).includes(p.id)
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'isParticipationValid'
|
'isParticipationValid'
|
||||||
@ -122,13 +127,6 @@ export default {
|
|||||||
getReturnPath() {
|
getReturnPath() {
|
||||||
return window.location.pathname + window.location.search + window.location.hash;
|
return window.location.pathname + window.location.search + window.location.hash;
|
||||||
},
|
},
|
||||||
addSuggestedPerson(person) { //TODO
|
|
||||||
this.$store.dispatch('addPersonsInvolved', { result: person, type: 'person' });
|
|
||||||
this.setPersonsInBloc();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
console.log(this.suggestedEntities)
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeParticipation(item) {
|
removeParticipation(item) {
|
||||||
@ -165,7 +163,17 @@ export default {
|
|||||||
);
|
);
|
||||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||||
modal.showModal = false;
|
modal.showModal = false;
|
||||||
}
|
},
|
||||||
|
addSuggestedPerson(person) {
|
||||||
|
this.$store.dispatch('addParticipation', { result: person, type: 'person' })
|
||||||
|
.catch(({name, violations}) => {
|
||||||
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
|
} else {
|
||||||
|
this.$toast.open({message: 'An error occurred'})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user