mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +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\CalendarBundle\Entity\CancelReason;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
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}
|
* {@inheritdoc}
|
||||||
|
@ -3,13 +3,6 @@ import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
|||||||
const appMessages = {
|
const appMessages = {
|
||||||
fr: {
|
fr: {
|
||||||
activity: {
|
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",
|
add_persons: "Ajouter des personnes concernées",
|
||||||
bloc_persons: "Usagers",
|
bloc_persons: "Usagers",
|
||||||
bloc_persons_associated: "Usagers du parcours",
|
bloc_persons_associated: "Usagers du parcours",
|
||||||
|
@ -22,7 +22,9 @@ const removeIdFromValue = (string, id) => {
|
|||||||
const activity = {
|
const activity = {
|
||||||
accompanyingPeriod: null,
|
accompanyingPeriod: null,
|
||||||
socialIssues: [],
|
socialIssues: [],
|
||||||
persons: []
|
persons: [],
|
||||||
|
professionals: [],
|
||||||
|
invites: []
|
||||||
}; // TODO: get this object from window.activity ?
|
}; // TODO: get this object from window.activity ?
|
||||||
|
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
@ -86,14 +88,12 @@ const store = createStore({
|
|||||||
// ConcernedGroups
|
// ConcernedGroups
|
||||||
addPersonsInvolved(state, payload) {
|
addPersonsInvolved(state, payload) {
|
||||||
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
||||||
console.log(state)
|
|
||||||
console.log(payload)
|
|
||||||
switch (payload.result.type) {
|
switch (payload.result.type) {
|
||||||
case 'person':
|
case 'person':
|
||||||
state.activity.persons.push(payload.result);
|
state.activity.persons.push(payload.result);
|
||||||
break;
|
break;
|
||||||
case 'thirdparty':
|
case 'thirdparty':
|
||||||
state.activity.thirdParties.push(payload.result);
|
state.activity.professionals.push(payload.result);
|
||||||
break;
|
break;
|
||||||
case 'user':
|
case 'user':
|
||||||
state.activity.users.push(payload.result);
|
state.activity.users.push(payload.result);
|
||||||
@ -107,7 +107,7 @@ const store = createStore({
|
|||||||
state.activity.persons = state.activity.persons.filter(person => person !== payload);
|
state.activity.persons = state.activity.persons.filter(person => person !== payload);
|
||||||
break;
|
break;
|
||||||
case 'thirdparty':
|
case 'thirdparty':
|
||||||
state.activity.thirdParties = state.activity.thirdParties.filter(thirdparty => thirdparty !== payload);
|
state.activity.professionals = state.activity.professionals.filter(thirdparty => thirdparty !== payload);
|
||||||
break;
|
break;
|
||||||
case 'user':
|
case 'user':
|
||||||
state.activity.users = state.activity.users.filter(user => user !== payload);
|
state.activity.users = state.activity.users.filter(user => user !== payload);
|
||||||
@ -138,18 +138,18 @@ const store = createStore({
|
|||||||
commit('updateActionsSelected', payload);
|
commit('updateActionsSelected', payload);
|
||||||
},
|
},
|
||||||
addPersonsInvolved({ commit }, payload) {
|
addPersonsInvolved({ commit }, payload) {
|
||||||
//console.log('### action addPersonsInvolved', payload.result.type);
|
console.log('### action addPersonsInvolved', payload.result.type);
|
||||||
switch (payload.result.type) {
|
switch (payload.result.type) {
|
||||||
case 'person':
|
case 'person':
|
||||||
let aPersons = document.getElementById("chill_calendarbundle_calendar_persons");
|
let aPersons = document.getElementById("chill_calendarbundle_calendar_persons");
|
||||||
aPersons.value = addIdToValue(aPersons.value, payload.result.id);
|
aPersons.value = addIdToValue(aPersons.value, payload.result.id);
|
||||||
break;
|
break;
|
||||||
case 'thirdparty':
|
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);
|
aThirdParties.value = addIdToValue(aThirdParties.value, payload.result.id);
|
||||||
break;
|
break;
|
||||||
case 'user':
|
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);
|
aUsers.value = addIdToValue(aUsers.value, payload.result.id);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -163,11 +163,11 @@ const store = createStore({
|
|||||||
aPersons.value = removeIdFromValue(aPersons.value, payload.id);
|
aPersons.value = removeIdFromValue(aPersons.value, payload.id);
|
||||||
break;
|
break;
|
||||||
case 'thirdparty':
|
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);
|
aThirdParties.value = removeIdFromValue(aThirdParties.value, payload.id);
|
||||||
break;
|
break;
|
||||||
case 'user':
|
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);
|
aUsers.value = removeIdFromValue(aUsers.value, payload.id);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
{%- if form.persons is defined -%}
|
{%- if form.persons is defined -%}
|
||||||
{{ form_widget(form.persons) }}
|
{{ form_widget(form.persons) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{%- if form.professionals is defined -%}
|
||||||
|
{{ form_widget(form.professionals) }}
|
||||||
|
{% endif %}
|
||||||
{%- if form.nonProfessionals is defined -%}
|
{%- if form.nonProfessionals is defined -%}
|
||||||
{{ form_widget(form.nonProfessionals) }}
|
{{ form_widget(form.nonProfessionals) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user