diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php
index b0a84fa4e..fbd10e723 100644
--- a/src/Bundle/ChillActivityBundle/Entity/Activity.php
+++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php
@@ -106,15 +106,16 @@ 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;
+ private Collection $socialIssues;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
+ * @Groups({"read"})
*/
- private $socialActions;
-
+ private Collection $socialActions;
/**
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
@@ -281,7 +282,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
return $this->socialIssues;
}
- public function addSocialIssue(SocialIssue $socialIssue): self
+ public function addSocialIssue(?SocialIssue $socialIssue): self
{
if (!$this->socialIssues->contains($socialIssue)) {
$this->socialIssues[] = $socialIssue;
@@ -297,15 +298,12 @@ class Activity implements HasCenterInterface, HasScopeInterface
return $this;
}
- /**
- * @return Collection|SocialAction[]
- */
public function getSocialActions(): Collection
{
return $this->socialActions;
}
- public function addSocialAction(SocialAction $socialAction): self
+ public function addSocialAction(?SocialAction $socialAction): self
{
if (!$this->socialActions->contains($socialAction)) {
$this->socialActions[] = $socialAction;
diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php
index 22bd45658..3ad204f18 100644
--- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php
+++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php
@@ -112,31 +112,51 @@ 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 {
+ if (null === $socialIssuesAsString) {
+ return [];
+ }
+ 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 {
+ if (null === $socialActionsAsString) {
+ return [];
+ }
+ return array_map(
+ fn(string $id): ?SocialAction => $this->om->getRepository(SocialAction::class)->findOneBy(['id' => (int) $id]),
+ explode(',', $socialActionsAsString)
+ );
+ }
+ ))
+ ;
}
if ($activityType->isVisible('date')) {
@@ -210,9 +230,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 +251,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 +283,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/scss/chillactivity.scss b/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss
index 64fd1cb18..ed54ce27a 100644
--- a/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss
+++ b/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss
@@ -112,3 +112,19 @@ div.flex-table.list-records {
margin-top: 1em;
}
}
+
+div.activity-row {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: center;
+ gap: 12px;
+ div.bloc {
+ width: 200px;
+ align-self: flex-end;
+ height: 140px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+}
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..c87573797 100644
--- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js
+++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js
@@ -21,11 +21,62 @@ 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 issue list', issue.id);
+ state.activity.accompanyingPeriod.socialIssues.push(issue);
+ },
+ addIssueSelected(state, issue) {
+ //console.log('add issue selected', issue.id);
+ state.activity.socialIssues.push(issue);
+ },
+ updateIssuesSelected(state, issues) {
+ //console.log('update issues selected', issues);
+ state.activity.socialIssues = issues;
+ },
+ updateIssuesOther(state, payload) {
+ //console.log('update issues other');
+ state.socialIssuesOther = payload;
+ },
+ removeIssueInOther(state, issue) {
+ //console.log('remove issue other', issue.id);
+ state.socialIssuesOther = state.socialIssuesOther.filter(i => i.id !== issue.id);
+ },
+ resetActionsList(state) {
+ //console.log('reset list actions');
+ state.socialActionsList = [];
+ },
+ addActionInList(state, action) {
+ //console.log('add action list', action.id);
+ state.socialActionsList.push(action);
+ },
+ updateActionsSelected(state, actions) {
+ //console.log('update actions selected', actions);
+ state.activity.socialActions = actions;
+ },
+ filterList(state, list) {
+ const filterList = (list) => {
+ // remove duplicates entries
+ list = list.filter((value, index) => list.findIndex(array => array.id === value.id) === index);
+ // alpha sort
+ 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 +107,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 +147,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 @@
-