mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
configure SocialIssue consistency on Activity and AccompanyingPeriod
This commit is contained in:
parent
09e5cc1545
commit
075f22e79c
@ -55,6 +55,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
$loader->load('services/controller.yaml');
|
$loader->load('services/controller.yaml');
|
||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/templating.yaml');
|
$loader->load('services/templating.yaml');
|
||||||
|
$loader->load('services/accompanyingPeriodConsistency.yaml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepend(ContainerBuilder $container)
|
public function prepend(ContainerBuilder $container)
|
||||||
|
@ -23,6 +23,7 @@ namespace Chill\ActivityBundle\Entity;
|
|||||||
use Chill\DocStoreBundle\Entity\Document;
|
use Chill\DocStoreBundle\Entity\Document;
|
||||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||||
|
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
@ -60,7 +61,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|||||||
* path="scope")
|
* path="scope")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Activity implements HasCenterInterface, HasScopeInterface
|
class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
|
||||||
{
|
{
|
||||||
const SENTRECEIVED_SENT = 'sent';
|
const SENTRECEIVED_SENT = 'sent';
|
||||||
const SENTRECEIVED_RECEIVED = 'received';
|
const SENTRECEIVED_RECEIVED = 'received';
|
||||||
@ -417,7 +418,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
return $this->persons;
|
return $this->persons;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPersonsAssociated(): array
|
public function getPersonsAssociated(): array
|
||||||
{
|
{
|
||||||
if (null !== $this->accompanyingPeriod) {
|
if (null !== $this->accompanyingPeriod) {
|
||||||
$personsAssociated = [];
|
$personsAssociated = [];
|
||||||
@ -426,11 +427,11 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
$personsAssociated[] = $participation->getPerson();
|
$personsAssociated[] = $participation->getPerson();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $personsAssociated;
|
return $personsAssociated;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPersonsNotAssociated(): array
|
public function getPersonsNotAssociated(): array
|
||||||
{
|
{
|
||||||
if (null !== $this->accompanyingPeriod) {
|
if (null !== $this->accompanyingPeriod) {
|
||||||
@ -443,7 +444,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
return $personsNotAssociated;
|
return $personsNotAssociated;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPersons(?Collection $persons): self
|
public function setPersons(?Collection $persons): self
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
services:
|
||||||
|
accompanying_period_social_issue_consistency_for_activity:
|
||||||
|
class: 'Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodSocialIssueConsistencyEntityListener'
|
||||||
|
tags:
|
||||||
|
-
|
||||||
|
name: 'doctrine.orm.entity_listener'
|
||||||
|
event: 'prePersist'
|
||||||
|
entity: 'Chill\ActivityBundle\Entity\Activity'
|
||||||
|
lazy: true
|
||||||
|
-
|
||||||
|
name: 'doctrine.orm.entity_listener'
|
||||||
|
event: 'preUpdate'
|
||||||
|
entity: 'Chill\ActivityBundle\Entity\Activity'
|
||||||
|
lazy: true
|
@ -17,7 +17,7 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|||||||
*/
|
*/
|
||||||
interface AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
|
interface AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
|
||||||
{
|
{
|
||||||
public function getAccompanyingPeriod(): AccompanyingPeriod;
|
public function getAccompanyingPeriod(): ?AccompanyingPeriod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection|SocialIssue[]
|
* @return Collection|SocialIssue[]
|
||||||
|
@ -39,14 +39,15 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListener
|
|||||||
|
|
||||||
private function ensureConsistencyEntity(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity): void
|
private function ensureConsistencyEntity(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity): void
|
||||||
{
|
{
|
||||||
|
if (NULL === $period = $entity->getAccompanyingPeriod()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// remove issues parents on the entity itself
|
// remove issues parents on the entity itself
|
||||||
$ancestors = SocialIssue::findAncestorSocialIssues($entity->getSocialIssues());
|
$ancestors = SocialIssue::findAncestorSocialIssues($entity->getSocialIssues());
|
||||||
foreach ($ancestors as $ancestor) {
|
foreach ($ancestors as $ancestor) {
|
||||||
$entity->removeSocialIssue($ancestor);
|
$entity->removeSocialIssue($ancestor);
|
||||||
}
|
}
|
||||||
|
|
||||||
$period = $entity->getAccompanyingPeriod();
|
|
||||||
|
|
||||||
foreach ($entity->getSocialIssues() as $issue) {
|
foreach ($entity->getSocialIssues() as $issue) {
|
||||||
// the entity itself test if the social issue is already associated, or not
|
// the entity itself test if the social issue is already associated, or not
|
||||||
$period->addSocialIssue($issue);
|
$period->addSocialIssue($issue);
|
||||||
|
@ -74,6 +74,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
$loader->load('services/alt_names.yaml');
|
$loader->load('services/alt_names.yaml');
|
||||||
$loader->load('services/household.yaml');
|
$loader->load('services/household.yaml');
|
||||||
$loader->load('services/notification.yaml');
|
$loader->load('services/notification.yaml');
|
||||||
|
$loader->load('services/accompanyingPeriod.yaml');
|
||||||
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
|
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
|
||||||
// We should use the PersonRepository service instead of a custom service name.
|
// We should use the PersonRepository service instead of a custom service name.
|
||||||
$loader->load('services/repository.yaml');
|
$loader->load('services/repository.yaml');
|
||||||
|
@ -71,7 +71,7 @@ const appMessages = {
|
|||||||
edit_temporary_address: "Modifier l'adresse temporaire",
|
edit_temporary_address: "Modifier l'adresse temporaire",
|
||||||
assign_course_address: "Désigner comme l'adresse du parcours",
|
assign_course_address: "Désigner comme l'adresse du parcours",
|
||||||
remove_button: "Enlever l'adresse",
|
remove_button: "Enlever l'adresse",
|
||||||
temporary_address_must_be_changed: "Cette addresse est temporaire et devrait être remplacée par celle d'un usager de référence.",
|
temporary_address_must_be_changed: "Cette adresse est temporaire et devrait être remplacée par celle d'un usager de référence.",
|
||||||
sure: "Êtes-vous sûr ?",
|
sure: "Êtes-vous sûr ?",
|
||||||
sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?",
|
sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?",
|
||||||
ok: "Désigner comme adresse du parcours",
|
ok: "Désigner comme adresse du parcours",
|
||||||
|
@ -105,8 +105,13 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
state.accompanyingCourse.initialComment = comment;
|
state.accompanyingCourse.initialComment = comment;
|
||||||
},
|
},
|
||||||
updateSocialIssues(state, value) {
|
updateSocialIssues(state, value) {
|
||||||
|
console.log('updateSocialIssues', value);
|
||||||
state.accompanyingCourse.socialIssues = value;
|
state.accompanyingCourse.socialIssues = value;
|
||||||
},
|
},
|
||||||
|
refreshSocialIssues(state, issues) {
|
||||||
|
console.log('refreshSocialIssues', issues);
|
||||||
|
state.accompanyingCourse.socialIssues = issues;
|
||||||
|
},
|
||||||
updateOrigin(state, value) {
|
updateOrigin(state, value) {
|
||||||
//console.log('value', value);
|
//console.log('value', value);
|
||||||
state.accompanyingCourse.origin = value;
|
state.accompanyingCourse.origin = value;
|
||||||
@ -226,14 +231,19 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).catch((error) => { commit('catchError', error) });
|
||||||
},
|
},
|
||||||
updateSocialIssues({ commit }, { payload, body, method }) {
|
updateSocialIssues({ state, commit }, { payload, body, method }) {
|
||||||
//console.log('## action: payload', { payload, body, method });
|
//console.log('## action: payload', { payload, body, method });
|
||||||
postSocialIssue(id, body, method)
|
postSocialIssue(id, body, method)
|
||||||
.then(response => new Promise((resolve, reject) => {
|
.then(response => new Promise((resolve, reject) => {
|
||||||
//console.log('response', response);
|
//console.log('response', response);
|
||||||
commit('updateSocialIssues', payload);
|
commit('updateSocialIssues', payload);
|
||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).then(() => {
|
||||||
|
return getAccompanyingCourse(state.accompanyingCourse.id);
|
||||||
|
}).then(accompanying_course => {
|
||||||
|
commit('refreshSocialIssues', accompanying_course.socialIssues);
|
||||||
|
})
|
||||||
|
.catch((error) => { commit('catchError', error) });
|
||||||
},
|
},
|
||||||
updateOrigin({ commit }, payload) {
|
updateOrigin({ commit }, payload) {
|
||||||
patchAccompanyingCourse(id, { type: "accompanying_period", origin: { id: payload.id, type: payload.type } })
|
patchAccompanyingCourse(id, { type: "accompanying_period", origin: { id: payload.id, type: payload.type } })
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
services:
|
||||||
|
Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodSocialIssueConsistencyEntityListener:
|
||||||
|
tags:
|
||||||
|
-
|
||||||
|
name: 'doctrine.orm.entity_listener'
|
||||||
|
event: 'prePersist'
|
||||||
|
entity: 'Chill\PersonBundle\Entity\AccompanyingPeriod'
|
||||||
|
lazy: true
|
||||||
|
method: prePersistAccompanyingPeriod
|
||||||
|
-
|
||||||
|
name: 'doctrine.orm.entity_listener'
|
||||||
|
event: 'preUpdate'
|
||||||
|
entity: 'Chill\PersonBundle\Entity\AccompanyingPeriod'
|
||||||
|
lazy: true
|
||||||
|
method: preUpdateAccompanyingPeriod
|
Loading…
x
Reference in New Issue
Block a user