Merge conflicts resolved

This commit is contained in:
Julie Lenaerts 2022-01-27 11:34:57 +01:00
commit 3fd4c6339a
23 changed files with 249 additions and 180 deletions

View File

@ -61,7 +61,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
/** /**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
* @Groups({"read", "docgen:read"}) * @Groups({"read"})
*/ */
private ?AccompanyingPeriod $accompanyingPeriod = null; private ?AccompanyingPeriod $accompanyingPeriod = null;
@ -75,16 +75,19 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
/** /**
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence")
* @Groups({"docgen:read"})
*/ */
private ?ActivityPresence $attendee = null; private ?ActivityPresence $attendee = null;
/** /**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
* @Groups({"docgen:read"})
*/ */
private CommentEmbeddable $comment; private CommentEmbeddable $comment;
/** /**
* @ORM\Column(type="datetime") * @ORM\Column(type="datetime")
* @Groups({"docgen:read"})
*/ */
private DateTime $date; private DateTime $date;
@ -100,6 +103,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
/** /**
* @ORM\Column(type="boolean", options={"default": false}) * @ORM\Column(type="boolean", options={"default": false})
* @Groups({"docgen:read"})
*/ */
private bool $emergency = false; private bool $emergency = false;
@ -130,16 +134,19 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
/** /**
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
* @Groups({"docgen:read"})
*/ */
private Collection $reasons; private Collection $reasons;
/** /**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
* @Groups({"docgen:read"})
*/ */
private ?Scope $scope = null; private ?Scope $scope = null;
/** /**
* @ORM\Column(type="string", options={"default": ""}) * @ORM\Column(type="string", options={"default": ""})
* @Groups({"docgen:read"})
*/ */
private string $sentReceived = ''; private string $sentReceived = '';
@ -170,12 +177,13 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
/** /**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @Groups({"docgen:read"})
*/ */
private User $user; private User $user;
/** /**
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
*/ */
private ?Collection $users = null; private ?Collection $users = null;
@ -302,6 +310,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
return $this->documents; return $this->documents;
} }
/**
* @Groups({"docgen:read"})
*/
public function getDurationMinute(): int
{
if (null === $this->durationTime) {
return 0;
}
return (int) round(($this->durationTime->getTimestamp() + $this->durationTime->getOffset()) / 60.0, 0);
}
public function getDurationTime(): ?DateTime public function getDurationTime(): ?DateTime
{ {
return $this->durationTime; return $this->durationTime;
@ -402,6 +422,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
return $this->travelTime; return $this->travelTime;
} }
/**
* @Groups({"docgen:read"})
*/
public function getTravelTimeMinute(): int
{
if (null === $this->travelTime) {
return 0;
}
return (int) round(($this->travelTime->getTimestamp() + $this->travelTime->getOffset()) / 60.0, 0);
}
/** /**
* @deprecated * @deprecated
*/ */

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Entity; namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/** /**
* Class ActivityPresence. * Class ActivityPresence.
@ -31,11 +32,14 @@ class ActivityPresence
* @ORM\Id * @ORM\Id
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"docgen:read"})
*/ */
private ?int $id; private ?int $id;
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")
* @Serializer\Groups({"docgen:read"})
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/ */
private array $name = []; private array $name = [];

View File

@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException; use InvalidArgumentException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -118,6 +119,7 @@ class ActivityType
* @ORM\Id * @ORM\Id
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"docgen:read"})
*/ */
private ?int $id; private ?int $id;
@ -133,7 +135,8 @@ class ActivityType
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/ */
private array $name = []; private array $name = [];

View File

@ -17,7 +17,7 @@
<select class="form-select" v-model="template"> <select class="form-select" v-model="template">
<option disabled selected value="">{{ $t('choose_a_template') }}</option> <option disabled selected value="">{{ $t('choose_a_template') }}</option>
<template v-for="t in templates"> <template v-for="t in templates">
<option v-bind:value="t.id">{{ t.name.fr }}</option> <option v-bind:value="t.id">{{ t.name.fr || 'Aucun nom défini' }}</option>
</template> </template>
</select> </select>
<button v-if="canGenerate" class="btn btn-update btn-sm change-icon" type="button" @click="generateDocument"><i class="fa fa-fw fa-cog"></i></button> <button v-if="canGenerate" class="btn btn-update btn-sm change-icon" type="button" @click="generateDocument"><i class="fa fa-fw fa-cog"></i></button>
@ -48,6 +48,7 @@ export default {
required: true, required: true,
}, },
templates: { templates: {
type: Array,
required: true, required: true,
}, },
// beforeMove execute "something" before // beforeMove execute "something" before
@ -73,7 +74,11 @@ export default {
return true; return true;
}, },
getDescription() { getDescription() {
return this.templates.find(t => t.id === this.template).description || ''; let desc = this.templates.find(t => t.id === this.template);
if (null === desc) {
return '';
}
return desc.description || '';
}, },
}, },
methods: { methods: {

View File

@ -64,7 +64,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
/** /**
* @ORM\Column(type="string", length=255, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Groups({"read", "write"}) * @Serializer\Groups({"read", "write", "docgen:read"})
*/ */
private ?string $email = null; private ?string $email = null;

View File

@ -45,8 +45,6 @@ class EntityToJsonTransformer implements DataTransformerInterface
{ {
$denormalized = json_decode($value, true); $denormalized = json_decode($value, true);
dump($value);
if ($this->multiple) { if ($this->multiple) {
if (null === $denormalized) { if (null === $denormalized) {
return []; return [];

View File

@ -7,7 +7,6 @@ const i18n = _createI18n(appMessages);
let appsOnPage = new Map(); let appsOnPage = new Map();
function loadDynamicPicker(element) { function loadDynamicPicker(element) {
let apps = element.querySelectorAll('[data-module="pick-dynamic"]'); let apps = element.querySelectorAll('[data-module="pick-dynamic"]');
@ -75,23 +74,23 @@ function loadDynamicPicker(element) {
} }
// document.addEventListener('show-hide-show', function(e) { document.addEventListener('show-hide-show', function(e) {
// console.log('creation event caught') console.log('creation event caught')
// loadDynamicPicker(e.detail.container) loadDynamicPicker(e.detail.container)
// }) })
// document.addEventListener('show-hide-hide', function(e) { document.addEventListener('show-hide-hide', function(e) {
// console.log('hiding event caught') console.log('hiding event caught')
// e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => { e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => {
// let uniqId = el.dataset.uniqid; let uniqId = el.dataset.uniqid;
// console.log(uniqId); console.log(uniqId);
// if (appsOnPage.has(uniqId)) { if (appsOnPage.has(uniqId)) {
// appsOnPage.get(uniqId).unmount(); appsOnPage.get(uniqId).unmount();
// console.log('App has been unmounted') console.log('App has been unmounted')
// appsOnPage.delete(uniqId); appsOnPage.delete(uniqId);
// } }
// }) })
// }) })
document.addEventListener('DOMContentLoaded', function(e) { document.addEventListener('DOMContentLoaded', function(e) {
console.log('loaded event', e) console.log('loaded event', e)

View File

@ -0,0 +1,88 @@
<?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\MainBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\UserRepository;
use DateTime;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use function array_key_exists;
class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
/**
* @param CommentEmbeddable $object
*
* @throws ExceptionInterface
*/
public function normalize($object, ?string $format = null, array $context = []): array
{
if (null === $object) {
return [
'comment' => '',
'isNull' => true,
'date' => $this->normalizer->normalize(null, $format, array_merge($context, [
'docgen:expects' => DateTime::class,
])),
'user' => $this->normalizer->normalize(null, $format, array_merge($context, [
'docgen:expects' => User::class,
])),
];
}
$user = $this->userRepository->find($object->getUserId());
return [
'comment' => (string) $object->getComment(),
'isNull' => false,
'date' => $this->normalizer->normalize($object->getDate(), $format, array_merge($context, [
'docgen:expects' => DateTime::class,
])),
'user' => $this->normalizer->normalize($user, $format, array_merge($context, [
'docgen:expects' => User::class,
])),
];
}
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
if ('docgen' !== $format) {
return false;
}
if ($data instanceof CommentEmbeddable) {
return true;
}
if (
null === $data
&& array_key_exists('docgen:expects', $context)
&& CommentEmbeddable::class === $context['docgen:expects']) {
return true;
}
return false;
}
}

View File

@ -69,7 +69,7 @@ class AccompanyingPeriodWorkEvaluationApiController
$paginator->setItemsPerPage(count($evaluations)); $paginator->setItemsPerPage(count($evaluations));
return new JsonResponse($this->serializer->serialize( return new JsonResponse($this->serializer->serialize(
new Collection($evaluations, $paginator), new Collection(array_values($evaluations), $paginator),
'json', 'json',
[ [
AbstractNormalizer::GROUPS => ['read'], AbstractNormalizer::GROUPS => ['read'],

View File

@ -114,8 +114,6 @@ final class PersonResourceController extends AbstractController
]); ]);
} }
dump($resource);
return $this->render( return $this->render(
'ChillPersonBundle:PersonResource:edit.html.twig', 'ChillPersonBundle:PersonResource:edit.html.twig',
[ [
@ -139,7 +137,7 @@ final class PersonResourceController extends AbstractController
$form->handleRequest($request); $form->handleRequest($request);
if ($request->getMethod() === Request::METHOD_POST && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$this->denyAccessUnlessGranted(PersonVoter::CREATE, $personOwner); $this->denyAccessUnlessGranted(PersonVoter::CREATE, $personOwner);
$personResource = new PersonResource(); $personResource = new PersonResource();

View File

@ -12,13 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\Person; namespace Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
@ -34,28 +33,20 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
*/ */
class PersonResource implements TrackCreationInterface, TrackUpdateInterface class PersonResource implements TrackCreationInterface, TrackUpdateInterface
{ {
use TrackCreationTrait;
use TrackUpdateTrait;
/** /**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
* @Groups({"read"}) * @Groups({"read"})
*/ */
private CommentEmbeddable $comment; private CommentEmbeddable $comment;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private User $createdBy;
/** /**
* @ORM\Column(type="text", nullable=true) * @ORM\Column(type="text", nullable=true)
* @Groups({"read"}) * @Groups({"read"})
*/ */
private $freeText; private ?string $freeText = null;
/** /**
* @ORM\Id * @ORM\Id
@ -92,16 +83,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
*/ */
private ?ThirdParty $thirdParty = null; private ?ThirdParty $thirdParty = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $updatedBy;
public function __construct() public function __construct()
{ {
$this->comment = new CommentEmbeddable(); $this->comment = new CommentEmbeddable();
@ -112,16 +93,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
return $this->comment; return $this->comment;
} }
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function getFreeText(): ?string public function getFreeText(): ?string
{ {
return $this->freeText; return $this->freeText;
@ -155,16 +126,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
return $this->thirdParty; return $this->thirdParty;
} }
public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setComment(?CommentEmbeddable $comment): self public function setComment(?CommentEmbeddable $comment): self
{ {
if (null === $comment) { if (null === $comment) {
@ -178,23 +139,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
return $this; return $this;
} }
public function setCreatedAt(DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
/**
* SETTERS.
*/
public function setFreeText(?string $freeText): self public function setFreeText(?string $freeText): self
{ {
$this->freeText = $freeText; $this->freeText = $freeText;
@ -204,6 +148,10 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
$this->setThirdParty(null); $this->setThirdParty(null);
} }
if ('' === $freeText) {
$this->freeText = null;
}
return $this; return $this;
} }
@ -245,20 +193,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
return $this; return $this;
} }
public function setUpdatedAt(DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
/** /**
* @Assert\Callback * @Assert\Callback
* *
@ -266,9 +200,8 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
*/ */
public function validate(ExecutionContextInterface $context, $payload) public function validate(ExecutionContextInterface $context, $payload)
{ {
if (null === $this->person && null === $this->thirdParty && null === $this->freeText) { if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
$context->buildViolation('You must associate at least one entity') $context->buildViolation('You must associate at least one entity')
->atPath('person')
->addViolation(); ->addViolation();
} }
} }

View File

@ -58,7 +58,11 @@ const store = createStore({
return state.thirdParties.length > 0; return state.thirdParties.length > 0;
}, },
getTemplatesAvailablesForEvaluation: (state) => (evaluation) => { getTemplatesAvailablesForEvaluation: (state) => (evaluation) => {
return state.templatesAvailablesForEvaluation.get(evaluation.id) || []; if (state.templatesAvailablesForEvaluation.has(evaluation.id)) {
return state.templatesAvailablesForEvaluation.get(evaluation.id);
}
return [];
}, },
buildPayload(state) { buildPayload(state) {
return { return {
@ -171,7 +175,6 @@ const store = createStore({
}; };
g.id = tmpIndex() -1 g.id = tmpIndex() -1
state.goalsPicked.push(g); state.goalsPicked.push(g);
//console.log('goals picked ids', state.goalsPicked.map(g => g.id))
}, },
removeGoal(state, goal) { removeGoal(state, goal) {
state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id); state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id);
@ -369,7 +372,6 @@ const store = createStore({
return makeFetch('PUT', url, payload) return makeFetch('PUT', url, payload)
.then(data => { .then(data => {
console.log('data received', data);
if (typeof(callback) !== 'undefined') { if (typeof(callback) !== 'undefined') {
return callback(data); return callback(data);
} else { } else {

View File

@ -1,5 +1,6 @@
<div class="col-md col-xxl"> <div class="col-md col-xxl">
<div id="collapseForm" class="collapse"> <div id="collapseForm" class="{% if not form.vars.submitted %}collapse{% endif %}">
<h3 style="margin-bottom: 2rem;">{{ 'Add a person resource'|trans }}</h3>
{% include "@ChillPerson/PersonResource/form.html.twig" %} {% include "@ChillPerson/PersonResource/form.html.twig" %}
</div> </div>

View File

@ -1,7 +1,6 @@
{{ form_start(form, {'attr' : {'id' : 'create-form'}}) }} {{ form_start(form, {'attr' : {'id' : 'create-form'}}) }}
{{ form_errors(form) }}
{{ form_row(form.kind) }} {{ form_row(form.kind) }}
<div id="linked-entity"> <div id="linked-entity">
<fieldset class="mb-3"> <fieldset class="mb-3">
<div class="row"> <div class="row">
@ -10,7 +9,7 @@
<div id="entity-selector"> <div id="entity-selector">
<div class="form-check"> <div class="form-check">
{% if resource is defined and resource.person is not null %} {% if resource is defined and resource.person is not null %}
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" /> <input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" {% if form.vars.submitted and app.request.request.get('linked-entity', null) == 'person' %}checked{% endif %}/>
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_0">Usager</label> <label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_0">Usager</label>
{% else %} {% else %}
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" /> <input type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" />
@ -19,7 +18,7 @@
</div> </div>
<div class="form-check"> <div class="form-check">
{% if resource is defined and resource.thirdparty is not null %} {% if resource is defined and resource.thirdparty is not null %}
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" /> <input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" {% if form.vars.submitted and app.request.request.get('linked-entity', null) == 'thirdparty' %}checked{% endif %}/>
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_1">Tiers</label> <label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_1">Tiers</label>
{% else %} {% else %}
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" /> <input type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" />
@ -28,7 +27,7 @@
</div> </div>
<div class="form-check"> <div class="form-check">
{% if resource is defined and resource.freeText is not null %} {% if resource is defined and resource.freeText is not null %}
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" /> <input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" {% if form.vars.submitted and app.request.request.get('linked-entity', null) == 'thirdparty' %}checked{% endif %}/>
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_2">Description libre</label> <label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_2">Description libre</label>
{% else %} {% else %}
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" /> <input type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" />
@ -75,4 +74,4 @@
</ul> </ul>
{% endif %} {% endif %}
{{ form_end(form) }} {{ form_end(form) }}

View File

@ -17,48 +17,39 @@
{% block personcontent %} {% block personcontent %}
<h1>{{ 'List of resources'|trans }}</h1> <h1>{{ 'List of resources'|trans }}</h1>
{% if personResources is not empty %}
{% for resource in personResources %} {% if personResources|length > 0 %}
<div class="flex-table"> <div class="flex-table">
{% for resource in personResources %}
<div class="item-bloc"> <div class="item-bloc">
<div class="item-row"> <div class="item-row">
<div class="wrap-header"> <div class="item-col">
<div class="wh-row"> {% if resource.person is not null %}
<div class="wh-col"> <div class="denomination h3">
{% if resource.person is not null %} <span class="name">{{ resource.person }}</span>
<div class="item-col"> <span class="badge rounded-pill bg-person">{{ 'person'|trans|capitalize }}</span>
<div class="denomination h3">
<span class="name">{{ resource.person }}</span>
<span class="badge rounded-pill bg-person">{{ 'person'|trans|capitalize }}</span>
</div>
</div>
{% elseif resource.thirdparty is not null %}
<div class="item-col">
<div class="denomination h3">
<span class="name">{{ resource.thirdparty }}</span>
<span class="badge rounded-pill bg-thirdparty">
{{ 'thirdparty'|trans|capitalize }}
<i class="fa fa-fw fa-user-md"></i>
</span>
</div>
</div>
{% else %}
<div class="item-col">
<div class="denomination h3">
<span>{{ resource.freetext }}</span>
</div>
</div>
{% endif %}
<div class="wh-col">
{% if resource.kind %}
<span>{{ resource.kind.title.fr|capitalize }}</span>
{% endif %}
</div>
</div>
</div> </div>
{% elseif resource.thirdparty is not null %}
<div class="denomination h3">
<span class="name">{{ resource.thirdparty }}</span>
<span class="badge rounded-pill bg-thirdparty">
{{ 'thirdparty'|trans|capitalize }}
<i class="fa fa-fw fa-user-md"></i>
</span>
</div>
{% else %}
<div class="denomination h3">
<span>{{ resource.freetext }}</span>
</div>
{% endif %}
</div>
<div class="item-col">
{% if resource.kind %}
<span>{{ resource.kind.title.fr|capitalize }}</span>
{% endif %}
</div> </div>
</div> </div>
{% if resource.comment.comment is not null %} {% if resource.comment.comment is not empty %}
<div class="item-row separator"> <div class="item-row separator">
<section class="chill-entity entity-comment-embeddable"> <section class="chill-entity entity-comment-embeddable">
<blockquote class="chill-user-quote"> <blockquote class="chill-user-quote">
@ -67,27 +58,29 @@
</section> </section>
</div> </div>
{% endif %} {% endif %}
<div class="item-row separator"> {% if is_granted('CHILL_PERSON_UPDATE', resource.person) %}
<div class="item-col"> <div class="item-row separator">
<ul class="record_actions"> <div class="item-col">
<li> <ul class="record_actions">
<a href="{{ chill_path_add_return_path('chill_person_resource_edit', {'resource_id': resource.id, <li>
'person_id': person.id,}) }}" <a href="{{ chill_path_add_return_path('chill_person_resource_edit', {'resource_id': resource.id,
class="btn btn-sm btn-edit" 'person_id': person.id,}) }}"
title="{{ 'Edit'|trans }}"></a> class="btn btn-sm btn-edit"
</li> title="{{ 'Edit'|trans }}"></a>
<li> </li>
<a href="{{ chill_path_add_return_path('chill_person_resource_delete', {'person_id': person.id, <li>
'resource_id': resource.id}) }}" <a href="{{ chill_path_add_return_path('chill_person_resource_delete', {'person_id': person.id,
class="btn btn-sm btn-delete" 'resource_id': resource.id}) }}"
title="{{ 'Delete'|trans }}"></a> class="btn btn-sm btn-delete"
</li> title="{{ 'Delete'|trans }}"></a>
</ul> </li>
</ul>
</div>
</div> </div>
</div> {% endif %}
</div> </div>
</div> {% endfor %}
{% endfor %} </div>
{% else %} {% else %}
<p class="chill-no-data-statement">{{ 'There are no available resources'|trans }}</p> <p class="chill-no-data-statement">{{ 'There are no available resources'|trans }}</p>

View File

@ -114,6 +114,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
$userContext = array_merge($context, ['docgen:expects' => User::class, 'groups' => 'docgen:read']); $userContext = array_merge($context, ['docgen:expects' => User::class, 'groups' => 'docgen:read']);
$participationContext = array_merge($context, ['docgen:expects' => AccompanyingPeriodParticipation::class, 'groups' => 'docgen:read']); $participationContext = array_merge($context, ['docgen:expects' => AccompanyingPeriodParticipation::class, 'groups' => 'docgen:read']);
$administrativeLocationContext = array_merge($context, ['docgen:expects' => Location::class, 'groups' => 'docgen:read']); $administrativeLocationContext = array_merge($context, ['docgen:expects' => Location::class, 'groups' => 'docgen:read']);
$workContext = array_merge($context, ['docgen:expects' => AccompanyingPeriod\AccompanyingPeriodWork::class, 'groups' => 'docgen:read']);
return [ return [
'id' => $period->getId(), 'id' => $period->getId(),
@ -160,6 +161,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'locationPerson' => $this->normalizer->normalize($period->getPersonLocation(), $format, array_merge($context, ['docgen:expects' => Person::class])), 'locationPerson' => $this->normalizer->normalize($period->getPersonLocation(), $format, array_merge($context, ['docgen:expects' => Person::class])),
'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext), 'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext),
'administrativeLocation' => $this->normalizer->normalize($period->getAdministrativeLocation(), $format, $administrativeLocationContext), 'administrativeLocation' => $this->normalizer->normalize($period->getAdministrativeLocation(), $format, $administrativeLocationContext),
'works' => $this->normalizer->normalize($period->getWorks(), $format, $workContext),
]; ];
} }
@ -178,6 +180,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'hasLocation' => false, 'hasLocation' => false,
'hasLocationPerson' => false, 'hasLocationPerson' => false,
'hasAdministrativeLocation' => false, 'hasAdministrativeLocation' => false,
'works' => [],
] ]
); );
} }

View File

@ -76,8 +76,8 @@ class PersonDocGenNormalizer implements
'type' => 'person', 'type' => 'person',
'isNull' => false, 'isNull' => false,
'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])), 'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])),
'firstname' => $person->getFirstName(), 'firstName' => $person->getFirstName(),
'lastname' => $person->getLastName(), 'lastName' => $person->getLastName(),
'altNames' => implode( 'altNames' => implode(
', ', ', ',
array_map( array_map(
@ -151,7 +151,7 @@ class PersonDocGenNormalizer implements
$normalizer = new NormalizeNullValueHelper($this->normalizer, 'type', 'person'); $normalizer = new NormalizeNullValueHelper($this->normalizer, 'type', 'person');
$attributes = [ $attributes = [
'firstname', 'lastname', 'age', 'altNames', 'text', 'firstName', 'lastName', 'age', 'altNames', 'text',
'civility' => Civility::class, 'civility' => Civility::class,
'birthdate' => DateTimeInterface::class, 'birthdate' => DateTimeInterface::class,
'deathdate' => DateTimeInterface::class, 'deathdate' => DateTimeInterface::class,

View File

@ -49,8 +49,11 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
return [ return [
'id' => $socialAction->getId(), 'id' => $socialAction->getId(),
'type' => 'social_work_social_action',
'text' => $this->render->renderString($socialAction, []), 'text' => $this->render->renderString($socialAction, []),
'title' => $socialAction->getTitle(), 'title' => $socialAction->getTitle(),
'parent' => $this->normalizer->normalize($socialAction->getParent(), $format, $context),
'issue' => $this->normalizer->normalize($socialAction->getIssue(), $format, $context),
]; ];
default: default:

View File

@ -98,7 +98,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
return $this->translatableStringHelper->localize($e->getTitle()); return $this->translatableStringHelper->localize($e->getTitle());
}, },
'multiple' => true, 'multiple' => true,
'expanded' => true, 'attr' => ['class' => 'select2'],
]); ]);
} }

View File

@ -100,6 +100,7 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
'hasLocationPerson' => false, 'hasLocationPerson' => false,
'location' => '@ignored', 'location' => '@ignored',
'locationPerson' => '@ignored', 'locationPerson' => '@ignored',
'works' => [],
]; ];
$this->assertIsArray($data); $this->assertIsArray($data);
@ -160,6 +161,7 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
'hasLocationPerson' => false, 'hasLocationPerson' => false,
'location' => '@ignored', 'location' => '@ignored',
'locationPerson' => '@ignored', 'locationPerson' => '@ignored',
'works' => [],
]; ];
$this->assertIsArray($data); $this->assertIsArray($data);

View File

@ -38,8 +38,8 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
use ProphecyTrait; use ProphecyTrait;
private const BLANK = [ private const BLANK = [
'firstname' => '', 'firstName' => '',
'lastname' => '', 'lastName' => '',
'altNames' => '', 'altNames' => '',
'text' => '', 'text' => '',
'isNull' => true, 'isNull' => true,
@ -80,7 +80,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
$expected = array_merge( $expected = array_merge(
self::BLANK, self::BLANK,
['firstname' => 'Renaud', 'lastname' => 'Mégane', ['firstName' => 'Renaud', 'lastName' => 'Mégane',
'text' => 'Renaud Mégane', ] 'text' => 'Renaud Mégane', ]
); );

View File

@ -530,3 +530,6 @@ household_composition:
Currently no composition: Aucune composition famiale renseignée. Currently no composition: Aucune composition famiale renseignée.
Add a composition: Ajouter une composition familiale Add a composition: Ajouter une composition familiale
Update composition: Modifier la composition familiale Update composition: Modifier la composition familiale
# docgen
Linked evaluations: Évaluations associées

View File

@ -50,3 +50,6 @@ household_membership:
A course must contains at least one social issue: 'Un parcours doit être associé à au moins une problématique sociale' A course must contains at least one social issue: 'Un parcours doit être associé à au moins une problématique sociale'
A course must be associated to at least one scope: 'Un parcours doit être associé à au moins un service' A course must be associated to at least one scope: 'Un parcours doit être associé à au moins un service'
The social %name% issue cannot be deleted because it is associated with an activity or an action: 'La problématique sociale "%name%" ne peut pas être supprimée car elle est associée à une activité ou une action' The social %name% issue cannot be deleted because it is associated with an activity or an action: 'La problématique sociale "%name%" ne peut pas être supprimée car elle est associée à une activité ou une action'
# resource
You must associate at least one entity: Associez un usager, un tiers ou indiquez une description libre