From 0ad7ca62355ccbd16683b597ee845f8d4a4072ca Mon Sep 17 00:00:00 2001 From: nobohan Date: Sun, 28 Nov 2021 22:17:00 +0100 Subject: [PATCH] person: init suggested entities in accompanying course (working) --- .../components/PersonsAssociated.vue | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue index 69f16358f..095cb0815 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -47,9 +47,9 @@ -
+
    -
  • +
  • {{ p.text }} @@ -102,10 +102,15 @@ export default { ...mapState({ courseId: state => state.accompanyingCourse.id, participations: state => state.accompanyingCourse.participations, - suggestedEntities: state => [ + suggestedPersons: state => [ state.accompanyingCourse.requestor, ...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([ 'isParticipationValid' @@ -122,13 +127,6 @@ export default { getReturnPath() { 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: { removeParticipation(item) { @@ -165,7 +163,17 @@ export default { ); this.$refs.addPersons.resetSearch(); // to cast child method 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'}) + } + }) + }, } }