mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Resolve "Proposer en plus du référent de parcours les agents traitants saisis dans toutes les cations d'accompagnement du parcours"
This commit is contained in:
@@ -26,6 +26,7 @@ const store = createStore({
|
||||
state: {
|
||||
me: null,
|
||||
activity: window.activity,
|
||||
accompanyingPeriodWorks: [],
|
||||
socialIssuesOther: [],
|
||||
socialActionsList: [],
|
||||
availableLocations: [],
|
||||
@@ -41,7 +42,7 @@ const store = createStore({
|
||||
const allEntities = [
|
||||
...store.getters.suggestedPersons,
|
||||
...store.getters.suggestedRequestor,
|
||||
...store.getters.suggestedUser,
|
||||
...store.getters.suggestedUsers,
|
||||
...store.getters.suggestedResources,
|
||||
];
|
||||
const uniqueIds = [
|
||||
@@ -80,8 +81,7 @@ const store = createStore({
|
||||
state.activity.activityType.thirdPartiesVisible !== 0),
|
||||
);
|
||||
},
|
||||
suggestedUser(state) {
|
||||
// console.log('current user', state.me)
|
||||
suggestedUsers(state) {
|
||||
const existingUserIds = state.activity.users.map((p) => p.id);
|
||||
let suggestedUsers =
|
||||
state.activity.activityType.usersVisible === 0
|
||||
@@ -90,11 +90,18 @@ const store = createStore({
|
||||
(u) => u !== null && !existingUserIds.includes(u.id),
|
||||
);
|
||||
|
||||
state.accompanyingPeriodWorks.forEach((work) => {
|
||||
work.referrers.forEach((r) => {
|
||||
if (!existingUserIds.includes(r.id)) {
|
||||
suggestedUsers.push(r);
|
||||
}
|
||||
});
|
||||
});
|
||||
// Add the current user from the state
|
||||
if (state.me && !existingUserIds.includes(state.me.id)) {
|
||||
suggestedUsers.push(state.me);
|
||||
}
|
||||
console.log("suggested users", suggestedUsers);
|
||||
// console.log("suggested users", suggestedUsers);
|
||||
|
||||
return suggestedUsers;
|
||||
},
|
||||
@@ -223,6 +230,9 @@ const store = createStore({
|
||||
addAvailableLocationGroup(state, group) {
|
||||
state.availableLocations.push(group);
|
||||
},
|
||||
setAccompanyingPeriodWorks(state, works) {
|
||||
state.accompanyingPeriodWorks = works;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
addIssueSelected({ commit }, issue) {
|
||||
@@ -341,6 +351,17 @@ const store = createStore({
|
||||
}
|
||||
commit("updateLocation", value);
|
||||
},
|
||||
async fetchAccompanyingPeriodWorks({ state, commit }) {
|
||||
const accompanyingPeriodId = state.activity.accompanyingPeriod.id;
|
||||
const url = `/api/1.0/person/accompanying-course/${accompanyingPeriodId}/works.json`;
|
||||
try {
|
||||
const works = await makeFetch("GET", url);
|
||||
// console.log("works", works);
|
||||
commit("setAccompanyingPeriodWorks", works);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch accompanying period works:", error);
|
||||
}
|
||||
},
|
||||
getWhoAmI({ commit }) {
|
||||
const url = `/api/1.0/main/whoami.json`;
|
||||
makeFetch("GET", url).then((user) => {
|
||||
@@ -353,5 +374,6 @@ const store = createStore({
|
||||
store.dispatch("getWhoAmI");
|
||||
|
||||
prepareLocations(store);
|
||||
store.dispatch("fetchAccompanyingPeriodWorks");
|
||||
|
||||
export default store;
|
||||
|
Reference in New Issue
Block a user