mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: add thirdParty in concerned persons (WIP)
This commit is contained in:
parent
1557b8f80a
commit
43d6dc835f
@ -14,6 +14,7 @@ use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Entity\CancelReason;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
@ -81,7 +82,45 @@ class CalendarType extends AbstractType
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
|
||||
$builder->add('professionals', HiddenType::class);
|
||||
$builder->get('professionals')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $thirdpartyAsIterable): string {
|
||||
$thirdpartyIds = [];
|
||||
foreach ($thirdpartyAsIterable as $value) {
|
||||
$thirdpartyIds[] = $value->getId();
|
||||
}
|
||||
return implode(',', $thirdpartyIds);
|
||||
},
|
||||
function (?string $thirdpartyAsString): array {
|
||||
return array_map(
|
||||
fn(string $id): ?ThirdParty => $this->om->getRepository(ThirdParty::class)->findOneBy(['id' => (int) $id]),
|
||||
explode(',', $thirdpartyAsString)
|
||||
);
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
// $builder->add('users', HiddenType::class);
|
||||
// $builder->get('users')
|
||||
// ->addModelTransformer(new CallbackTransformer(
|
||||
// function (iterable $usersAsIterable): string {
|
||||
// $userIds = [];
|
||||
// foreach ($usersAsIterable as $value) {
|
||||
// $userIds[] = $value->getId();
|
||||
// }
|
||||
// return implode(',', $userIds);
|
||||
// },
|
||||
// function (?string $usersAsString): array {
|
||||
// return array_map(
|
||||
// fn(string $id): ?User => $this->om->getRepository(User::class)->findOneBy(['id' => (int) $id]),
|
||||
// explode(',', $usersAsString)
|
||||
// );
|
||||
// }
|
||||
// ))
|
||||
// ;
|
||||
|
||||
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
|
@ -3,13 +3,6 @@ import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||
const appMessages = {
|
||||
fr: {
|
||||
activity: {
|
||||
//
|
||||
social_issues: "Problématiques sociales",
|
||||
choose_other_social_issue: "Ajouter une autre problématique sociale...",
|
||||
social_actions: "Actions d'accompagnement",
|
||||
select_first_a_social_issue: "Sélectionnez d'abord une problématique sociale",
|
||||
|
||||
//
|
||||
add_persons: "Ajouter des personnes concernées",
|
||||
bloc_persons: "Usagers",
|
||||
bloc_persons_associated: "Usagers du parcours",
|
||||
|
@ -22,7 +22,9 @@ const removeIdFromValue = (string, id) => {
|
||||
const activity = {
|
||||
accompanyingPeriod: null,
|
||||
socialIssues: [],
|
||||
persons: []
|
||||
persons: [],
|
||||
professionals: [],
|
||||
invites: []
|
||||
}; // TODO: get this object from window.activity ?
|
||||
|
||||
const store = createStore({
|
||||
@ -86,14 +88,12 @@ const store = createStore({
|
||||
// ConcernedGroups
|
||||
addPersonsInvolved(state, payload) {
|
||||
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
||||
console.log(state)
|
||||
console.log(payload)
|
||||
switch (payload.result.type) {
|
||||
case 'person':
|
||||
state.activity.persons.push(payload.result);
|
||||
break;
|
||||
case 'thirdparty':
|
||||
state.activity.thirdParties.push(payload.result);
|
||||
state.activity.professionals.push(payload.result);
|
||||
break;
|
||||
case 'user':
|
||||
state.activity.users.push(payload.result);
|
||||
@ -107,7 +107,7 @@ const store = createStore({
|
||||
state.activity.persons = state.activity.persons.filter(person => person !== payload);
|
||||
break;
|
||||
case 'thirdparty':
|
||||
state.activity.thirdParties = state.activity.thirdParties.filter(thirdparty => thirdparty !== payload);
|
||||
state.activity.professionals = state.activity.professionals.filter(thirdparty => thirdparty !== payload);
|
||||
break;
|
||||
case 'user':
|
||||
state.activity.users = state.activity.users.filter(user => user !== payload);
|
||||
@ -138,18 +138,18 @@ const store = createStore({
|
||||
commit('updateActionsSelected', payload);
|
||||
},
|
||||
addPersonsInvolved({ commit }, payload) {
|
||||
//console.log('### action addPersonsInvolved', payload.result.type);
|
||||
console.log('### action addPersonsInvolved', payload.result.type);
|
||||
switch (payload.result.type) {
|
||||
case 'person':
|
||||
let aPersons = document.getElementById("chill_calendarbundle_calendar_persons");
|
||||
aPersons.value = addIdToValue(aPersons.value, payload.result.id);
|
||||
break;
|
||||
case 'thirdparty':
|
||||
let aThirdParties = document.getElementById("chill_calendarbundle_calendar_thirdParties");
|
||||
let aThirdParties = document.getElementById("chill_calendarbundle_calendar_professionals");
|
||||
aThirdParties.value = addIdToValue(aThirdParties.value, payload.result.id);
|
||||
break;
|
||||
case 'user':
|
||||
let aUsers = document.getElementById("chill_calendarbundle_calendar_users");
|
||||
let aUsers = document.getElementById("chill_calendarbundle_calendar_invites");
|
||||
aUsers.value = addIdToValue(aUsers.value, payload.result.id);
|
||||
break;
|
||||
};
|
||||
@ -163,11 +163,11 @@ const store = createStore({
|
||||
aPersons.value = removeIdFromValue(aPersons.value, payload.id);
|
||||
break;
|
||||
case 'thirdparty':
|
||||
let aThirdParties = document.getElementById("chill_calendarbundle_calendar_thirdParties");
|
||||
let aThirdParties = document.getElementById("chill_calendarbundle_calendar_professionals");
|
||||
aThirdParties.value = removeIdFromValue(aThirdParties.value, payload.id);
|
||||
break;
|
||||
case 'user':
|
||||
let aUsers = document.getElementById("chill_calendarbundle_calendar_users");
|
||||
let aUsers = document.getElementById("chill_calendarbundle_calendar_invites");
|
||||
aUsers.value = removeIdFromValue(aUsers.value, payload.id);
|
||||
break;
|
||||
};
|
||||
|
@ -12,6 +12,9 @@
|
||||
{%- if form.persons is defined -%}
|
||||
{{ form_widget(form.persons) }}
|
||||
{% endif %}
|
||||
{%- if form.professionals is defined -%}
|
||||
{{ form_widget(form.professionals) }}
|
||||
{% endif %}
|
||||
{%- if form.nonProfessionals is defined -%}
|
||||
{{ form_widget(form.nonProfessionals) }}
|
||||
{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user