mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
activity: suggest requestor, user and ressources for adding persons|user|3rdparty
This commit is contained in:
parent
909e2ca070
commit
b3cd7c5cdb
@ -10,9 +10,9 @@
|
|||||||
</persons-bloc>
|
</persons-bloc>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="getContext === 'accompanyingCourse' && filterSuggestedPersons.length > 0">
|
<div v-if="getContext === 'accompanyingCourse' && suggestedEntities.length > 0">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="p in filterSuggestedPersons" @click="addNewPerson(p)">
|
<li v-for="p in suggestedEntities" @click="addNewPerson(p)">
|
||||||
{{ p.text }}
|
{{ p.text }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -91,7 +91,7 @@ export default {
|
|||||||
accompanyingCourse: state => state.activity.accompanyingPeriod
|
accompanyingCourse: state => state.activity.accompanyingPeriod
|
||||||
}),
|
}),
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'filterSuggestedPersons'
|
'suggestedEntities'
|
||||||
]),
|
]),
|
||||||
getContext() {
|
getContext() {
|
||||||
return (this.accompanyingCourse) ? "accompanyingCourse" : "person";
|
return (this.accompanyingCourse) ? "accompanyingCourse" : "person";
|
||||||
|
@ -26,14 +26,52 @@ const store = createStore({
|
|||||||
socialActionsList: [],
|
socialActionsList: [],
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
filterSuggestedPersons(state) {
|
suggestedEntities(state) {
|
||||||
if (typeof(state.activity.accompanyingPeriod) === 'undefined') {
|
if (typeof(state.activity.accompanyingPeriod) === 'undefined') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
let existingPersonIds = state.activity.persons.map(p => p.id);
|
const allEntities = [
|
||||||
return state.activity.accompanyingPeriod.participations.filter(p => p.endDate === null)
|
...store.getters.suggestedPersons,
|
||||||
|
...store.getters.suggestedRequestor,
|
||||||
|
...store.getters.suggestedUser,
|
||||||
|
...store.getters.suggestedResources
|
||||||
|
];
|
||||||
|
const uniqueIds = [...new Set(allEntities.map(i => `${i.type}-${i.id}`))];
|
||||||
|
return Array.from(uniqueIds, id => allEntities.filter(r => `${r.type}-${r.id}` === id)[0]);
|
||||||
|
},
|
||||||
|
suggestedPersons(state) {
|
||||||
|
const existingPersonIds = state.activity.persons.map(p => p.id);
|
||||||
|
return state.activity.accompanyingPeriod.participations
|
||||||
|
.filter(p => p.endDate === null)
|
||||||
.map(p => p.person)
|
.map(p => p.person)
|
||||||
.filter(p => !existingPersonIds.includes(p.id))
|
.filter(p => !existingPersonIds.includes(p.id))
|
||||||
|
},
|
||||||
|
suggestedRequestor(state) {
|
||||||
|
const existingPersonIds = state.activity.persons.map(p => p.id);
|
||||||
|
const existingThirdPartyIds = state.activity.thirdParties.map(p => p.id);
|
||||||
|
return [state.activity.accompanyingPeriod.requestor]
|
||||||
|
.filter(r =>
|
||||||
|
(r.type === 'person' && !existingPersonIds.includes(r.id)) ||
|
||||||
|
(r.type === 'thirdparty' && !existingThirdPartyIds.includes(r.id))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
suggestedUser(state) {
|
||||||
|
const existingUserIds = state.activity.users.map(p => p.id);
|
||||||
|
return [state.activity.accompanyingPeriod.user]
|
||||||
|
.filter(
|
||||||
|
u => !existingUserIds.includes(u.id)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
suggestedResources(state) {
|
||||||
|
const resources = state.activity.accompanyingPeriod.resources;
|
||||||
|
const existingPersonIds = state.activity.persons.map(p => p.id);
|
||||||
|
const existingThirdPartyIds = state.activity.thirdParties.map(p => p.id);
|
||||||
|
return state.activity.accompanyingPeriod.resources
|
||||||
|
.map(r => r.resource)
|
||||||
|
.filter(r =>
|
||||||
|
(r.type === 'person' && !existingPersonIds.includes(r.id)) ||
|
||||||
|
(r.type === 'thirdparty' && !existingThirdPartyIds.includes(r.id))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user