mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
improve docgen, trnslations, admin
This commit is contained in:
parent
027c01fc58
commit
70ab232149
@ -13,7 +13,7 @@
|
|||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ entity.id }}</td>
|
<td>{{ entity.id }}</td>
|
||||||
<td>{{ entity.name | localize_translatable_string }}</td>
|
<td>{{ entity.name|localize_translatable_string}}</td>
|
||||||
<td>{{ contextManager.getContextByKey(entity.context).name|trans }}</td>
|
<td>{{ contextManager.getContextByKey(entity.context).name|trans }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ chill_path_add_return_path('chill_crud_docgen_template_edit', { 'id': entity.id }) }}" class="btn btn-edit">
|
<a href="{{ chill_path_add_return_path('chill_crud_docgen_template_edit', { 'id': entity.id }) }}" class="btn btn-edit">
|
||||||
|
@ -217,7 +217,6 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
|||||||
|
|
||||||
if (is_iterable($value)) {
|
if (is_iterable($value)) {
|
||||||
$arr = [];
|
$arr = [];
|
||||||
|
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
$arr[$k] =
|
$arr[$k] =
|
||||||
$this->normalizer->normalize($v, $format, array_merge(
|
$this->normalizer->normalize($v, $format, array_merge(
|
||||||
|
@ -11,7 +11,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\DocStoreBundle\Form;
|
namespace Chill\DocStoreBundle\Form;
|
||||||
|
|
||||||
|
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
|
||||||
use Chill\DocStoreBundle\Entity\Document;
|
use Chill\DocStoreBundle\Entity\Document;
|
||||||
|
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
||||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
@ -70,11 +72,11 @@ class AccompanyingCourseDocumentType extends AbstractType
|
|||||||
//TODO : adapt to using AccompanyingCourseDocument categories. Currently there are none...
|
//TODO : adapt to using AccompanyingCourseDocument categories. Currently there are none...
|
||||||
->add('category', EntityType::class, [
|
->add('category', EntityType::class, [
|
||||||
'placeholder' => 'Choose a document category',
|
'placeholder' => 'Choose a document category',
|
||||||
'class' => 'ChillDocStoreBundle:DocumentCategory',
|
'class' => DocumentCategory::class,
|
||||||
'query_builder' => static function (EntityRepository $er) {
|
'query_builder' => static function (EntityRepository $er) {
|
||||||
return $er->createQueryBuilder('c')
|
return $er->createQueryBuilder('c')
|
||||||
->where('c.documentClass = :docClass')
|
->where('c.documentClass = :docClass')
|
||||||
->setParameter('docClass', PersonDocument::class);
|
->setParameter('docClass', AccompanyingCourseDocument::class);
|
||||||
},
|
},
|
||||||
'choice_label' => function ($entity = null) {
|
'choice_label' => function ($entity = null) {
|
||||||
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
|
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
|
||||||
|
@ -73,6 +73,7 @@ class HouseholdMember
|
|||||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||||
* )
|
* )
|
||||||
* @Serializer\Groups({"read", "docgen:read"})
|
* @Serializer\Groups({"read", "docgen:read"})
|
||||||
|
* @Serializer\Context({"docgen:person:with-household": false})
|
||||||
* @Assert\Valid(groups={"household_memberships"})
|
* @Assert\Valid(groups={"household_memberships"})
|
||||||
* @Assert\NotNull(groups={"household_memberships"})
|
* @Assert\NotNull(groups={"household_memberships"})
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
|
|||||||
|
|
||||||
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
|
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\PersonAltName;
|
use Chill\PersonBundle\Entity\PersonAltName;
|
||||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||||
@ -57,7 +58,7 @@ class PersonDocGenNormalizer implements
|
|||||||
return $this->normalizeNullValue($format, $context);
|
return $this->normalizeNullValue($format, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
$data = [
|
||||||
'firstname' => $person->getFirstName(),
|
'firstname' => $person->getFirstName(),
|
||||||
'lastname' => $person->getLastName(),
|
'lastname' => $person->getLastName(),
|
||||||
'altNames' => implode(
|
'altNames' => implode(
|
||||||
@ -84,6 +85,16 @@ class PersonDocGenNormalizer implements
|
|||||||
'memo' => $person->getMemo(),
|
'memo' => $person->getMemo(),
|
||||||
'numberOfChildren' => (string) $person->getNumberOfChildren(),
|
'numberOfChildren' => (string) $person->getNumberOfChildren(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($context['docgen:person:with-household'] ?? false) {
|
||||||
|
$data['household'] = $this->normalizer->normalize(
|
||||||
|
$person->getCurrentHousehold(),
|
||||||
|
$format,
|
||||||
|
array_merge($context, ['docgen:expects' => Household::class])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsNormalization($data, ?string $format = null, array $context = [])
|
public function supportsNormalization($data, ?string $format = null, array $context = [])
|
||||||
|
@ -36,8 +36,8 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
|
|||||||
'id' => $socialAction->getId(),
|
'id' => $socialAction->getId(),
|
||||||
'type' => 'social_work_social_action',
|
'type' => 'social_work_social_action',
|
||||||
'text' => $this->render->renderString($socialAction, []),
|
'text' => $this->render->renderString($socialAction, []),
|
||||||
'parent' => $this->normalizer->normalize($socialAction->getParent()),
|
'parent' => $this->normalizer->normalize($socialAction->getParent(), $format, $context),
|
||||||
'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate()),
|
'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate(), $format, $context),
|
||||||
'title' => $socialAction->getTitle(),
|
'title' => $socialAction->getTitle(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class AccompanyingPeriodContext implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function adminFormReverseTransform(array $data): array
|
public function adminFormReverseTransform(array $data): array
|
||||||
{
|
{dump($data);
|
||||||
if (array_key_exists('category', $data)) {
|
if (array_key_exists('category', $data)) {
|
||||||
$data['category'] = [
|
$data['category'] = [
|
||||||
'idInsideBundle' => $data['category']->getIdInsideBundle(),
|
'idInsideBundle' => $data['category']->getIdInsideBundle(),
|
||||||
@ -80,7 +80,7 @@ class AccompanyingPeriodContext implements
|
|||||||
|
|
||||||
public function adminFormTransform(array $data): array
|
public function adminFormTransform(array $data): array
|
||||||
{
|
{
|
||||||
$data = [
|
$r = [
|
||||||
'mainPerson' => $data['mainPerson'] ?? false,
|
'mainPerson' => $data['mainPerson'] ?? false,
|
||||||
'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'),
|
'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'),
|
||||||
'person1' => $data['person1'] ?? false,
|
'person1' => $data['person1'] ?? false,
|
||||||
@ -90,11 +90,11 @@ class AccompanyingPeriodContext implements
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (array_key_exists('category', $data)) {
|
if (array_key_exists('category', $data)) {
|
||||||
$data['category'] = array_key_exists('category', $data) ?
|
$r['category'] = array_key_exists('category', $data) ?
|
||||||
$this->documentCategoryRepository->find($data['category']) : null;
|
$this->documentCategoryRepository->find($data['category']) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildAdminForm(FormBuilderInterface $builder): void
|
public function buildAdminForm(FormBuilderInterface $builder): void
|
||||||
@ -204,7 +204,7 @@ class AccompanyingPeriodContext implements
|
|||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'Accompanying Period basic';
|
return 'docgen.Accompanying Period basic';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasAdminForm(): bool
|
public function hasAdminForm(): bool
|
||||||
@ -231,7 +231,7 @@ class AccompanyingPeriodContext implements
|
|||||||
->setCourse($entity)
|
->setCourse($entity)
|
||||||
->setObject($storedObject);
|
->setObject($storedObject);
|
||||||
|
|
||||||
if (array_key_exists('category', $template->getOptions()['category'])) {
|
if (array_key_exists('category', $template->getOptions())) {
|
||||||
$doc
|
$doc
|
||||||
->setCategory(
|
->setCategory(
|
||||||
$this->documentCategoryRepository->find(
|
$this->documentCategoryRepository->find(
|
||||||
|
@ -102,7 +102,7 @@ class AccompanyingPeriodWorkContext implements
|
|||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'Accompanying period work';
|
return 'docgen.Accompanying period work';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasAdminForm(): bool
|
public function hasAdminForm(): bool
|
||||||
|
@ -153,7 +153,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
|
|||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'Accompanying period work context';
|
return 'docgen.Accompanying period work context';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasAdminForm(): bool
|
public function hasAdminForm(): bool
|
||||||
|
@ -11,6 +11,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Serializer\Normalizer;
|
namespace Serializer\Normalizer;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
@ -77,8 +80,55 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testNormalize(?Person $person, $expected, $msg)
|
public function testNormalize(?Person $person, $expected, $msg)
|
||||||
{
|
{
|
||||||
$normalized = $this->normalizer->normalize($person, 'docgen', ['docgen:expects' => Person::class]);
|
$normalized = $this->normalizer->normalize($person, 'docgen', [
|
||||||
|
'docgen:expects' => Person::class,
|
||||||
|
'groups' => 'docgen:read'
|
||||||
|
]);
|
||||||
|
|
||||||
$this->assertEquals($expected, $normalized, $msg);
|
$this->assertEquals($expected, $normalized, $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNormalizePersonWithHousehold()
|
||||||
|
{
|
||||||
|
$household = new Household();
|
||||||
|
$person = new Person();
|
||||||
|
$person
|
||||||
|
->setFirstName('Renaud')
|
||||||
|
->setLastName('Mégane')
|
||||||
|
;
|
||||||
|
$householdMember = new HouseholdMember();
|
||||||
|
$householdMember
|
||||||
|
->setPosition((new Position())->setAllowHolder(true)->setLabel(['fr' => 'position'])
|
||||||
|
->setShareHousehold(true))
|
||||||
|
->setHolder(true)
|
||||||
|
;
|
||||||
|
$person->addHouseholdParticipation($householdMember);
|
||||||
|
$household->addMember($householdMember);
|
||||||
|
|
||||||
|
$person = new Person();
|
||||||
|
$person
|
||||||
|
->setFirstName('Citroen')
|
||||||
|
->setLastName('Xsara')
|
||||||
|
;
|
||||||
|
$householdMember = new HouseholdMember();
|
||||||
|
$householdMember
|
||||||
|
->setPosition((new Position())->setAllowHolder(true)->setLabel(['fr' => 'position2'])
|
||||||
|
->setShareHousehold(false))
|
||||||
|
->setHolder(false)
|
||||||
|
;
|
||||||
|
$person->addHouseholdParticipation($householdMember);
|
||||||
|
$household->addMember($householdMember);
|
||||||
|
|
||||||
|
$actual = $this->normalizer->normalize($person, 'docgen', [
|
||||||
|
'groups' => 'docgen:read',
|
||||||
|
'docgen:expects' => Person::class,
|
||||||
|
'docgen:person:with-household' => true,
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertCount(2, $household->getMembers());
|
||||||
|
$this->assertIsArray($actual);
|
||||||
|
|
||||||
|
var_dump($actual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,13 +455,15 @@ see social issues: Voir les problématiques sociales
|
|||||||
see persons associated: Voir les usagers concernés
|
see persons associated: Voir les usagers concernés
|
||||||
|
|
||||||
docgen:
|
docgen:
|
||||||
|
Accompanying Period basic: "Parcours d'accompagnement (basique)"
|
||||||
|
Accompanying period work: "Action d'accompagnement"
|
||||||
|
Accompanying period work context: "Evaluation des actions d'accompagnement"
|
||||||
Main person: Personne principale
|
Main person: Personne principale
|
||||||
person 1: Première personne
|
person 1: Première personne
|
||||||
person 2: Seconde personne
|
person 2: Seconde personne
|
||||||
Ask for main person: Demander à l'utilisateur de préciser la personne principale
|
Ask for main person: Demander à l'utilisateur de préciser la personne principale
|
||||||
Ask for person 1: Demander à l'utilisateur de préciser la première personne
|
Ask for person 1: Demander à l'utilisateur de préciser la première personne
|
||||||
Ask for person 2: Demander à l'utilisateur de préciser la seconde personne
|
Ask for person 2: Demander à l'utilisateur de préciser la seconde personne
|
||||||
Accompanying period work: Actions
|
|
||||||
A basic context for accompanying period: Contexte pour les parcours
|
A basic context for accompanying period: Contexte pour les parcours
|
||||||
A context for accompanying period work: Contexte pour les actions d'accompagnement
|
A context for accompanying period work: Contexte pour les actions d'accompagnement
|
||||||
A context for accompanying period work evaluation: Contexte pour les évaluations dans les actions d'accompagnement
|
A context for accompanying period work evaluation: Contexte pour les évaluations dans les actions d'accompagnement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user