mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add involved persons to accompanying period work
This commit is contained in:
parent
0754d20622
commit
154fa4719d
@ -4,6 +4,7 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
@ -148,11 +149,22 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
*/
|
*/
|
||||||
private Collection $thirdParties;
|
private Collection $thirdParties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @ORM\ManyToMany(targetEntity=Person::class)
|
||||||
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_person")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||||
|
* @Serializer\Groups({"accompanying_period_work:create"})
|
||||||
|
*/
|
||||||
|
private Collection $persons;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->goals = new ArrayCollection();
|
$this->goals = new ArrayCollection();
|
||||||
$this->results = new ArrayCollection();
|
$this->results = new ArrayCollection();
|
||||||
$this->thirdParties = new ArrayCollection();
|
$this->thirdParties = new ArrayCollection();
|
||||||
|
$this->persons = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
@ -390,4 +402,25 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPersons(): Collection
|
||||||
|
{
|
||||||
|
return $this->persons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPerson(Person $person): self
|
||||||
|
{
|
||||||
|
if (!$this->persons->contains($person)) {
|
||||||
|
$this->persons[] = $person;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removePerson(Person $person): self
|
||||||
|
{
|
||||||
|
$this->persons->removeElement($person);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,19 @@
|
|||||||
<div v-if="isLoadingSocialActions">
|
<div v-if="isLoadingSocialActions">
|
||||||
<p>spinner</p>
|
<p>spinner</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<div v-if="hasSocialActionPicked" id="persons">
|
||||||
|
<h2>{{ $t('persons_involved') }}</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li v-for="p in personsReachables" :key="p.id">
|
||||||
|
<input type="checkbox" :value="p.id" v-model="personsPicked">
|
||||||
|
<person :person="p"></person>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
<div v-if="hasSocialActionPicked" id="start_date">
|
<div v-if="hasSocialActionPicked" id="start_date">
|
||||||
<p><label>{{ $t('startDate') }}</label> <input type="date" v-model="startDate" /></p>
|
<p><label>{{ $t('startDate') }}</label> <input type="date" v-model="startDate" /></p>
|
||||||
</div>
|
</div>
|
||||||
@ -85,6 +96,14 @@
|
|||||||
|
|
||||||
#picking {
|
#picking {
|
||||||
grid-area: picking;
|
grid-area: picking;
|
||||||
|
|
||||||
|
#persons {
|
||||||
|
ul {
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#start_date {
|
#start_date {
|
||||||
@ -105,6 +124,7 @@
|
|||||||
import { mapState, mapActions, mapGetters } from 'vuex';
|
import { mapState, mapActions, mapGetters } from 'vuex';
|
||||||
import VueMultiselect from 'vue-multiselect';
|
import VueMultiselect from 'vue-multiselect';
|
||||||
import { dateToISO, ISOToDate } from 'ChillMainAssets/js/date.js';
|
import { dateToISO, ISOToDate } from 'ChillMainAssets/js/date.js';
|
||||||
|
import Person from 'ChillPersonAssets/vuejs/_components/Person/Person.vue';
|
||||||
|
|
||||||
const i18n = {
|
const i18n = {
|
||||||
messages: {
|
messages: {
|
||||||
@ -115,6 +135,7 @@ const i18n = {
|
|||||||
pick_social_issue: "Choisir une problématique sociale",
|
pick_social_issue: "Choisir une problématique sociale",
|
||||||
pick_an_action: "Choisir une action d'accompagnement",
|
pick_an_action: "Choisir une action d'accompagnement",
|
||||||
pick_social_issue_linked_with_action: "Indiquez la problématique sociale liée à l'action d'accompagnement",
|
pick_social_issue_linked_with_action: "Indiquez la problématique sociale liée à l'action d'accompagnement",
|
||||||
|
persons_involved: "Usagers concernés",
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,6 +145,7 @@ export default {
|
|||||||
name: 'App',
|
name: 'App',
|
||||||
components: {
|
components: {
|
||||||
VueMultiselect,
|
VueMultiselect,
|
||||||
|
Person,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
@ -136,6 +158,7 @@ export default {
|
|||||||
'socialIssues',
|
'socialIssues',
|
||||||
'socialActionsReachables',
|
'socialActionsReachables',
|
||||||
'errors',
|
'errors',
|
||||||
|
'personsReachables',
|
||||||
]),
|
]),
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'hasSocialIssuePicked',
|
'hasSocialIssuePicked',
|
||||||
@ -144,6 +167,18 @@ export default {
|
|||||||
'isPostingWork',
|
'isPostingWork',
|
||||||
'hasErrors',
|
'hasErrors',
|
||||||
]),
|
]),
|
||||||
|
personsPicked: {
|
||||||
|
get() {
|
||||||
|
let s = this.$store.state.personsPicked.map(p => p.id);
|
||||||
|
console.log('persons picked', s);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
},
|
||||||
|
set(v) {
|
||||||
|
console.log('persons picked', v);
|
||||||
|
this.$store.commit('setPersonsPickedIds', v);
|
||||||
|
}
|
||||||
|
},
|
||||||
socialIssuePicked: {
|
socialIssuePicked: {
|
||||||
get() {
|
get() {
|
||||||
let s = this.$store.state.socialIssuePicked;
|
let s = this.$store.state.socialIssuePicked;
|
||||||
|
@ -14,6 +14,10 @@ const store = createStore({
|
|||||||
socialIssuePicked: null,
|
socialIssuePicked: null,
|
||||||
socialActionsReachables: [],
|
socialActionsReachables: [],
|
||||||
socialActionPicked: null,
|
socialActionPicked: null,
|
||||||
|
personsPicked: window.accompanyingCourse.participations.filter(p => p.endDate == null)
|
||||||
|
.map(p => p.person),
|
||||||
|
personsReachables: window.accompanyingCourse.participations.filter(p => p.endDate == null)
|
||||||
|
.map(p => p.person),
|
||||||
startDate: new Date(),
|
startDate: new Date(),
|
||||||
endDate: null,
|
endDate: null,
|
||||||
isLoadingSocialActions: false,
|
isLoadingSocialActions: false,
|
||||||
@ -44,9 +48,17 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
startDate: {
|
startDate: {
|
||||||
datetime: datetimeToISO(state.startDate)
|
datetime: datetimeToISO(state.startDate)
|
||||||
}
|
},
|
||||||
|
persons: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for (let i in state.personsPicked) {
|
||||||
|
payload.persons.push({
|
||||||
|
id: state.personsPicked[i].id,
|
||||||
|
type: 'person'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== state.endDate) {
|
if (null !== state.endDate) {
|
||||||
payload.endDate = {
|
payload.endDate = {
|
||||||
datetime: datetimeToISO(state.endDate)
|
datetime: datetimeToISO(state.endDate)
|
||||||
@ -71,12 +83,16 @@ const store = createStore({
|
|||||||
state.socialActionPicked = socialAction;
|
state.socialActionPicked = socialAction;
|
||||||
},
|
},
|
||||||
setSocialIssue(state, socialIssueId) {
|
setSocialIssue(state, socialIssueId) {
|
||||||
|
console.log('set social issue', socialIssueId);
|
||||||
if (socialIssueId === null) {
|
if (socialIssueId === null) {
|
||||||
state.socialIssuePicked = null;
|
state.socialIssuePicked = null;
|
||||||
return;
|
} else {
|
||||||
|
let mapped = state.socialIssues
|
||||||
|
.find(e => e.id === socialIssueId);
|
||||||
|
console.log('mapped', mapped);
|
||||||
|
state.socialIssuePicked = mapped;
|
||||||
|
console.log('social issue setted', state.socialIssuePicked);
|
||||||
}
|
}
|
||||||
state.socialIssuePicked = state.socialIssues
|
|
||||||
.find(e => e.id === socialIssueId);
|
|
||||||
},
|
},
|
||||||
setIsLoadingSocialActions(state, s) {
|
setIsLoadingSocialActions(state, s) {
|
||||||
state.isLoadingSocialActions = s;
|
state.isLoadingSocialActions = s;
|
||||||
@ -90,6 +106,11 @@ const store = createStore({
|
|||||||
setEndDate(state, date) {
|
setEndDate(state, date) {
|
||||||
state.endDate = date;
|
state.endDate = date;
|
||||||
},
|
},
|
||||||
|
setPersonsPickedIds(state, ids) {
|
||||||
|
console.log('persons ids', ids);
|
||||||
|
state.personsPicked = state.personsReachables
|
||||||
|
.filter(p => ids.includes(p.id))
|
||||||
|
},
|
||||||
addErrors(state, { errors, cancel_posting }) {
|
addErrors(state, { errors, cancel_posting }) {
|
||||||
console.log('add errors', errors);
|
console.log('add errors', errors);
|
||||||
state.errors = errors;
|
state.errors = errors;
|
||||||
@ -103,8 +124,10 @@ const store = createStore({
|
|||||||
console.log('pick social issue');
|
console.log('pick social issue');
|
||||||
|
|
||||||
commit('setIsLoadingSocialActions', true);
|
commit('setIsLoadingSocialActions', true);
|
||||||
commit('setSocialIssue', null);
|
commit('setSocialAction', null);
|
||||||
commit('setSocialActionsReachables', []);
|
commit('setSocialActionsReachables', []);
|
||||||
|
commit('setSocialIssue', null);
|
||||||
|
|
||||||
|
|
||||||
findSocialActionsBySocialIssue(socialIssueId).then(
|
findSocialActionsBySocialIssue(socialIssueId).then(
|
||||||
(response) => {
|
(response) => {
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add link to accompanying period work and persons
|
||||||
|
*/
|
||||||
|
final class Version20210623135043 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add link to accompanying period work and persons';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql("CREATE TABLE chill_person_accompanying_period_work_person (accompanyingperiodwork_id INT NOT NULL, person_id INT NOT NULL, PRIMARY KEY(accompanyingperiodwork_id, person_id))");
|
||||||
|
$this->addSql("CREATE INDEX IDX_615F494CB99F6060 ON chill_person_accompanying_period_work_person (accompanyingperiodwork_id)");
|
||||||
|
$this->addSql("CREATE INDEX IDX_615F494C217BBB47 ON chill_person_accompanying_period_work_person (person_id)");
|
||||||
|
$this->addSql("ALTER TABLE chill_person_accompanying_period_work_person ADD CONSTRAINT FK_615F494CB99F6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE");
|
||||||
|
$this->addSql("ALTER TABLE chill_person_accompanying_period_work_person ADD CONSTRAINT FK_615F494C217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql("DROP TABLE chill_person_accompanying_period_work_person");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user