Merge remote-tracking branch 'origin/master' into issue603_add_closing_motive_course

This commit is contained in:
2022-05-27 21:57:19 +02:00
55 changed files with 953 additions and 144 deletions

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
@@ -143,6 +144,12 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
*/
private Collection $persons;
/**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
*/
private PrivateCommentEmbeddable $privateComment;
/**
* @ORM\ManyToMany(targetEntity=User::class)
* @ORM\JoinTable(name="chill_person_accompanying_period_work_referrer")
@@ -202,6 +209,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
public function __construct()
{
$this->goals = new ArrayCollection();
$this->privateComment = new PrivateCommentEmbeddable();
$this->results = new ArrayCollection();
$this->thirdParties = new ArrayCollection();
$this->persons = new ArrayCollection();
@@ -328,6 +336,11 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->persons;
}
public function getPrivateComment(): PrivateCommentEmbeddable
{
return $this->privateComment;
}
/**
* @return Collection|User[]
*/
@@ -505,6 +518,13 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this;
}
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
{
$this->privateComment->merge($privateComment);
return $this;
}
public function setSocialAction(?SocialAction $socialAction): self
{
$this->socialAction = $socialAction;

View File

@@ -46,10 +46,8 @@ class SocialAction
private $desactivationDate;
/**
* @ORM\ManyToMany(
* targetEntity=Evaluation::class,
* mappedBy="socialActions"
* )
* @ORM\ManyToMany(targetEntity=Evaluation::class, inversedBy="socialActions")
* @ORM\JoinTable(name="chill_person_social_work_evaluation_action")
*/
private Collection $evaluations;
@@ -110,6 +108,15 @@ class SocialAction
return $this;
}
public function addEvaluation(Evaluation $evaluation): self
{
if (!$this->evaluations->contains($evaluation)) {
$this->evaluations[] = $evaluation;
}
return $this;
}
public function addGoal(Goal $goal): self
{
if (!$this->goals->contains($goal)) {
@@ -300,6 +307,13 @@ class SocialAction
return $this;
}
public function removeEvaluation(Evaluation $evaluation): self
{
$this->evaluations->removeElement($evaluation);
return $this;
}
public function removeGoal(Goal $goal): self
{
$this->goals->removeElement($goal);

View File

@@ -43,16 +43,6 @@ class GoalType extends AbstractType
->add('title', TranslatableStringFormType::class, [
'label' => 'Nom',
])
->add('socialActions', EntityType::class, [
'class' => SocialAction::class,
'required' => false,
'multiple' => true,
'choice_label' => function (SocialAction $issue) {
return $this->translatableStringHelper->localize($issue->getTitle());
},
])
->add('results', EntityType::class, [
'class' => Result::class,
'required' => false,
@@ -60,8 +50,8 @@ class GoalType extends AbstractType
'choice_label' => function (Result $r) {
return $this->translatableStringHelper->localize($r->getTitle());
},
'attr' => ['class' => 'select2 '],
])
->add('desactivationDate', ChillDateType::class, [
'required' => false,
'label' => 'goal.desactivationDate',

View File

@@ -253,7 +253,6 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
state.accompanyingCourse.administrativeLocation = value;
},
updateReferrer(state, value) {
//console.log('value', value);
state.accompanyingCourse.user = value;
},
updateJob(state, value) {
@@ -775,9 +774,7 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
throw error;
})
},
updateReferrer({ commit }, payload) {
console.log('update referrer', payload);
console.log('payload !== null', payload !== null);
updateReferrer({ commit, state }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`;
let body = { type: "accompanying_period", user: null };
@@ -788,7 +785,10 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateReferrer', response.user);
commit('setFilteredReferrersSuggested');
if (null !== payload.user_job && payload.user_job !== state.accompanyingCourse.job) {
this.dispatch('updateJob', payload.user_job);
}
// commit('setFilteredReferrersSuggested'); // this mutation doesn't exist?
})
.catch((error) => {
commit('catchError', error);
@@ -799,6 +799,8 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
const url = `/api/1.0/person/accompanying-course/${id}.json`;
let body = { type: "accompanying_period", job: null };
console.log('update job', payload);
if (payload !== null) {
body = { type: "accompanying_period", job: { id: payload.id, type: payload.type } };
}

View File

@@ -24,6 +24,15 @@
<input v-model="endDate" type="date" class="form-control" />
</div>
<div id="privateComment" class="action-row">
<label class="col-form-label">{{ $t('private_comment') }}</label>
<ckeditor
v-model="privateComment"
:editor="editor"
tag-name="textarea"
></ckeditor>
</div>
<div id="comment" class="action-row">
<label class="col-form-label">{{ $t('comments') }}</label>
<ckeditor
@@ -33,6 +42,7 @@
></ckeditor>
</div>
<div id="objectives" class="action-row">
<div aria="hidden" class="title">
<div><h3>{{ $t('goals_title') }}</h3></div>
@@ -141,12 +151,12 @@
<ul class="list-unstyled">
<li v-for="p in personsReachables" :key="p.id">
<div class="form-check">
<input v-model="personsPicked" :value="p.id" type="checkbox" class="me-2 form-check-input" :id="'person_check'+p.id">
<label :for="'person_check'+p.id" class="form-check-label">
<person-text :person="p"></person-text>
</label>
</div>
<div class="form-check">
<input v-model="personsPicked" :value="p.id" type="checkbox" class="me-2 form-check-input" :id="'person_check'+p.id">
<label :for="'person_check'+p.id" class="form-check-label">
<person-text :person="p"></person-text>
</label>
</div>
</li>
</ul>
</div>
@@ -274,18 +284,18 @@
</div>
</div>
<ul class="record_actions sticky-form-buttons">
<li>
<list-workflow-modal
:workflows="this.work.workflows"
:allowCreate="true"
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork"
:relatedEntityId="this.work.id"
:workflowsAvailables="this.work.workflows_availables"
:preventDefaultMoveToGenerate="true"
@go-to-generate-workflow="goToGenerateWorkflow"
></list-workflow-modal>
</li>
<ul class="record_actions sticky-form-buttons">
<li>
<list-workflow-modal
:workflows="this.work.workflows"
:allowCreate="true"
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork"
:relatedEntityId="this.work.id"
:workflowsAvailables="this.work.workflows_availables"
:preventDefaultMoveToGenerate="true"
@go-to-generate-workflow="goToGenerateWorkflow"
></list-workflow-modal>
</li>
<li v-if="!isPosting">
<button class="btn btn-save" @click="submit">
@@ -355,7 +365,8 @@ const i18n = {
referrers: "Agents traitants",
no_referrers: "Aucun agent traitant",
choose_referrers: "Choisir des agents traitants",
remove_referrer: "Enlever l'agent"
remove_referrer: "Enlever l'agent",
private_comment: "Commentaire privé"
}
}
};
@@ -417,8 +428,8 @@ export default {
},
};
},
computed: {
...mapState([
computed: {
...mapState([
'work',
'resultsForAction',
'evaluationsForAction',
@@ -461,6 +472,14 @@ export default {
this.$store.commit('setNote', v);
}
},
privateComment: {
get() {
return this.$store.state.privateComment;
},
set(v) {
this.$store.commit('setPrivateComment', v);
}
},
availableForCheckGoal() {
let pickedIds = this.$store.state.goalsPicked.map(g => g.goal.id);
@@ -573,6 +592,7 @@ div#workEditor {
"title title"
"startDate endDate"
"comment comment"
"privateComment privateComment"
"objectives objectives"
"evaluations evaluations"
"persons persons"
@@ -589,6 +609,8 @@ div#workEditor {
grid-area: endDate; }
#comment {
grid-area: comment; }
#privateComment {
grid-area: privateComment; }
#objectives {
grid-area: objectives; }
#evaluations {

View File

@@ -17,6 +17,7 @@ const store = createStore({
endDate: window.accompanyingCourseWork.endDate !== null ?
dateToISO(new Date(window.accompanyingCourseWork.endDate.datetime)) : null,
note: window.accompanyingCourseWork.note,
privateComment: window.accompanyingCourseWork.privateComment,
goalsPicked: window.accompanyingCourseWork.goals,
goalsForAction: [],
resultsPicked: window.accompanyingCourseWork.results,
@@ -79,6 +80,7 @@ const store = createStore({
datetime: datetimeToISO(ISOToDate(state.endDate))
},
note: state.note,
privateComment: state.privateComment,
persons: state.personsPicked.map(p => ({id: p.id, type: p.type})),
handlingThierParty: state.handlingThirdParty === null ? null : {
id: state.handlingThirdParty.id,
@@ -297,6 +299,9 @@ const store = createStore({
setNote(state, note) {
state.note = note;
},
setPrivateComment(state, privateComment) {
state.privateComment = privateComment;
},
setHandlingThirdParty(state, thirdParty) {
state.handlingThirdParty = thirdParty;
},
@@ -454,6 +459,8 @@ const store = createStore({
;
commit('setIsPosting', true);
console.log('payload', payload);
return makeFetch('PUT', url, payload)
.then(data => {
if (typeof(callback) !== 'undefined') {

View File

@@ -305,7 +305,8 @@ export default {
if (this.listenPersonFlag === 'normal') {
if (person.folded === true) {
//console.log(' @@> expand mode event')
this.$store.commit('unfoldPerson', person)
this.$store.commit('unfoldPerson', person);
this.$store.dispatch('fetchInfoForPerson', person);
}
} else {
//console.log(' @@> create link mode event')

View File

@@ -252,7 +252,6 @@ const store = createStore({
if (!person.folded) {
return;
}
//console.log('unfoldPerson', person)
person.label = person._label
delete person._label
delete person.title

View File

@@ -5,7 +5,6 @@
{% block table_entities_thead_tr %}
<th>{{ 'Id'|trans }}</th>
<th>{{ 'Title'|trans }}</th>
<th>{{ 'Social actions'|trans }}</th>
<th>{{ 'goal.results'|trans }}</th>
<th>{{ 'goal.desactivationDate'|trans }}</th>
<th>&nbsp;</th>
@@ -17,11 +16,6 @@
<td>{{ entity.id }}</td>
<td>{{ entity.title|localize_translatable_string }}</td>
<td>
{% for sa in entity.socialActions %}
{{ sa.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
{% endfor %}
</td>
<td>
{% for sa in entity.results %}
{{ sa.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
{% endfor %}

View File

@@ -8,9 +8,20 @@
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
{% block crud_content_form_rows %}
<div class="mb-3 row">
<label class="col-form-label col-sm-4 required" for="social_action_ordering">{{ 'Parent'|trans }}</label>
<div class="col-sm-8">{{ entity.parent|chill_entity_render_box }}</div>
</div>
<div class="mb-3 row">
<label class="col-form-label col-sm-4 required" for="social_action_ordering">{{ 'Social issue'|trans }}</label>
<div class="col-sm-8">{{ entity.issue|chill_entity_render_box }}</div>
</div>
{% for f in form %}
{% if f.vars.name == 'parent' or f.vars.name == 'issue' %}
{{ form_row(f, { 'attr':{'disabled':'disabled'}}) }}
{{ form_widget(f, { 'attr':{'hidden':'hidden'}}) }}
{% else %}
{{ form_row(f) }}
{% endif %}

View File

@@ -17,6 +17,7 @@ use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
use Chill\DocStoreBundle\Entity\DocumentCategory;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Repository\DocumentCategoryRepository;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
@@ -132,7 +133,7 @@ class AccompanyingPeriodContext implements
])
->add('category', EntityType::class, [
'placeholder' => 'Choose a document category',
'class' => 'ChillDocStoreBundle:DocumentCategory',
'class' => DocumentCategory::class,
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.documentClass = :docClass')

View File

@@ -15,6 +15,7 @@ use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithAdminFormInterface;
use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
use Chill\DocStoreBundle\Entity\DocumentCategory;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Repository\DocumentCategoryRepository;
@@ -92,7 +93,7 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface
$builder
->add('category', EntityType::class, [
'placeholder' => 'Choose a document category',
'class' => 'ChillDocStoreBundle:DocumentCategory',
'class' => DocumentCategory::class,
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.documentClass = :docClass')

View File

@@ -223,6 +223,8 @@ components:
- "accompanying_period_work"
note:
type: string
privateComment:
type: string
startDate:
$ref: "#/components/schemas/Date"
endDate:

View File

@@ -0,0 +1,33 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20220527124737 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE activity DROP privateComment_comments');
}
public function getDescription(): string
{
return 'add private comment on accompanying period work';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period_work ADD privateComment_comments JSON DEFAULT \'{}\'');
}
}

View File

@@ -609,6 +609,8 @@ accompanying_course_work:
Any work: Aucune action d'accompagnement
remove: Supprimer une action d'accompagnement
social_evaluation: Évaluation
private_comment: Commentaire privé
#
Person addresses: Adresses de résidence