mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 06:26:15 +00:00
person: suggest entities for resources
This commit is contained in:
parent
4abb1a7a57
commit
60422f5eee
@ -109,7 +109,7 @@ export default {
|
|||||||
.filter((e) => e !== null)
|
.filter((e) => e !== null)
|
||||||
.filter((e) => e.type === 'person')
|
.filter((e) => e.type === 'person')
|
||||||
.filter(
|
.filter(
|
||||||
(p) => !state.accompanyingCourse.participations.map((p) => p.person.id).includes(p.id)
|
(p) => !state.accompanyingCourse.participations.map((pa) => pa.person.id).includes(p.id)
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
|
@ -248,7 +248,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
addSuggestedEntity(e) {
|
addSuggestedEntity(e) {
|
||||||
this.$store.dispatch('addRequestor', { result: e, type: e.type }) //TODO check person | thirdparty
|
this.$store.dispatch('addRequestor', { result: e, type: e.type })
|
||||||
.catch(({name, violations}) => {
|
.catch(({name, violations}) => {
|
||||||
if (name === 'ValidationException' || name === 'AccessException') {
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
|
@ -18,6 +18,18 @@
|
|||||||
@remove="removeResource">
|
@remove="removeResource">
|
||||||
</resource-item>
|
</resource-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="suggestedEntities.length > 0">
|
||||||
|
<ul class="list-suggest add-items">
|
||||||
|
<li v-for="p in suggestedEntities" :key="uniqueId(p)" @click="addSuggestedEntity(p)">
|
||||||
|
<span class="badge bg-primary" style="cursor: pointer;">
|
||||||
|
<i class="fa fa-plus fa-fw text-success"></i>
|
||||||
|
{{ p.text }}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<add-persons
|
<add-persons
|
||||||
buttonTitle="resources.add_resources"
|
buttonTitle="resources.add_resources"
|
||||||
@ -57,7 +69,26 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: mapState({
|
computed: mapState({
|
||||||
resources: state => state.accompanyingCourse.resources,
|
resources: state => state.accompanyingCourse.resources,
|
||||||
counter: state => state.accompanyingCourse.resources.length
|
counter: state => state.accompanyingCourse.resources.length,
|
||||||
|
suggestedEntities: state => [
|
||||||
|
state.accompanyingCourse.requestor,
|
||||||
|
...state.accompanyingCourse.participations.map(p => p.person),
|
||||||
|
]
|
||||||
|
.filter((e) => e !== null)
|
||||||
|
.filter(
|
||||||
|
(e) => {
|
||||||
|
if (e.type === 'person') {
|
||||||
|
return !state.accompanyingCourse.resources
|
||||||
|
.filter((r) => r.resource.type === 'person')
|
||||||
|
.map((r) => r.resource.id).includes(e.id)
|
||||||
|
}
|
||||||
|
if (e.type === 'thirdparty') {
|
||||||
|
return !state.accompanyingCourse.resources
|
||||||
|
.filter((r) => r.resource.type === 'thirdparty')
|
||||||
|
.map((r) => r.resource.id).includes(e.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
removeResource(item) {
|
removeResource(item) {
|
||||||
@ -86,6 +117,19 @@ export default {
|
|||||||
);
|
);
|
||||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||||
modal.showModal = false;
|
modal.showModal = false;
|
||||||
|
},
|
||||||
|
addSuggestedEntity(e) {
|
||||||
|
this.$store.dispatch('addResource', { result: e, type: e.type})
|
||||||
|
.catch(({name, violations}) => {
|
||||||
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
|
} else {
|
||||||
|
this.$toast.open({message: 'An error occurred'})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
uniqueId(e) {
|
||||||
|
return `${e.type}-${e.id}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user