mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-09 17:29:51 +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:
parent
096466e79e
commit
10eaebf610
6
.changes/unreleased/Feature-20250130-120207.yaml
Normal file
6
.changes/unreleased/Feature-20250130-120207.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
kind: Feature
|
||||||
|
body: Suggest all referrers within actions of the accompanying period when creating an activity
|
||||||
|
time: 2025-01-30T12:02:07.053587034+01:00
|
||||||
|
custom:
|
||||||
|
Issue: "349"
|
||||||
|
SchemaChange: No schema change
|
@ -26,6 +26,7 @@ const store = createStore({
|
|||||||
state: {
|
state: {
|
||||||
me: null,
|
me: null,
|
||||||
activity: window.activity,
|
activity: window.activity,
|
||||||
|
accompanyingPeriodWorks: [],
|
||||||
socialIssuesOther: [],
|
socialIssuesOther: [],
|
||||||
socialActionsList: [],
|
socialActionsList: [],
|
||||||
availableLocations: [],
|
availableLocations: [],
|
||||||
@ -41,7 +42,7 @@ const store = createStore({
|
|||||||
const allEntities = [
|
const allEntities = [
|
||||||
...store.getters.suggestedPersons,
|
...store.getters.suggestedPersons,
|
||||||
...store.getters.suggestedRequestor,
|
...store.getters.suggestedRequestor,
|
||||||
...store.getters.suggestedUser,
|
...store.getters.suggestedUsers,
|
||||||
...store.getters.suggestedResources,
|
...store.getters.suggestedResources,
|
||||||
];
|
];
|
||||||
const uniqueIds = [
|
const uniqueIds = [
|
||||||
@ -80,8 +81,7 @@ const store = createStore({
|
|||||||
state.activity.activityType.thirdPartiesVisible !== 0),
|
state.activity.activityType.thirdPartiesVisible !== 0),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
suggestedUser(state) {
|
suggestedUsers(state) {
|
||||||
// console.log('current user', state.me)
|
|
||||||
const existingUserIds = state.activity.users.map((p) => p.id);
|
const existingUserIds = state.activity.users.map((p) => p.id);
|
||||||
let suggestedUsers =
|
let suggestedUsers =
|
||||||
state.activity.activityType.usersVisible === 0
|
state.activity.activityType.usersVisible === 0
|
||||||
@ -90,11 +90,18 @@ const store = createStore({
|
|||||||
(u) => u !== null && !existingUserIds.includes(u.id),
|
(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
|
// Add the current user from the state
|
||||||
if (state.me && !existingUserIds.includes(state.me.id)) {
|
if (state.me && !existingUserIds.includes(state.me.id)) {
|
||||||
suggestedUsers.push(state.me);
|
suggestedUsers.push(state.me);
|
||||||
}
|
}
|
||||||
console.log("suggested users", suggestedUsers);
|
// console.log("suggested users", suggestedUsers);
|
||||||
|
|
||||||
return suggestedUsers;
|
return suggestedUsers;
|
||||||
},
|
},
|
||||||
@ -223,6 +230,9 @@ const store = createStore({
|
|||||||
addAvailableLocationGroup(state, group) {
|
addAvailableLocationGroup(state, group) {
|
||||||
state.availableLocations.push(group);
|
state.availableLocations.push(group);
|
||||||
},
|
},
|
||||||
|
setAccompanyingPeriodWorks(state, works) {
|
||||||
|
state.accompanyingPeriodWorks = works;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addIssueSelected({ commit }, issue) {
|
addIssueSelected({ commit }, issue) {
|
||||||
@ -341,6 +351,17 @@ const store = createStore({
|
|||||||
}
|
}
|
||||||
commit("updateLocation", value);
|
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 }) {
|
getWhoAmI({ commit }) {
|
||||||
const url = `/api/1.0/main/whoami.json`;
|
const url = `/api/1.0/main/whoami.json`;
|
||||||
makeFetch("GET", url).then((user) => {
|
makeFetch("GET", url).then((user) => {
|
||||||
@ -353,5 +374,6 @@ const store = createStore({
|
|||||||
store.dispatch("getWhoAmI");
|
store.dispatch("getWhoAmI");
|
||||||
|
|
||||||
prepareLocations(store);
|
prepareLocations(store);
|
||||||
|
store.dispatch("fetchAccompanyingPeriodWorks");
|
||||||
|
|
||||||
export default store;
|
export default store;
|
||||||
|
@ -25,7 +25,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
|||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
@ -46,7 +46,7 @@ use Symfony\Component\Workflow\Registry;
|
|||||||
|
|
||||||
final class AccompanyingCourseApiController extends ApiController
|
final class AccompanyingCourseApiController extends ApiController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) {}
|
||||||
|
|
||||||
public function commentApi($id, Request $request, string $_format): Response
|
public function commentApi($id, Request $request, string $_format): Response
|
||||||
{
|
{
|
||||||
@ -305,6 +305,20 @@ final class AccompanyingCourseApiController extends ApiController
|
|||||||
return $this->json($accompanyingCourse->getIntensity(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
return $this->json($accompanyingCourse->getIntensity(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ParamConverter("accompanyingPeriod", options={"id": "id"})
|
||||||
|
*/
|
||||||
|
#[Route(path: '/api/1.0/person/accompanying-course/{id}/works.json', name: 'chill_api_person_accompanying_period_works')]
|
||||||
|
public function worksByAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): JsonResponse
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingPeriod);
|
||||||
|
|
||||||
|
$works = $this->accompanyingPeriodWorkRepository->findBy(['accompanyingPeriod' => $accompanyingPeriod]);
|
||||||
|
dump($works);
|
||||||
|
|
||||||
|
return $this->json($works, Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||||
|
}
|
||||||
|
|
||||||
public function workApi($id, Request $request, string $_format): Response
|
public function workApi($id, Request $request, string $_format): Response
|
||||||
{
|
{
|
||||||
return $this->addRemoveSomething(
|
return $this->addRemoveSomething(
|
||||||
|
@ -1013,6 +1013,29 @@ paths:
|
|||||||
200:
|
200:
|
||||||
description: "OK"
|
description: "OK"
|
||||||
|
|
||||||
|
/1.0/person/accompanying-course/{id}/works.json:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- accompanying-course
|
||||||
|
summary: List of accompanying period works for an accompanying period
|
||||||
|
description: Gets a list of accompanying period works for an accompanying period
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The accompanying period id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: integer
|
||||||
|
minimum: 1
|
||||||
|
responses:
|
||||||
|
401:
|
||||||
|
description: "Unauthorized"
|
||||||
|
404:
|
||||||
|
description: "Not found"
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
|
||||||
/1.0/person/accompanying-course/{id}/work.json:
|
/1.0/person/accompanying-course/{id}/work.json:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user