mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
improve docgen, trnslations, admin
This commit is contained in:
parent
027c01fc58
commit
70ab232149
@ -13,7 +13,7 @@
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<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>
|
||||
<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)) {
|
||||
$arr = [];
|
||||
|
||||
foreach ($value as $k => $v) {
|
||||
$arr[$k] =
|
||||
$this->normalizer->normalize($v, $format, array_merge(
|
||||
|
@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Form;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
|
||||
use Chill\DocStoreBundle\Entity\Document;
|
||||
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
@ -70,11 +72,11 @@ class AccompanyingCourseDocumentType extends AbstractType
|
||||
//TODO : adapt to using AccompanyingCourseDocument categories. Currently there are none...
|
||||
->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')
|
||||
->setParameter('docClass', PersonDocument::class);
|
||||
->setParameter('docClass', AccompanyingCourseDocument::class);
|
||||
},
|
||||
'choice_label' => function ($entity = null) {
|
||||
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
|
||||
|
@ -73,6 +73,7 @@ class HouseholdMember
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Context({"docgen:person:with-household": false})
|
||||
* @Assert\Valid(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\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonAltName;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
@ -57,7 +58,7 @@ class PersonDocGenNormalizer implements
|
||||
return $this->normalizeNullValue($format, $context);
|
||||
}
|
||||
|
||||
return [
|
||||
$data = [
|
||||
'firstname' => $person->getFirstName(),
|
||||
'lastname' => $person->getLastName(),
|
||||
'altNames' => implode(
|
||||
@ -84,6 +85,16 @@ class PersonDocGenNormalizer implements
|
||||
'memo' => $person->getMemo(),
|
||||
'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 = [])
|
||||
|
@ -36,8 +36,8 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
'id' => $socialAction->getId(),
|
||||
'type' => 'social_work_social_action',
|
||||
'text' => $this->render->renderString($socialAction, []),
|
||||
'parent' => $this->normalizer->normalize($socialAction->getParent()),
|
||||
'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate()),
|
||||
'parent' => $this->normalizer->normalize($socialAction->getParent(), $format, $context),
|
||||
'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate(), $format, $context),
|
||||
'title' => $socialAction->getTitle(),
|
||||
];
|
||||
|
||||
|
@ -67,7 +67,7 @@ class AccompanyingPeriodContext implements
|
||||
}
|
||||
|
||||
public function adminFormReverseTransform(array $data): array
|
||||
{
|
||||
{dump($data);
|
||||
if (array_key_exists('category', $data)) {
|
||||
$data['category'] = [
|
||||
'idInsideBundle' => $data['category']->getIdInsideBundle(),
|
||||
@ -80,7 +80,7 @@ class AccompanyingPeriodContext implements
|
||||
|
||||
public function adminFormTransform(array $data): array
|
||||
{
|
||||
$data = [
|
||||
$r = [
|
||||
'mainPerson' => $data['mainPerson'] ?? false,
|
||||
'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'),
|
||||
'person1' => $data['person1'] ?? false,
|
||||
@ -90,11 +90,11 @@ class AccompanyingPeriodContext implements
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function buildAdminForm(FormBuilderInterface $builder): void
|
||||
@ -204,7 +204,7 @@ class AccompanyingPeriodContext implements
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Accompanying Period basic';
|
||||
return 'docgen.Accompanying Period basic';
|
||||
}
|
||||
|
||||
public function hasAdminForm(): bool
|
||||
@ -231,7 +231,7 @@ class AccompanyingPeriodContext implements
|
||||
->setCourse($entity)
|
||||
->setObject($storedObject);
|
||||
|
||||
if (array_key_exists('category', $template->getOptions()['category'])) {
|
||||
if (array_key_exists('category', $template->getOptions())) {
|
||||
$doc
|
||||
->setCategory(
|
||||
$this->documentCategoryRepository->find(
|
||||
|
@ -102,7 +102,7 @@ class AccompanyingPeriodWorkContext implements
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Accompanying period work';
|
||||
return 'docgen.Accompanying period work';
|
||||
}
|
||||
|
||||
public function hasAdminForm(): bool
|
||||
|
@ -153,7 +153,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Accompanying period work context';
|
||||
return 'docgen.Accompanying period work context';
|
||||
}
|
||||
|
||||
public function hasAdminForm(): bool
|
||||
|
@ -11,6 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
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 Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
@ -77,8 +80,55 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
person 1: Première personne
|
||||
person 2: Seconde personne
|
||||
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 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 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user