diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php
index b0a84fa4e..eb1a8386e 100644
--- a/src/Bundle/ChillActivityBundle/Entity/Activity.php
+++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php
@@ -106,12 +106,14 @@ class Activity implements HasCenterInterface, HasScopeInterface
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
+ * @Groups({"read"})
*/
private $socialIssues;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
+ * @Groups({"read"})
*/
private $socialActions;
diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php
index 22bd45658..80d0991e7 100644
--- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php
+++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php
@@ -112,31 +112,45 @@ class ActivityType extends AbstractType
}
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
- $builder->add('socialIssues', EntityType::class, [
- 'label' => $activityType->getLabel('socialIssues'),
- 'required' => $activityType->isRequired('socialIssues'),
- 'class' => SocialIssue::class,
- 'choice_label' => function (SocialIssue $socialIssue) {
- return $this->socialIssueRender->renderString($socialIssue, []);
- },
- 'multiple' => true,
- 'choices' => $accompanyingPeriod->getRecursiveSocialIssues(),
- 'expanded' => true,
- ]);
+ $builder->add('socialIssues', HiddenType::class);
+ $builder->get('socialIssues')
+ ->addModelTransformer(new CallbackTransformer(
+ function (iterable $socialIssuesAsIterable): string {
+ $socialIssueIds = [];
+ foreach ($socialIssuesAsIterable as $value) {
+ $socialIssueIds[] = $value->getId();
+ }
+ return implode(',', $socialIssueIds);
+ },
+ function (?string $socialIssuesAsString): array {
+ return array_map(
+ fn(string $id): ?SocialIssue => $this->om->getRepository(SocialIssue::class)->findOneBy(['id' => (int) $id]),
+ explode(',', $socialIssuesAsString)
+ );
+ }
+ ))
+ ;
}
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
- $builder->add('socialActions', EntityType::class, [
- 'label' => $activityType->getLabel('socialActions'),
- 'required' => $activityType->isRequired('socialActions'),
- 'class' => SocialAction::class,
- 'choice_label' => function (SocialAction $socialAction) {
- return $this->socialActionRender->renderString($socialAction, []);
- },
- 'multiple' => true,
- 'choices' => $accompanyingPeriod->getRecursiveSocialActions(),
- 'expanded' => true,
- ]);
+ $builder->add('socialActions', HiddenType::class);
+ $builder->get('socialActions')
+ ->addModelTransformer(new CallbackTransformer(
+ function (iterable $socialActionsAsIterable): string {
+ $socialActionIds = [];
+ foreach ($socialActionsAsIterable as $value) {
+ $socialActionIds[] = $value->getId();
+ }
+ return implode(',', $socialActionIds);
+ },
+ function (?string $socialActionsAsString): array {
+ return array_map(
+ fn(string $id): ?SocialAction => $this->om->getRepository(SocialAction::class)->findOneBy(['id' => (int) $id]),
+ explode(',', $socialActionsAsString)
+ );
+ }
+ ))
+ ;
}
if ($activityType->isVisible('date')) {
@@ -210,9 +224,7 @@ class ActivityType extends AbstractType
}
if ($activityType->isVisible('persons')) {
- $builder->add('persons', HiddenType::class, [
- //'data_class' => Person::class,
- ]);
+ $builder->add('persons', HiddenType::class);
$builder->get('persons')
->addModelTransformer(new CallbackTransformer(
function (iterable $personsAsIterable): string {
@@ -233,9 +245,7 @@ class ActivityType extends AbstractType
}
if ($activityType->isVisible('thirdParties')) {
- $builder->add('thirdParties', HiddenType::class, [
- //'data_class' => ThirdParty::class,
- ]);
+ $builder->add('thirdParties', HiddenType::class);
$builder->get('thirdParties')
->addModelTransformer(new CallbackTransformer(
function (iterable $thirdpartyAsIterable): string {
@@ -267,9 +277,7 @@ class ActivityType extends AbstractType
}
if ($activityType->isVisible('users')) {
- $builder->add('users', HiddenType::class, [
- //'data_class' => User::class,
- ]);
+ $builder->add('users', HiddenType::class);
$builder->get('users')
->addModelTransformer(new CallbackTransformer(
function (iterable $usersAsIterable): string {
diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue
index bf8467c2b..07fe84319 100644
--- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue
+++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue
@@ -1,170 +1,17 @@
-
+
+
+
diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc/CheckSocialIssue.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc/CheckSocialIssue.vue
new file mode 100644
index 000000000..0f223eced
--- /dev/null
+++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc/CheckSocialIssue.vue
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js
index 778072e61..3262a37a5 100644
--- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js
+++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js
@@ -3,6 +3,13 @@ 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",
diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js
index 4f30cf516..9684ab375 100644
--- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js
+++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js
@@ -21,11 +21,65 @@ const removeIdFromValue = (string, id) => {
const store = createStore({
strict: debug,
state: {
- activity: window.activity
- },
- getters: {
+ activity: window.activity,
+ socialIssuesOther: [],
+ socialActionsList: [],
},
mutations: {
+
+ // SocialIssueAcc
+ addIssueInList(state, issue) {
+ console.log('add list issue', issue.id);
+ state.activity.accompanyingPeriod.socialIssues.push(issue);
+ },
+ addIssueSelected(state, issue) {
+ console.log('add selected issue', issue.id);
+ state.activity.socialIssues.push(issue);
+ },
+ updateIssuesSelected(state, issues) {
+ console.log('update selected issues', issues);
+ state.activity.socialIssues = issues;
+ },
+ updateIssuesOther(state, payload) {
+ console.log('update other issues');
+ state.socialIssuesOther = payload;
+ },
+ removeIssueInOther(state, issue) {
+ console.log('remove other issue', issue.id);
+ state.socialIssuesOther = state.socialIssuesOther.filter(item => item !== issue);
+ },
+ resetActionsList(state) {
+ console.log('reset actions list');
+ state.socialActionsList = [];
+ },
+ addActionInList(state, action) {
+ console.log('add list action', action.id);
+ state.socialActionsList.push(action);
+ },
+ updateActionsSelected(state, actions) {
+ console.log('update selected actions', actions);
+ state.activity.socialActions = actions;
+ },
+ filterList(state, list) {
+ const filterList = (list) => {
+ console.log('filter ' + list.length + ' items: uniq'); // grr !!!
+ // TODO un filtrage qui enlève les doublons
+ //list = list.filter((v, i, a) => a.indexOf(v) === i);
+ let _list = [...new Set(list)];
+
+ console.log('filter ' + list.length + ' items: sort', list);
+ _list.sort((a,b) => (a.text > b.text) ? 1 : ((b.text > a.text) ? -1 : 0));
+ return _list;
+ };
+ if (list === 'issues') {
+ state.activity.accompanyingPeriod.socialIssues = filterList(state.activity.accompanyingPeriod.socialIssues);
+ }
+ if (list === 'actions') {
+ state.socialActionsList = filterList(state.socialActionsList);
+ }
+ },
+
+ // ConcernedGroups
addPersonsInvolved(state, payload) {
//console.log('### mutation addPersonsInvolved', payload.result.type);
switch (payload.result.type) {
@@ -56,8 +110,29 @@ const store = createStore({
}
},
actions: {
+ addIssueSelected({ commit }, issue) {
+ let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
+ aSocialIssues.value = addIdToValue(aSocialIssues.value, issue.id);
+ commit('addIssueSelected', issue);
+ },
+ updateIssuesSelected({ commit }, payload) {
+ let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
+ aSocialIssues.value = '';
+ payload.forEach(item => {
+ aSocialIssues.value = addIdToValue(aSocialIssues.value, item.id);
+ });
+ commit('updateIssuesSelected', payload);
+ },
+ updateActionsSelected({ commit }, payload) {
+ let aSocialActions = document.getElementById("chill_activitybundle_activity_socialActions");
+ aSocialActions.value = '';
+ payload.forEach(item => {
+ aSocialActions.value = addIdToValue(aSocialActions.value, item.id);
+ });
+ 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_activitybundle_activity_persons");
@@ -75,7 +150,7 @@ const store = createStore({
commit('addPersonsInvolved', payload);
},
removePersonInvolved({ commit }, payload) {
- console.log('### action removePersonInvolved', payload);
+ //console.log('### action removePersonInvolved', payload);
switch (payload.type) {
case 'person':
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig
index 3024148e1..56a7c96b4 100644
--- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig
+++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig
@@ -1,4 +1,8 @@
-