mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'master' into notification/completion
This commit is contained in:
commit
46ca74fc70
@ -11,6 +11,8 @@ and this project adheres to
|
||||
## Unreleased
|
||||
|
||||
<!-- write down unreleased development here -->
|
||||
* vuejs: translate in French all multiselect widgets
|
||||
* [address] define address lines according postal standards for France and Belgium (default) and change AddressRender, chill_entity_render_box and AddressRenderBox.vue
|
||||
* [household] change translations (champs-libres/departement-de-la-vendee/accent-suivi-developpement#109)
|
||||
* [household] add address i18n in household component (champs-libres/departement-de-la-vendee/accent-suivi-developpement#158)
|
||||
* [household] add on the fly i18n in household component
|
||||
@ -20,6 +22,9 @@ and this project adheres to
|
||||
* [household] household member editor: remove markNoAddress button (champs-libres/departement-de-la-vendee/accent-suivi-developpement#109)
|
||||
* [person]: ordering fields in add person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/61)
|
||||
* [person]: Add email and alt names in add person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/61)
|
||||
* [accompanyingCourse] Add a delete action and delete buttons to delete a accompanying course when step = DRAFT (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/64)
|
||||
* [accompanyingCourse] Add a administrative location in the accompanying course, set the user current location as default, allow to select a location in a select field and do not allow to confirm the accompanying course if location is empty.
|
||||
* [accompanyingCourse] Add the administrative location in the available variables for document generation
|
||||
* AddAddress: optimize loading: wait for the user finish typing;
|
||||
* UserPicker: fix bug with deprecated role
|
||||
* docgen: add base context + tests
|
||||
|
@ -60,6 +60,7 @@
|
||||
"drupol/php-conventions": "^5",
|
||||
"fakerphp/faker": "^1.13",
|
||||
"nelmio/alice": "^3.8",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.0",
|
||||
"phpunit/phpunit": ">= 7.5",
|
||||
"symfony/debug-bundle": "^5.1",
|
||||
|
@ -315,11 +315,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 3
|
||||
path: src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 1
|
||||
|
@ -6,7 +6,6 @@
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="tests/app/tests/bootstrap.php"
|
||||
stopOnFailure="true"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
|
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div v-if="getContext === 'accompanyingCourse' && suggestedEntities.length > 0">
|
||||
<ul class="list-suggest add-items inline">
|
||||
<li v-for="p in suggestedEntities" @click="addSuggestedEntity(p)">
|
||||
<li v-for="(p, i) in suggestedEntities" @click="addSuggestedEntity(p)" :key="`suggestedEntities-${i}`">
|
||||
<span>{{ p.text }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -15,13 +15,15 @@
|
||||
:searchable="true"
|
||||
:placeholder="$t('activity.choose_location')"
|
||||
:custom-label="customLabel"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
:options="availableLocations"
|
||||
group-values="locations"
|
||||
group-label="locationGroup"
|
||||
v-model="location"
|
||||
>
|
||||
</VueMultiselect>
|
||||
|
||||
<new-location v-bind:locations="locations"></new-location>
|
||||
</div>
|
||||
</div>
|
||||
@ -32,7 +34,6 @@
|
||||
import { mapState, mapGetters } from "vuex";
|
||||
import VueMultiselect from "vue-multiselect";
|
||||
import NewLocation from "./Location/NewLocation.vue";
|
||||
import { getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation } from "../api.js";
|
||||
|
||||
export default {
|
||||
name: "Location",
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
<check-social-issue
|
||||
v-for="issue in socialIssuesList"
|
||||
v-bind:key="issue.id"
|
||||
v-bind:issue="issue"
|
||||
v-bind:selection="socialIssuesSelected"
|
||||
:key="issue.id"
|
||||
:issue="issue"
|
||||
:selection="socialIssuesSelected"
|
||||
@updateSelected="updateIssuesSelected">
|
||||
</check-social-issue>
|
||||
|
||||
@ -21,18 +21,18 @@
|
||||
label="text"
|
||||
track-by="id"
|
||||
open-direction="bottom"
|
||||
v-bind:close-on-select="true"
|
||||
v-bind:preserve-search="false"
|
||||
v-bind:reset-after="true"
|
||||
v-bind:hide-selected="true"
|
||||
v-bind:taggable="false"
|
||||
v-bind:multiple="false"
|
||||
v-bind:searchable="true"
|
||||
v-bind:allow-empty="true"
|
||||
v-bind:show-labels="false"
|
||||
v-bind:loading="issueIsLoading"
|
||||
v-bind:placeholder="$t('activity.choose_other_social_issue')"
|
||||
v-bind:options="socialIssuesOther"
|
||||
:close-on-select="true"
|
||||
:preserve-search="false"
|
||||
:reset-after="true"
|
||||
:hide-selected="true"
|
||||
:taggable="false"
|
||||
:multiple="false"
|
||||
:searchable="true"
|
||||
:allow-empty="true"
|
||||
:show-labels="false"
|
||||
:loading="issueIsLoading"
|
||||
:placeholder="$t('activity.choose_other_social_issue')"
|
||||
:options="socialIssuesOther"
|
||||
@select="addIssueInList">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
@ -58,9 +58,9 @@
|
||||
<check-social-action
|
||||
v-if="socialIssuesSelected.length || socialActionsSelected.length"
|
||||
v-for="action in socialActionsList"
|
||||
v-bind:key="action.id"
|
||||
v-bind:action="action"
|
||||
v-bind:selection="socialActionsSelected"
|
||||
:key="action.id"
|
||||
:action="action"
|
||||
:selection="socialActionsSelected"
|
||||
@updateSelected="updateActionsSelected">
|
||||
</check-social-action>
|
||||
</template>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||
import { multiSelectMessages } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||
|
||||
const activityMessages = {
|
||||
fr: {
|
||||
@ -33,12 +34,11 @@ const activityMessages = {
|
||||
},
|
||||
create_address: 'Créer une adresse',
|
||||
edit_address: "Modifier l'adresse"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(activityMessages.fr, personMessages.fr);
|
||||
Object.assign(activityMessages.fr, personMessages.fr, multiSelectMessages.fr);
|
||||
|
||||
export {
|
||||
activityMessages
|
||||
|
@ -13,6 +13,9 @@
|
||||
:close-on-select="false"
|
||||
:allow-empty="true"
|
||||
:model-value="value"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
@select="selectUsers"
|
||||
@remove="unSelectUsers"
|
||||
@close="coloriseSelectedValues"
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { multiSelectMessages } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||
|
||||
const calendarUserSelectorMessages = {
|
||||
fr: {
|
||||
choose_your_calendar_user: "Afficher les plages de disponibilités",
|
||||
@ -5,9 +7,11 @@ const calendarUserSelectorMessages = {
|
||||
show_my_calendar: "Afficher mon calendrier",
|
||||
show_weekends: "Afficher les week-ends"
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export {
|
||||
Object.assign(calendarUserSelectorMessages.fr, multiSelectMessages.fr);
|
||||
|
||||
export {
|
||||
calendarUserSelectorMessages
|
||||
};
|
||||
};
|
||||
|
@ -276,7 +276,6 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
fwrite($templateResource, $dataDecrypted);
|
||||
rewind($templateResource);
|
||||
}
|
||||
|
||||
$datas = $context->getData($template, $entity, $contextGenerationData);
|
||||
|
||||
try {
|
||||
|
@ -46,7 +46,6 @@ class RelatorioDriver implements DriverInterface
|
||||
'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType),
|
||||
];
|
||||
$form = new FormDataPart($formFields);
|
||||
dump(json_encode($data));
|
||||
|
||||
try {
|
||||
$response = $this->relatorioClient->request('POST', $this->url, [
|
||||
|
@ -23,11 +23,7 @@
|
||||
<input type="hidden" name="entityClassName" value="{{ contextManager.getContextByKey(entity.context).entityClass|e('html_attr') }}" />
|
||||
<input type="text" name="entityId" />
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<button type="submit" class="btn btn-mini btn-neutral">{{ 'docgen.test generate'|trans }}</button>
|
||||
</li>
|
||||
</ul>
|
||||
<button type="submit" class="btn btn-mini btn-misc"><i class="fa fa-cog"></i>{{ 'docgen.test generate'|trans }}</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -11,9 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Serializer\Helper;
|
||||
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
use function array_merge;
|
||||
use function is_array;
|
||||
|
||||
class NormalizeNullValueHelper
|
||||
{
|
||||
@ -30,7 +32,7 @@ class NormalizeNullValueHelper
|
||||
$this->discriminatorValue = $discriminatorValue;
|
||||
}
|
||||
|
||||
public function normalize(array $attributes, string $format = 'docgen', ?array $context = [])
|
||||
public function normalize(array $attributes, string $format = 'docgen', ?array $context = [], ?ClassMetadata $classMetadata = null)
|
||||
{
|
||||
$data = [];
|
||||
$data['isNull'] = true;
|
||||
@ -58,7 +60,7 @@ class NormalizeNullValueHelper
|
||||
|
||||
default:
|
||||
$data[$key] = $this->normalizer->normalize(null, $format, array_merge(
|
||||
$context,
|
||||
$this->getContextForAttribute($key, $context, $classMetadata),
|
||||
['docgen:expects' => $class]
|
||||
));
|
||||
|
||||
@ -69,4 +71,25 @@ class NormalizeNullValueHelper
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getContextForAttribute(string $key, array $initialContext, ?ClassMetadata $classMetadata): array
|
||||
{
|
||||
if (null === $classMetadata) {
|
||||
return $initialContext;
|
||||
}
|
||||
|
||||
$attributeMetadata = $classMetadata->getAttributesMetadata()[$key] ?? null;
|
||||
|
||||
if (null !== $attributeMetadata) {
|
||||
/** @var \Symfony\Component\Serializer\Mapping\AttributeMetadata $attributeMetadata */
|
||||
$initialContext = array_merge(
|
||||
$initialContext,
|
||||
$attributeMetadata->getNormalizationContextForGroups(
|
||||
is_array($initialContext['groups']) ? $initialContext['groups'] : [$initialContext['groups']]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $initialContext;
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
|
||||
$normalizer = new NormalizeNullValueHelper($this->normalizer, $typeKey, $typeValue);
|
||||
|
||||
return $normalizer->normalize($keys, $format, $context);
|
||||
return $normalizer->normalize($keys, $format, $context, $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -260,9 +260,13 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
/** @var AttributeMetadata $attribute */
|
||||
$value = $this->propertyAccess->getValue($object, $attribute->getName());
|
||||
$key = $attribute->getSerializedName() ?? $attribute->getName();
|
||||
$isTranslatable = $attribute->getNormalizationContextForGroups(
|
||||
$objectContext = array_merge(
|
||||
$context,
|
||||
$attribute->getNormalizationContextForGroups(
|
||||
is_array($context['groups']) ? $context['groups'] : [$context['groups']]
|
||||
)['is-translatable'] ?? false;
|
||||
)
|
||||
);
|
||||
$isTranslatable = $objectContext['is-translatable'] ?? false;
|
||||
|
||||
if ($isTranslatable) {
|
||||
$data[$key] = $this->translatableStringHelper
|
||||
@ -273,7 +277,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
foreach ($value as $k => $v) {
|
||||
$arr[$k] =
|
||||
$this->normalizer->normalize($v, $format, array_merge(
|
||||
$context,
|
||||
$objectContext,
|
||||
$attribute->getNormalizationContextForGroups($expectedGroups)
|
||||
));
|
||||
}
|
||||
@ -281,11 +285,11 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
} elseif (is_object($value)) {
|
||||
$data[$key] =
|
||||
$this->normalizer->normalize($value, $format, array_merge(
|
||||
$context,
|
||||
$objectContext,
|
||||
$attribute->getNormalizationContextForGroups($expectedGroups)
|
||||
));
|
||||
} elseif (null === $value) {
|
||||
$data[$key] = $this->normalizeNullOutputValue($format, $context, $attribute, $reflection);
|
||||
$data[$key] = $this->normalizeNullOutputValue($format, $objectContext, $attribute, $reflection);
|
||||
} else {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace Chill\DocGeneratorBundle\tests\Serializer\Normalizer;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
@ -33,6 +34,49 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testChangeContextOnAttribute()
|
||||
{
|
||||
$object = new TestableParentClass();
|
||||
$actual = $this->normalizer->normalize(
|
||||
$object,
|
||||
'docgen',
|
||||
['groups' => 'docgen:read']
|
||||
);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('child', $actual);
|
||||
$this->assertIsArray($actual['child']);
|
||||
$this->assertArrayHasKey('foo', $actual['child']);
|
||||
$this->assertEquals('bar', $actual['child']['foo']);
|
||||
$this->assertArrayNotHasKey('baz', $actual['child']);
|
||||
|
||||
// test with child = null
|
||||
$object->child = null;
|
||||
$actual = $this->normalizer->normalize(
|
||||
$object,
|
||||
'docgen',
|
||||
['groups' => 'docgen:read']
|
||||
);
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('child', $actual);
|
||||
$this->assertIsArray($actual['child']);
|
||||
$this->assertArrayHasKey('foo', $actual['child']);
|
||||
$this->assertEquals('', $actual['child']['foo']);
|
||||
$this->assertArrayNotHasKey('baz', $actual['child']);
|
||||
|
||||
$actual = $this->normalizer->normalize(
|
||||
null,
|
||||
'docgen',
|
||||
['groups' => 'docgen:read', 'docgen:expects' => TestableParentClass::class],
|
||||
);
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('child', $actual);
|
||||
$this->assertIsArray($actual['child']);
|
||||
$this->assertArrayHasKey('foo', $actual['child']);
|
||||
$this->assertEquals('', $actual['child']['foo']);
|
||||
$this->assertArrayNotHasKey('baz', $actual['child']);
|
||||
}
|
||||
|
||||
public function testNormalizationBasic()
|
||||
{
|
||||
$scope = new Scope();
|
||||
@ -99,3 +143,30 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertEquals($expected, $normalized, 'test normalization fo an user with null center');
|
||||
}
|
||||
}
|
||||
|
||||
class TestableParentClass
|
||||
{
|
||||
/**
|
||||
* @Serializer\Groups("docgen:read")
|
||||
* @Serializer\Context(normalizationContext={"groups": "docgen:read:foo"}, groups={"docgen:read"})
|
||||
*/
|
||||
public ?TestableChildClass $child;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->child = new TestableChildClass();
|
||||
}
|
||||
}
|
||||
|
||||
class TestableChildClass
|
||||
{
|
||||
/**
|
||||
* @Serializer\Groups("docgen:read")
|
||||
*/
|
||||
public string $baz = 'bloup';
|
||||
|
||||
/**
|
||||
* @Serializer\Groups("docgen:read:foo")
|
||||
*/
|
||||
public string $foo = 'bar';
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\tests\Service\Context;
|
||||
|
||||
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
@ -23,6 +24,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
*/
|
||||
final class BaseContextDataTest extends KernelTestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@ -7,6 +7,7 @@ docgen:
|
||||
Context: Contexte
|
||||
New template: Nouveau gabarit
|
||||
Edit template: Modifier gabarit
|
||||
test generate: Tester la génération
|
||||
With context: 'Avec le contexte :'
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ class Address
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* used for the CEDEX information
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
|
@ -6,8 +6,9 @@
|
||||
v-model="value"
|
||||
:placeholder="$t('select_address')"
|
||||
:tag-placeholder="$t('create_address')"
|
||||
:select-label="$t('press_enter_to_select')"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('create_address')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
@search-change="listenInputSearch"
|
||||
ref="addressSelector"
|
||||
@select="selectAddress"
|
||||
|
@ -12,8 +12,9 @@
|
||||
label="value"
|
||||
:custom-label="transName"
|
||||
:placeholder="$t('select_city')"
|
||||
:select-label="$t('press_enter_to_select')"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('create_postal_code')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
:taggable="true"
|
||||
:multiple="false"
|
||||
@tag="addPostcode"
|
||||
|
@ -5,12 +5,13 @@
|
||||
id="countrySelect"
|
||||
label="name"
|
||||
track-by="id"
|
||||
v-bind:custom-label="transName"
|
||||
v-bind:placeholder="$t('select_country')"
|
||||
v-bind:options="sortedCountries"
|
||||
:custom-label="transName"
|
||||
:placeholder="$t('select_country')"
|
||||
:options="sortedCountries"
|
||||
v-model="value"
|
||||
:select-label="$t('press_enter_to_select')"
|
||||
:deselect-label="$t('press_enter_to_remove')"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
@select="selectCountry">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<h4 class="h3">{{ $t('address_suggestions') }}</h4>
|
||||
|
||||
<div class="flex-table AddressSuggestionList">
|
||||
<div v-for="a in context.suggestions" class="item-bloc">
|
||||
<div v-for="(a, i) in context.suggestions" class="item-bloc" :key="`suggestions-${i}`">
|
||||
<div class="float-button bottom">
|
||||
<div class="box">
|
||||
<div class="action">
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { multiSelectMessages } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||
|
||||
const addressMessages = {
|
||||
fr: {
|
||||
press_enter_to_select: 'Appuyer sur Entrée pour sélectionner',
|
||||
press_enter_to_remove: 'Appuyer sur Entrée pour désélectionner',
|
||||
add_an_address_title: 'Créer une adresse',
|
||||
edit_an_address_title: 'Modifier une adresse',
|
||||
create_a_new_address: 'Créer une nouvelle adresse',
|
||||
@ -48,6 +48,8 @@ const addressMessages = {
|
||||
}
|
||||
};
|
||||
|
||||
Object.assign(addressMessages.fr, multiSelectMessages.fr);
|
||||
|
||||
export {
|
||||
addressMessages
|
||||
};
|
||||
|
@ -2,9 +2,15 @@
|
||||
<component :is="component" class="chill-entity entity-address my-3">
|
||||
|
||||
<component :is="component" class="address" :class="multiline">
|
||||
<div v-if="isMultiline === true">
|
||||
<p v-for="(l, i) in address.lines" :key="`line-${i}`">
|
||||
{{ l }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p v-if="address.text"
|
||||
class="street">
|
||||
{{ address.text }},
|
||||
{{ address.text }}
|
||||
</p>
|
||||
<p v-if="address.postcode"
|
||||
class="postcode">
|
||||
@ -14,9 +20,10 @@
|
||||
class="country">
|
||||
{{ address.country.name.fr }}
|
||||
</p>
|
||||
</div>
|
||||
</component>
|
||||
|
||||
<div v-if="isMultiline === true" class="address-more">
|
||||
<!-- <div v-if="isMultiline === true" class="address-more">
|
||||
<div v-if="address.floor">
|
||||
<span class="floor">
|
||||
<b>{{ $t('floor') }}</b>: {{ address.floor }}
|
||||
@ -52,7 +59,7 @@
|
||||
<b>{{ $t('distribution') }}</b>: {{ address.distribution }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div v-if="useDatePane === true" class="address-more">
|
||||
<div v-if="address.validFrom">
|
||||
|
@ -84,3 +84,17 @@ const _createI18n = (appMessages) => {
|
||||
};
|
||||
|
||||
export { _createI18n }
|
||||
|
||||
export const multiSelectMessages = {
|
||||
fr: {
|
||||
multiselect: {
|
||||
placeholder: 'Choisir',
|
||||
tag_placeholder: 'Créer un nouvel élément',
|
||||
select_label: 'Appuyer sur "Entrée" pour sélectionner',
|
||||
deselect_label: 'Appuyer sur "Entrée" pour désélectionner',
|
||||
select_group_label: 'Appuyer sur "Entrée" pour sélectionner ce groupe',
|
||||
deselect_group_label: 'Appuyer sur "Entrée" pour désélectionner ce groupe',
|
||||
selected_label: 'Sélectionné'
|
||||
}
|
||||
}
|
||||
};
|
@ -9,57 +9,23 @@
|
||||
* with_delimiter bool add a delimiter between fragments
|
||||
* has_no_address bool
|
||||
* multiline bool multiline display
|
||||
* extended_infos bool add extra informations (step, floor, etc.)
|
||||
* extended_infos bool add extra informations (step, floor, etc.) DEPRECATED
|
||||
|
||||
#}
|
||||
|
||||
{% macro raw(address, options, streetLine) %}
|
||||
|
||||
{% if address.street is not empty %}
|
||||
<p>{{ streetLine }}</p>
|
||||
{% endif %}
|
||||
{% if options['extended_infos'] %}
|
||||
{{ _self.extended(address, options) }}
|
||||
{% endif %}
|
||||
{% if address.postCode is not empty %}
|
||||
<p class="postcode">
|
||||
<span class="code">{{ address.postCode.code }}</span>
|
||||
<span class="name">{{ address.postCode.name }}</span>
|
||||
</p>
|
||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||
{% endif %}
|
||||
{% macro raw(lines) %}
|
||||
{% for l in lines %}
|
||||
<p>{{ l }}</p>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro extended(address, options) %}
|
||||
{% if address.floor is not empty %}
|
||||
<span class="floor">{{ 'address more.floor'|trans }} {{ address.floor }}</span>
|
||||
{% endif %}
|
||||
{% if address.corridor is not empty %}
|
||||
<span class="corridor">{{ 'address more.corridor'|trans }} {{ address.corridor }}</span>
|
||||
{% endif %}
|
||||
{% if address.steps is not empty %}
|
||||
<span class="steps">{{ 'address more.steps'|trans }} {{ address.steps }}</span>
|
||||
{% endif %}
|
||||
{% if address.buildingName is not empty %}
|
||||
<span class="buildingName">{{ 'address more.buildingName'|trans }} {{ address.buildingName }}</span>
|
||||
{% endif %}
|
||||
{% if address.flat is not empty %}
|
||||
<span class="flat">{{ 'address more.flat'|trans }} {{ address.flat }}</span>
|
||||
{% endif %}
|
||||
{% if address.extra is not empty %}
|
||||
<span class="extra">{{ 'address more.extra'|trans }} {{ address.extra }}</span>
|
||||
{% endif %}
|
||||
{% if address.distribution is not empty %}
|
||||
<span class="distribution">{{ 'address more.distribution'|trans }} {{ address.distribution }}</span>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro inline(address, options, streetLine) %}
|
||||
{% macro inline(address, options, streetLine, lines) %}
|
||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||
{% if address.postCode is not empty %}
|
||||
<p class="postcode">
|
||||
<span class="code">{{ address.postCode.code }}</span>
|
||||
<span class="name">{{ address.postCode.name }}</span>
|
||||
<span class="name">{{ address.distribution }}</span>
|
||||
</p>
|
||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||
{% endif %}
|
||||
@ -68,7 +34,7 @@
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
|
||||
{{ _self.raw(address, options, streetLine) }}
|
||||
{{ _self.raw(lines) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{{ _self.validity(address, options) }}
|
||||
@ -97,7 +63,7 @@
|
||||
{% if options['with_picto'] %}
|
||||
<i class="fa fa-li fa-map-marker"></i>
|
||||
{% endif %}
|
||||
{{ _self.inline(address, options, streetLine) }}
|
||||
{{ _self.inline(address, options, streetLine, lines) }}
|
||||
</li>
|
||||
{%- endif -%}
|
||||
|
||||
@ -106,7 +72,7 @@
|
||||
{% if options['with_picto'] %}
|
||||
<i class="fa fa-fw fa-map-marker"></i>
|
||||
{% endif %}
|
||||
{{ _self.inline(address, options, streetLine) }}
|
||||
{{ _self.inline(address, options, streetLine, lines) }}
|
||||
</span>
|
||||
{%- endif -%}
|
||||
|
||||
@ -118,6 +84,7 @@
|
||||
<p class="postcode">
|
||||
<span class="code">{{ address.postCode.code }}</span>
|
||||
<span class="name">{{ address.postCode.name }}</span>
|
||||
<span class="name">{{ address.distribution }}</span>
|
||||
</p>
|
||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||
</div>
|
||||
@ -131,7 +98,7 @@
|
||||
{% if options['with_picto'] %}
|
||||
<i class="fa fa-fw fa-map-marker"></i>
|
||||
{% endif %}
|
||||
{{ _self.raw(address, options, streetLine) }}
|
||||
{{ _self.raw(lines) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ _self.validity(address, options) }}
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\MainBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Templating\Entity\AddressRender;
|
||||
use DateTimeInterface;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
@ -46,6 +47,13 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
'validTo' => DateTimeInterface::class,
|
||||
];
|
||||
|
||||
private AddressRender $addressRender;
|
||||
|
||||
public function __construct(AddressRender $addressRender)
|
||||
{
|
||||
$this->addressRender = $addressRender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
* @param string|null $format
|
||||
@ -53,19 +61,9 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
public function normalize($address, $format = null, array $context = [])
|
||||
{
|
||||
if ($address instanceof Address) {
|
||||
$text = $address->isNoAddress() ? '' : $address->getStreet() . ', ' . $address->getStreetNumber();
|
||||
|
||||
if (null !== $address->getPostCode()->getCountry()->getCountryCode()) {
|
||||
if ($address->getPostCode()->getCountry()->getCountryCode() === 'FR') {
|
||||
$text = $address->isNoAddress() ? '' : $address->getStreetNumber() . ', ' . $address->getStreet();
|
||||
} else {
|
||||
$text = $address->isNoAddress() ? '' : $address->getStreetNumber() . ', ' . $address->getStreet();
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'address_id' => $address->getId(),
|
||||
'text' => $text,
|
||||
'text' => $address->isNoAddress() ? null : $this->addressRender->renderStreetLine($address, []),
|
||||
'street' => $address->getStreet(),
|
||||
'streetNumber' => $address->getStreetNumber(),
|
||||
'postcode' => [
|
||||
@ -85,6 +83,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
'buildingName' => $address->getBuildingName(),
|
||||
'distribution' => $address->getDistribution(),
|
||||
'extra' => $address->getExtra(),
|
||||
'lines' => $this->addressRender->renderLines($address),
|
||||
];
|
||||
|
||||
if ('json' === $format) {
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
@ -55,16 +56,21 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
$context,
|
||||
['docgen:expects' => Center::class, 'groups' => 'docgen:read']
|
||||
);
|
||||
$locationContext = array_merge(
|
||||
$context,
|
||||
['docgen:expects' => Location::class, 'groups' => 'dogen:read']
|
||||
);
|
||||
|
||||
if (null === $user && 'docgen' === $format) {
|
||||
return array_merge(self::NULL_USER, [
|
||||
'user_job' => $this->normalizer->normalize(null, $format, $userJobContext),
|
||||
'main_center' => $this->normalizer->normalize(null, $format, $centerContext),
|
||||
'main_scope' => $this->normalizer->normalize(null, $format, $scopeContext),
|
||||
'current_location' => $this->normalizer->normalize(null, $format, $locationContext),
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
$data = [
|
||||
'type' => 'user',
|
||||
'id' => $user->getId(),
|
||||
'username' => $user->getUsername(),
|
||||
@ -75,6 +81,12 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
'main_center' => $this->normalizer->normalize($user->getMainCenter(), $format, $centerContext),
|
||||
'main_scope' => $this->normalizer->normalize($user->getMainScope(), $format, $scopeContext),
|
||||
];
|
||||
|
||||
if ('docgen' === $format) {
|
||||
$data['current_location'] = $this->normalizer->normalize($user->getCurrentLocation(), $format, $locationContext);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, $format = null, array $context = []): bool
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
use function array_merge;
|
||||
@ -26,14 +27,18 @@ class AddressRender implements ChillEntityRenderInterface
|
||||
'with_delimiter' => false,
|
||||
'has_no_address' => false,
|
||||
'multiline' => true,
|
||||
/* deprecated */
|
||||
'extended_infos' => false,
|
||||
];
|
||||
|
||||
private EngineInterface $templating;
|
||||
|
||||
public function __construct(EngineInterface $templating)
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(EngineInterface $templating, TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->templating = $templating;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,43 +55,49 @@ class AddressRender implements ChillEntityRenderInterface
|
||||
'streetLine' => $this->renderStreetLine($addr),
|
||||
'render' => $options['render'] ?? 'bloc',
|
||||
'options' => $options,
|
||||
'lines' => $this->renderLines($addr),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address addr
|
||||
* @param mixed $addr
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function renderString($addr, array $options): string
|
||||
public function renderLines($addr): array
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
$lines[0] = $this->renderStreetLine($addr);
|
||||
|
||||
if (!empty($addr->getPostcode())) {
|
||||
$lines[1] = strtr('{postcode} {label}', [
|
||||
'{postcode}' => $addr->getPostcode()->getCode(),
|
||||
'{label}' => $addr->getPostcode()->getName(),
|
||||
]);
|
||||
if (null !== $addr->getPostCode()) {
|
||||
if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') {
|
||||
$lines[] = $this->renderIntraBuildingLine($addr);
|
||||
$lines[] = $this->renderBuildingLine($addr);
|
||||
$lines[] = $this->renderStreetLine($addr);
|
||||
$lines[] = $this->renderDeliveryLine($addr);
|
||||
$lines[] = $this->renderCityLine($addr);
|
||||
$lines[] = $this->renderCountryLine($addr);
|
||||
} else {
|
||||
$lines[] = $this->renderBuildingLine($addr);
|
||||
$lines[] = $this->renderDeliveryLine($addr);
|
||||
$lines[] = $this->renderStreetLine($addr);
|
||||
$lines[] = $this->renderCityLine($addr);
|
||||
$lines[] = $this->renderCountryLine($addr);
|
||||
}
|
||||
}
|
||||
|
||||
return implode(' - ', $lines);
|
||||
return array_values(array_filter($lines, static fn ($l) => null !== $l));
|
||||
}
|
||||
|
||||
public function supports($entity, array $options): bool
|
||||
public function renderStreetLine(Address $addr): ?string
|
||||
{
|
||||
return $entity instanceof Address;
|
||||
}
|
||||
|
||||
private function renderStreetLine($addr): string
|
||||
{
|
||||
if (!empty($addr->getStreet())) {
|
||||
if (null !== $addr->getStreet() && $addr->getStreet() !== '') {
|
||||
$street = $addr->getStreet();
|
||||
} else {
|
||||
$street = '';
|
||||
}
|
||||
|
||||
if (!empty($addr->getStreetNumber())) {
|
||||
if (null !== $addr->getStreetNumber() && $addr->getStreetNumber() !== '') {
|
||||
$streetNumber = $addr->getStreetNumber();
|
||||
} else {
|
||||
$streetNumber = '';
|
||||
@ -100,8 +111,111 @@ class AddressRender implements ChillEntityRenderInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (',' === $res) {
|
||||
$res = '';
|
||||
if ((',' === $res) || ('' === $res)) {
|
||||
$res = null;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address addr
|
||||
* @param mixed $addr
|
||||
*/
|
||||
public function renderString($addr, array $options): string
|
||||
{
|
||||
return implode(' - ', $this->renderLines($addr));
|
||||
}
|
||||
|
||||
public function supports($entity, array $options): bool
|
||||
{
|
||||
return $entity instanceof Address;
|
||||
}
|
||||
|
||||
private function renderBuildingLine(Address $addr): ?string
|
||||
{
|
||||
if (null !== $addr->getBuildingName() && $addr->getBuildingName() !== '') {
|
||||
$building = $addr->getBuildingName();
|
||||
} else {
|
||||
$building = '';
|
||||
}
|
||||
$intraBuilding = $this->renderIntraBuildingLine($addr);
|
||||
|
||||
if (null === $intraBuilding) {
|
||||
$intraBuilding = '';
|
||||
}
|
||||
|
||||
$res = trim($building . ' - ' . $intraBuilding, ' - ');
|
||||
|
||||
if ('' === $res) {
|
||||
$res = null;
|
||||
}
|
||||
|
||||
if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) {
|
||||
if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') {
|
||||
$res = $addr->getBuildingName();
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
private function renderCityLine($addr): string
|
||||
{
|
||||
if (null !== $addr->getPostcode()) {
|
||||
$res = strtr('{postcode} {label}', [
|
||||
'{postcode}' => $addr->getPostcode()->getCode(),
|
||||
'{label}' => $addr->getPostcode()->getName(),
|
||||
]);
|
||||
|
||||
if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) {
|
||||
if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') {
|
||||
if ($addr->getDistribution()) {
|
||||
$res = $res . ' ' . $addr->getDistribution();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res ?? '';
|
||||
}
|
||||
|
||||
private function renderCountryLine($addr): ?string
|
||||
{
|
||||
return $this->translatableStringHelper->localize(
|
||||
$addr->getPostCode()->getCountry()->getName()
|
||||
);
|
||||
}
|
||||
|
||||
private function renderDeliveryLine($addr): ?string
|
||||
{
|
||||
return $addr->getExtra();
|
||||
}
|
||||
|
||||
private function renderIntraBuildingLine($addr): ?string
|
||||
{
|
||||
$arr = [];
|
||||
|
||||
if ($addr->getFlat()) {
|
||||
$arr[] = 'appart ' . $addr->getFlat();
|
||||
}
|
||||
|
||||
if ($addr->getFloor()) {
|
||||
$arr[] = 'ét ' . $addr->getFloor();
|
||||
}
|
||||
|
||||
if ($addr->getCorridor()) {
|
||||
$arr[] = 'coul ' . $addr->getCorridor();
|
||||
}
|
||||
|
||||
if ($addr->getSteps()) {
|
||||
$arr[] = 'esc ' . $addr->getSteps();
|
||||
}
|
||||
|
||||
$res = implode(' - ', $arr);
|
||||
|
||||
if ('' === $res) {
|
||||
$res = null;
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Templating\Entity\AddressRender;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Iterator;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
@ -30,11 +31,11 @@ final class AddressRenderTest extends KernelTestCase
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
public function addressDataProvider(): Iterator
|
||||
public function addressDataProviderBEWithBuilding(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'Pays'])
|
||||
->setName(['fr' => 'Belgium'])
|
||||
->setCountryCode('BE');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
@ -45,20 +46,279 @@ final class AddressRenderTest extends KernelTestCase
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
yield [$addr, 'Rue ABC, 5 - 012345 Locality'];
|
||||
$addr->setBuildingName('Résidence "Les Bleuets"');
|
||||
|
||||
yield [$addr, 'Résidence "Les Bleuets" - Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
}
|
||||
|
||||
public function addressDataProviderBEWithSteps(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'Belgium'])
|
||||
->setCountryCode('BE');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setStreet('Rue ABC')
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
$addr->setSteps('4');
|
||||
|
||||
yield [$addr, 'esc 4 - Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
}
|
||||
|
||||
public function addressDataProviderFRWithBuilding(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'France'])
|
||||
->setCountryCode('FR');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setStreet('Rue ABC')
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
$addr->setBuildingName('Résidence "Les Bleuets"');
|
||||
|
||||
yield [$addr, 'Résidence "Les Bleuets" - 5, Rue ABC - 012345 Locality - France'];
|
||||
}
|
||||
|
||||
public function addressDataProviderFRWithSteps(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'France'])
|
||||
->setCountryCode('FR');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setStreet('Rue ABC')
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
$addr->setSteps('4');
|
||||
|
||||
yield [$addr, 'esc 4 - 5, Rue ABC - 012345 Locality - France'];
|
||||
}
|
||||
|
||||
public function complexAddressDataProviderBE(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'Belgium'])
|
||||
->setCountryCode('BE');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setStreet('Rue ABC')
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
$addr->setBuildingName('Résidence "Les Bleuets"');
|
||||
$addr->setFlat('1');
|
||||
$addr->setFloor('2');
|
||||
$addr->setCorridor('3');
|
||||
$addr->setSteps('4');
|
||||
|
||||
yield [$addr, 'Résidence "Les Bleuets" - appart 1 - ét 2 - coul 3 - esc 4 - Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
}
|
||||
|
||||
public function complexAddressDataProviderFR(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'France'])
|
||||
->setCountryCode('FR');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setStreet('Rue ABC')
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
$addr->setBuildingName('Résidence "Les Bleuets"');
|
||||
$addr->setFlat('1');
|
||||
$addr->setFloor('2');
|
||||
$addr->setCorridor('3');
|
||||
$addr->setSteps('4');
|
||||
$addr->setExtra('A droite de la porte');
|
||||
$addr->setDistribution('CEDEX');
|
||||
|
||||
yield [$addr, 'appart 1 - ét 2 - coul 3 - esc 4 - Résidence "Les Bleuets" - 5, Rue ABC - A droite de la porte - 012345 Locality CEDEX - France'];
|
||||
}
|
||||
|
||||
public function noFullAddressDataProviderBE(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'Belgium'])
|
||||
->setCountryCode('BE');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setPostcode($postCode)
|
||||
->setIsNoAddress(true);
|
||||
|
||||
yield [$addr, '012345 Locality - Belgium'];
|
||||
}
|
||||
|
||||
public function simpleAddressDataProviderBE(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'Belgium'])
|
||||
->setCountryCode('BE');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setStreet('Rue ABC')
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
yield [$addr, 'Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
}
|
||||
|
||||
public function simpleAddressDataProviderFR(): Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
->setName(['fr' => 'France'])
|
||||
->setCountryCode('FR');
|
||||
$postCode = new PostalCode();
|
||||
$postCode->setName('Locality')
|
||||
->setCode('012345')
|
||||
->setCountry($country);
|
||||
|
||||
$addr->setStreet('Rue ABC')
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
yield [$addr, '5, Rue ABC - 012345 Locality - France'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addressDataProvider
|
||||
* @dataProvider complexAddressDataProviderBE
|
||||
*/
|
||||
public function testRenderString(Address $addr, string $expectedString): void
|
||||
public function testRenderComplexAddressBE(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$renderer = new AddressRender($engine);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
return;
|
||||
$this->assertIsString($renderer->renderBox($addr, []));
|
||||
/**
|
||||
* @dataProvider complexAddressDataProviderFR
|
||||
*/
|
||||
public function testRenderComplexAddressFR(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider noFullAddressDataProviderBE
|
||||
*/
|
||||
public function testRenderNoFullAddressBE(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider simpleAddressDataProviderBE
|
||||
*/
|
||||
public function testRenderStringSimpleAddressBE(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider simpleAddressDataProviderFR
|
||||
*/
|
||||
public function testRenderStringSimpleAddressFR(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addressDataProviderBEWithBuilding
|
||||
*/
|
||||
public function testRenderWithBuildingAddressBE(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addressDataProviderFRWithBuilding
|
||||
*/
|
||||
public function testRenderWithBuildingAddressFR(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addressDataProviderBEWithSteps
|
||||
*/
|
||||
public function testRenderWithStepsAddressBE(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addressDataProviderFRWithSteps
|
||||
*/
|
||||
public function testRenderWithStepsAddressFR(Address $addr, string $expectedString): void
|
||||
{
|
||||
$engine = self::$container->get(EngineInterface::class);
|
||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||
|
||||
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepos
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@ -110,6 +111,60 @@ class AccompanyingCourseController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete page of Accompanying Course section.
|
||||
*
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/delete", name="chill_person_accompanying_course_delete")
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
public function deleteAction(Request $request, AccompanyingPeriod $accompanyingCourse)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$person_id = $request->query->get('person_id');
|
||||
|
||||
$form = $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('chill_person_accompanying_course_delete', [
|
||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
'person_id' => $person_id,
|
||||
]))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm();
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em->remove($accompanyingCourse);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
->trans('The accompanying course has been successfully removed.'));
|
||||
|
||||
if (null !== $person_id) {
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_list', [
|
||||
'person_id' => $person_id,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('chill_main_homepage');
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $person_id) {
|
||||
$view = '@ChillPerson/AccompanyingCourse/confirm_delete_person.html.twig';
|
||||
} else {
|
||||
$view = '@ChillPerson/AccompanyingCourse/confirm_delete_accompanying_course.html.twig';
|
||||
}
|
||||
|
||||
return $this->render($view, [
|
||||
'accompanyingCourse' => $accompanyingCourse,
|
||||
'person_id' => $person_id,
|
||||
'delete_form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit page of Accompanying Course section.
|
||||
*
|
||||
@ -208,6 +263,9 @@ class AccompanyingCourseController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$userLocation = $this->getUser()->getCurrentLocation();
|
||||
$period->setAdministrativeLocation($userLocation);
|
||||
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period);
|
||||
|
||||
$em->persist($period);
|
||||
|
@ -17,6 +17,7 @@ use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\HasCentersInterface;
|
||||
use Chill\MainBundle\Entity\HasScopesInterface;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
@ -118,6 +119,13 @@ class AccompanyingPeriod implements
|
||||
*/
|
||||
private ?Address $addressLocation = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
||||
* @Groups({"read", "write"})
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*/
|
||||
private ?Location $administrativeLocation = null;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*
|
||||
@ -507,6 +515,11 @@ class AccompanyingPeriod implements
|
||||
return $this->addressLocation;
|
||||
}
|
||||
|
||||
public function getAdministrativeLocation(): ?Location
|
||||
{
|
||||
return $this->administrativeLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of person which have an adresse available for a valid location.
|
||||
*
|
||||
@ -980,6 +993,13 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAdministrativeLocation(?Location $administrativeLocation): AccompanyingPeriod
|
||||
{
|
||||
$this->administrativeLocation = $administrativeLocation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set closingDate.
|
||||
*
|
||||
|
@ -39,32 +39,32 @@ class AccompanyingPeriodWorkGoal
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Goal::class)
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private $goal;
|
||||
private ?Goal $goal = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private $id;
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $note;
|
||||
private ?string $note = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
|
||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private $results;
|
||||
private Collection $results;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ class Relation
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
<persons-associated></persons-associated>
|
||||
<course-location></course-location>
|
||||
<origin-demand></origin-demand>
|
||||
<admin-location></admin-location>
|
||||
<requestor v-bind:isAnonymous="accompanyingCourse.requestorAnonymous"></requestor>
|
||||
<social-issue></social-issue>
|
||||
<scopes></scopes>
|
||||
@ -28,6 +29,7 @@ import { mapGetters, mapState } from 'vuex'
|
||||
import Banner from './components/Banner.vue';
|
||||
import StickyNav from './components/StickyNav.vue';
|
||||
import OriginDemand from './components/OriginDemand.vue';
|
||||
import AdminLocation from './components/AdminLocation.vue';
|
||||
import PersonsAssociated from './components/PersonsAssociated.vue';
|
||||
import Requestor from './components/Requestor.vue';
|
||||
import SocialIssue from './components/SocialIssue.vue';
|
||||
@ -44,6 +46,7 @@ export default {
|
||||
Banner,
|
||||
StickyNav,
|
||||
OriginDemand,
|
||||
AdminLocation,
|
||||
PersonsAssociated,
|
||||
Requestor,
|
||||
SocialIssue,
|
||||
|
@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h2><a id="section-40"></a>{{ $t('admin_location.title') }}</h2>
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="selectAdminLocation">
|
||||
{{ $t('admin_location.title') }}
|
||||
</label>
|
||||
|
||||
<VueMultiselect
|
||||
name="selectAdminLocation"
|
||||
label="text"
|
||||
:custom-label="customLabel"
|
||||
track-by="id"
|
||||
:multiple="false"
|
||||
:searchable="true"
|
||||
:placeholder="$t('admin_location.placeholder')"
|
||||
v-model="value"
|
||||
:options="options"
|
||||
group-values="locations"
|
||||
group-label="locationCategories"
|
||||
@select="updateAdminLocation">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
|
||||
<div v-if="!isAdminLocationValid" class="alert alert-warning to-confirm">
|
||||
{{ $t('admin_location.not_valid') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VueMultiselect from 'vue-multiselect';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'AdminLocation',
|
||||
components: { VueMultiselect },
|
||||
data() {
|
||||
return {
|
||||
options: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
value: state => state.accompanyingCourse.administrativeLocation,
|
||||
}),
|
||||
...mapGetters([
|
||||
'isAdminLocationValid'
|
||||
])
|
||||
},
|
||||
mounted() {
|
||||
this.getOptions();
|
||||
},
|
||||
methods: {
|
||||
getOptions() {
|
||||
const url = `/api/1.0/main/location.json`;
|
||||
makeFetch('GET', url)
|
||||
.then(response => {
|
||||
let options = response.results;
|
||||
let uniqueLocationTypeId = [...new Set(options.map(o => o.locationType.id))];
|
||||
let results = [];
|
||||
for (let id of uniqueLocationTypeId) {
|
||||
results.push({
|
||||
locationCategories: options.filter(o => o.locationType.id === id)[0].locationType.title.fr,
|
||||
locations: options.filter(o => o.locationType.id === id)
|
||||
})
|
||||
}
|
||||
this.options = results;
|
||||
return response;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toast.open({message: error.txt})
|
||||
})
|
||||
},
|
||||
updateAdminLocation(value) {
|
||||
this.$store.dispatch('updateAdminLocation', value)
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'})
|
||||
}
|
||||
});
|
||||
},
|
||||
customLabel(value) {
|
||||
return value.locationType
|
||||
? value.name
|
||||
? `${value.name} (${value.locationType.title.fr})`
|
||||
: value.locationType.title.fr
|
||||
: '';
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||
<style lang="css" scoped>
|
||||
label {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<span v-for="h in personsByHousehold()" :class="{ 'household': householdExists(h.id), 'no-household': !householdExists(h.id) }">
|
||||
<span v-for="h in personsByHousehold()" :class="{ 'household': householdExists(h.id), 'no-household': !householdExists(h.id) }" :key="h.id">
|
||||
<a v-if="householdExists(h.id)" :href="householdLink(h.id)">
|
||||
<i class="fa fa-home fa-fw text-light" :title="$t('persons_associated.show_household_number', { id: h.id })"></i>
|
||||
</a>
|
||||
<span v-for="person in h.persons" class="me-1">
|
||||
<span v-for="person in h.persons" class="me-1" :key="person.id">
|
||||
<on-the-fly :type="person.type" :id="person.id" :buttonText="person.text" :displayBadge="'true' === 'true'" action="show"></on-the-fly>
|
||||
</span>
|
||||
</span>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h2><a id="section-90"></a>{{ $t('comment.title') }}</h2>
|
||||
<h2><a id="section-100"></a>{{ $t('comment.title') }}</h2>
|
||||
|
||||
<!--div class="error flash_message" v-if="errors.length > 0">
|
||||
{{ errors[0] }}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h2><a id="section-100"></a>
|
||||
<h2><a id="section-110"></a>
|
||||
{{ $t('confirm.title') }}
|
||||
</h2>
|
||||
<div>
|
||||
@ -24,6 +24,11 @@
|
||||
{{ $t('confirm.ok') }}
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-delete" :href="deleteLink">
|
||||
{{ $t('confirm.delete') }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -37,6 +42,11 @@
|
||||
{{ $t('confirm.ok') }}
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-delete" :href="deleteLink">
|
||||
{{ $t('confirm.delete') }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -89,13 +99,17 @@ export default {
|
||||
msg: 'confirm.origin_not_valid',
|
||||
anchor: '#section-30'
|
||||
},
|
||||
adminLocation: {
|
||||
msg: 'confirm.adminLocation_not_valid',
|
||||
anchor: '#section-40'
|
||||
},
|
||||
socialIssue: {
|
||||
msg: 'confirm.socialIssue_not_valid',
|
||||
anchor: '#section-50'
|
||||
anchor: '#section-60'
|
||||
},
|
||||
scopes: {
|
||||
msg: 'confirm.set_a_scope',
|
||||
anchor: '#section-60'
|
||||
anchor: '#section-70'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,10 +122,14 @@ export default {
|
||||
'isParticipationValid',
|
||||
'isSocialIssueValid',
|
||||
'isOriginValid',
|
||||
'isAdminLocationValid',
|
||||
'isLocationValid',
|
||||
'validationKeys',
|
||||
'isValidToBeConfirmed'
|
||||
])
|
||||
]),
|
||||
deleteLink() {
|
||||
return `/fr/parcours/${this.accompanyingCourse.id}/delete`; //TODO locale
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
confirmCourse() {
|
||||
|
@ -4,7 +4,7 @@
|
||||
{{ $t('courselocation.title') }}
|
||||
</h2>
|
||||
|
||||
<div v-for="error in displayErrors" class="alert alert-danger my-2">
|
||||
<div v-for="error in displayErrors" class="alert alert-danger my-2" :key="error">
|
||||
{{ error }}
|
||||
</div>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="selectOrigin">
|
||||
{{ $t('origin.label.fr') }}
|
||||
{{ $t('origin.title') }}
|
||||
</label>
|
||||
|
||||
<VueMultiselect
|
||||
@ -17,6 +17,9 @@
|
||||
:placeholder="$t('origin.placeholder')"
|
||||
v-model="value"
|
||||
:options="options"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
@select="updateOrigin">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h2><a id="section-70"></a>{{ $t('referrer.title') }}</h2>
|
||||
<h2><a id="section-80"></a>{{ $t('referrer.title') }}</h2>
|
||||
|
||||
<div>
|
||||
<label class="col-form-label" for="selectReferrer">
|
||||
@ -11,17 +11,20 @@
|
||||
name="selectReferrer"
|
||||
label="text"
|
||||
track-by="id"
|
||||
v-bind:multiple="false"
|
||||
v-bind:searchable="true"
|
||||
v-bind:placeholder="$t('referrer.placeholder')"
|
||||
:multiple="false"
|
||||
:searchable="true"
|
||||
:placeholder="$t('referrer.placeholder')"
|
||||
v-model="value"
|
||||
v-bind:options="users"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
@select="updateReferrer">
|
||||
</VueMultiselect>
|
||||
|
||||
<template v-if="referrersSuggested.length > 0">
|
||||
<ul class="list-suggest add-items inline">
|
||||
<li v-for="u in referrersSuggested" @click="updateReferrer(u)">
|
||||
<li v-for="(u, i) in referrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
|
||||
<span>
|
||||
<user-render-box-badge :user="u"></user-render-box-badge>
|
||||
</span>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
|
||||
<h2><a id="section-40"></a>{{ $t('requestor.title') }}</h2>
|
||||
<h2><a id="section-50"></a>{{ $t('requestor.title') }}</h2>
|
||||
|
||||
<div v-if="accompanyingCourse.requestor && isAnonymous" class="flex-table">
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
|
||||
<h2><a id="section-80"></a>{{ $t('resources.title')}}</h2>
|
||||
<h2><a id="section-90"></a>{{ $t('resources.title')}}</h2>
|
||||
|
||||
<div v-if="resources.length > 0">
|
||||
<label class="col-form-label">{{ $tc('resources.counter', counter) }}</label>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h2><a id="section-60"></a>{{ $t('scopes.title') }}</h2>
|
||||
<h2><a id="section-70"></a>{{ $t('scopes.title') }}</h2>
|
||||
|
||||
<div class="mb-4">
|
||||
<div class="form-check" v-for="s in scopes" :key="s.id">
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h2><a id="section-50"></a>{{ $t('social_issue.title') }}</h2>
|
||||
<h2><a id="section-60"></a>{{ $t('social_issue.title') }}</h2>
|
||||
|
||||
<div class="my-4">
|
||||
<!--label for="field">{{ $t('social_issue.label') }}</label
|
||||
|
@ -37,6 +37,12 @@ const appMessages = {
|
||||
placeholder: "Renseignez l'origine de la demande",
|
||||
not_valid: "Indiquez une origine à la demande",
|
||||
},
|
||||
admin_location: {
|
||||
title: "Localisation administrative",
|
||||
label: "Localisation administrative",
|
||||
placeholder: "Renseignez la localisation administrative",
|
||||
not_valid: "Indiquez une localisation administrative",
|
||||
},
|
||||
persons_associated: {
|
||||
title: "Usagers concernés",
|
||||
counter: "Il n'y a pas encore d'usagers | 1 usager | {count} usagers",
|
||||
@ -127,10 +133,12 @@ const appMessages = {
|
||||
socialIssue_not_valid: "sélectionnez au minimum une problématique sociale",
|
||||
location_not_valid: "indiquez au minimum une localisation temporaire du parcours",
|
||||
origin_not_valid: "Indiquez une origine à la demande",
|
||||
adminLocation_not_valid: "Indiquez une localisation administrative à la demande",
|
||||
set_a_scope: "indiquez au moins un service",
|
||||
sure: "Êtes-vous sûr ?",
|
||||
sure_description: "Une fois le changement confirmé, il ne sera plus possible de le remettre à l'état de brouillon !",
|
||||
ok: "Confirmer le parcours"
|
||||
ok: "Confirmer le parcours",
|
||||
delete: "Supprimer le parcours"
|
||||
},
|
||||
// catch errors
|
||||
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",
|
||||
|
@ -49,6 +49,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
isOriginValid(state) {
|
||||
return state.accompanyingCourse.origin !== null;
|
||||
},
|
||||
isAdminLocationValid(state) {
|
||||
return state.accompanyingCourse.administrativeLocation !== null;
|
||||
},
|
||||
isLocationValid(state) {
|
||||
return state.accompanyingCourse.location !== null;
|
||||
},
|
||||
@ -62,6 +65,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
if (!getters.isLocationValid) { keys.push('location'); }
|
||||
if (!getters.isSocialIssueValid) { keys.push('socialIssue'); }
|
||||
if (!getters.isOriginValid) { keys.push('origin'); }
|
||||
if (!getters.isAdminLocationValid) { keys.push('adminLocation'); }
|
||||
if (!getters.isScopeValid) { keys.push('scopes'); }
|
||||
//console.log('getter keys', keys);
|
||||
return keys;
|
||||
@ -177,6 +181,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
//console.log('value', value);
|
||||
state.accompanyingCourse.origin = value;
|
||||
},
|
||||
updateAdminLocation(state, value) {
|
||||
state.accompanyingCourse.administrativeLocation = value;
|
||||
},
|
||||
updateReferrer(state, value) {
|
||||
//console.log('value', value);
|
||||
state.accompanyingCourse.user = value;
|
||||
@ -607,6 +614,19 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
updateAdminLocation({ commit }, payload) {
|
||||
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
||||
const body = { type: "accompanying_period", administrativeLocation: { id: payload.id, type: payload.type }}
|
||||
|
||||
return makeFetch('PATCH', url, body)
|
||||
.then((response) => {
|
||||
commit('updateAdminLocation', response.administrativeLocation);
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
updateReferrer({ commit }, payload) {
|
||||
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
||||
const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<div id="picking">
|
||||
<p>{{ $t('pick_social_issue_linked_with_action') }}</p>
|
||||
<div v-for="si in socialIssues">
|
||||
<div v-for="si in socialIssues" :key="si.id">
|
||||
<input type="radio" v-bind:value="si.id" name="socialIssue" v-model="socialIssuePicked"><span class="badge bg-chill-l-gray text-dark">{{ si.text }}</span>
|
||||
</div>
|
||||
<div class="my-3">
|
||||
|
@ -2,6 +2,7 @@
|
||||
<ol class="breadcrumb">
|
||||
<li
|
||||
v-for="s in steps"
|
||||
:key="s"
|
||||
class="breadcrumb-item" :class="{ active: step === s }"
|
||||
>
|
||||
{{ $t('household_members_editor.app.steps.'+s) }}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div v-else>
|
||||
<p>
|
||||
{{ $t('household_members_editor.concerned.persons_will_be_moved') }} :
|
||||
<span v-for="c in concerned" :key=c.person.id>
|
||||
<span v-for="c in concerned" :key="c.person.id">
|
||||
<person-render-box render="badge" :options="{addLink: false}" :person="c.person"></person-render-box>
|
||||
<button class="btn" @click="removePerson(c.person)" v-if="c.allowRemove" style="padding-left:0;">
|
||||
<span class="fa-stack fa-lg" :title="$t('household_members_editor.concerned.remove_concerned')">
|
||||
@ -21,7 +21,7 @@
|
||||
</p>
|
||||
<div class="alert alert-info" v-if="concernedPersonsWithHouseholds.length > 0">
|
||||
<p>{{ $t('household_members_editor.concerned.persons_with_household') }}</p>
|
||||
<ul v-for="c in concernedPersonsWithHouseholds" :key=c.person.id>
|
||||
<ul v-for="c in concernedPersonsWithHouseholds" :key="c.person.id">
|
||||
<li>
|
||||
{{ c.person.text }}
|
||||
{{ $t('household_members_editor.concerned.already_belongs_to_household') }}
|
||||
|
@ -8,10 +8,10 @@
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li v-for="(msg, index) in warnings" class="warning">
|
||||
<li v-for="(msg, i) in warnings" class="warning" :key="i">
|
||||
{{ $t(msg.m, msg.a) }}
|
||||
</li>
|
||||
<li v-for="msg in errors" class="error">
|
||||
<li v-for="(msg, i) in errors" class="error" :key="i">
|
||||
{{ msg }}
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -39,7 +39,7 @@
|
||||
aria-labelledby="heading_household_suggestions" data-bs-parent="#householdSuggestions">
|
||||
<div v-if="showHouseholdSuggestion">
|
||||
<div class="flex-table householdSuggestionList">
|
||||
<div v-for="s in getSuggestions" class="item-bloc">
|
||||
<div v-for="(s, i) in getSuggestions" class="item-bloc" :key="`householdSuggestions-${i}`">
|
||||
<household-render-box :household="s.household"></household-render-box>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
|
@ -24,7 +24,8 @@
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-for="position in positions"
|
||||
v-for="(position, i) in positions"
|
||||
:key="`position-${i}`"
|
||||
class="position"
|
||||
>
|
||||
<button
|
||||
|
@ -23,7 +23,7 @@
|
||||
<div class="my-4 legend">
|
||||
<h3>{{ $t('visgraph.Legend') }}</h3>
|
||||
<div class="list-group">
|
||||
<label class="list-group-item" v-for="layer in legendLayers">
|
||||
<label class="list-group-item" v-for="(layer, i) in legendLayers" :key="`layer-${i}`">
|
||||
<input
|
||||
class="form-check-input me-1"
|
||||
type="checkbox"
|
||||
|
@ -0,0 +1,31 @@
|
||||
|
||||
{% macro insert_onthefly(type, entity) %}
|
||||
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
|
||||
action: 'show', displayBadge: true,
|
||||
targetEntity: { name: type, id: entity.id },
|
||||
buttonText: entity|chill_entity_render_string
|
||||
} %}
|
||||
{% endmacro %}
|
||||
|
||||
<div>
|
||||
{% if accompanyingCourse.participations is not empty %}
|
||||
<div class="col mb-4">
|
||||
<h4 class="item-key">{{ 'Persons associated'|trans }}</h4>
|
||||
{% for r in accompanyingCourse.participations %}
|
||||
{{ _self.insert_onthefly('person', r.person) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if accompanyingCourse.socialIssues is not empty %}
|
||||
<div class="col mb-4">
|
||||
<h4 class="item-key">{{ 'Social issues'|trans }}</h4>
|
||||
{% for s in accompanyingCourse.socialIssues %}
|
||||
{{ s|chill_entity_render_box }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
|
||||
|
||||
{% block title %}{{ 'Delete accompanying period'|trans }}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% include '@ChillPerson/AccompanyingCourse/_confirm_delete.html.twig' %}
|
||||
|
||||
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||
{
|
||||
'title' : 'Delete accompanying period'|trans,
|
||||
'confirm_question' : 'Are you sure you want to remove the accompanying period "%id%" ?'|trans({ '%id%' : accompanyingCourse.id } ),
|
||||
'cancel_route' : 'chill_person_accompanying_course_edit',
|
||||
'cancel_parameters' : {'accompanying_period_id' : accompanyingCourse.id},
|
||||
'form' : delete_form
|
||||
} ) }}
|
||||
{% endblock %}
|
@ -0,0 +1,18 @@
|
||||
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
|
||||
|
||||
{% block title %}{{ 'Delete accompanying period'|trans }}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% include '@ChillPerson/AccompanyingCourse/_confirm_delete.html.twig' %}
|
||||
|
||||
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||
{
|
||||
'title' : 'Delete accompanying period'|trans,
|
||||
'confirm_question' : 'Are you sure you want to remove the accompanying period "%id%" ?'|trans({ '%id%' : accompanyingCourse.id } ),
|
||||
'cancel_route' : 'chill_person_accompanying_period_list',
|
||||
'cancel_parameters' : {'person_id' : person_id},
|
||||
'form' : delete_form
|
||||
} ) }}
|
||||
{% endblock %}
|
@ -154,6 +154,15 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if accompanyingCourse.administrativeLocation is not null %}
|
||||
<div class="mbloc col col-sm-6 col-lg-4">
|
||||
<div class="administrative-location">
|
||||
<h4 class="item-key">{{ 'accompanying_course.administrative_location'|trans }}</h4>
|
||||
{{ accompanyingCourse.administrativeLocation.name }} ({{ accompanyingCourse.administrativeLocation.locationType.title|localize_translatable_string }})
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="social-actions my-4">
|
||||
|
@ -1,9 +1,15 @@
|
||||
{% macro recordAction(period) %}
|
||||
{% macro recordAction(period, person = null) %}
|
||||
{# TODO if enable_accompanying_course_with_multiple_persons is true ... #}
|
||||
<li>
|
||||
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': period.id }) }}"
|
||||
class="btn btn-show" title="{{ 'See accompanying period'|trans }}">{# {{ 'See this period'|trans }} #}</a>
|
||||
</li>
|
||||
{% if period.step == 'DRAFT' %}
|
||||
<li>
|
||||
<a href="{{ path('chill_person_accompanying_course_delete', { 'accompanying_period_id': period.id, 'person_id' : person.id }) }}"
|
||||
class="btn btn-delete" title="{{ 'Delete accompanying period'|trans }}">{# {{ 'Delete this period'|trans }} #}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{# DISABLED if new accompanying course, this is not necessary
|
||||
{% if person is defined %}
|
||||
<li>
|
||||
@ -39,7 +45,7 @@
|
||||
{% for period in accompanying_periods %}
|
||||
|
||||
{% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with {
|
||||
'recordAction': _self.recordAction(period)
|
||||
'recordAction': _self.recordAction(period, person)
|
||||
} %}
|
||||
|
||||
{% endfor %}
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
|
||||
@ -68,6 +69,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'resources' => Collection::class,
|
||||
'location' => Address::class,
|
||||
'locationPerson' => Person::class,
|
||||
'administrativeLocation' => Location::class,
|
||||
];
|
||||
|
||||
private ClosingMotiveRender $closingMotiveRender;
|
||||
@ -111,6 +113,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
$dateContext = array_merge($context, ['docgen:expects' => DateTime::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']);
|
||||
$administrativeLocationContext = array_merge($context, ['docgen:expects' => Location::class, 'groups' => 'docgen:read']);
|
||||
|
||||
return [
|
||||
'id' => $period->getId(),
|
||||
@ -153,8 +156,10 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'requestorKind' => $period->getRequestorKind(),
|
||||
'hasLocation' => $period->getLocation() !== null,
|
||||
'hasLocationPerson' => $period->getPersonLocation() !== null,
|
||||
'hasAdministrativeLocation' => $period->getAdministrativeLocation() !== null,
|
||||
'locationPerson' => $this->normalizer->normalize($period->getPersonLocation(), $format, array_merge($context, ['docgen:expects' => Person::class])),
|
||||
'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext),
|
||||
'administrativeLocation' => $this->normalizer->normalize($period->getAdministrativeLocation(), $format, $administrativeLocationContext),
|
||||
];
|
||||
}
|
||||
|
||||
@ -172,6 +177,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'confidential' => false,
|
||||
'hasLocation' => false,
|
||||
'hasLocationPerson' => false,
|
||||
'hasAdministrativeLocation' => false,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class PersonDocGenNormalizer implements
|
||||
$normalizer = new NormalizeNullValueHelper($this->normalizer, 'type', 'person');
|
||||
|
||||
$attributes = [
|
||||
'firstname', 'lastname', 'altNames', 'text',
|
||||
'firstname', 'lastname', 'age', 'altNames', 'text',
|
||||
'civility' => Civility::class,
|
||||
'birthdate' => DateTimeInterface::class,
|
||||
'deathdate' => DateTimeInterface::class,
|
||||
|
@ -306,6 +306,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testAccompanyingCourseAddParticipation(int $personId, int $periodId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$this->client->request(
|
||||
Request::METHOD_POST,
|
||||
sprintf('/api/1.0/person/accompanying-course/%d/participation.json', $periodId),
|
||||
@ -377,6 +378,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testAccompanyingCourseAddRemoveSocialIssue(AccompanyingPeriod $period, SocialIssue $si)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$this->client->request(
|
||||
Request::METHOD_POST,
|
||||
sprintf('/api/1.0/person/accompanying-course/%d/socialissue.json', $period->getId()),
|
||||
@ -437,6 +439,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testAccompanyingPeriodPatch(int $personId, int $periodId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$period = self::$container->get(AccompanyingPeriodRepository::class)
|
||||
->find($periodId);
|
||||
$initialValueEmergency = $period->isEmergency();
|
||||
@ -475,6 +478,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testCommentWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$this->client->request(
|
||||
@ -515,6 +519,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testConfirm(AccompanyingPeriod $period)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$this->client->request(
|
||||
Request::METHOD_POST,
|
||||
sprintf('/api/1.0/person/accompanying-course/%d/confirm.json', $period->getId())
|
||||
@ -551,6 +556,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testRequestorWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
// post a person
|
||||
@ -634,6 +640,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testResourceWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
// post a person
|
||||
|
@ -166,7 +166,7 @@ final class PersonControllerCreateTest extends WebTestCase
|
||||
$form = $this->fillAValidCreationForm($form, 'Charline', 'dd');
|
||||
$client->submit($form);
|
||||
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'DEPARDIEU',
|
||||
$client->getCrawler()->text(),
|
||||
'check that the page has detected the lastname of a person existing in database'
|
||||
@ -177,7 +177,7 @@ final class PersonControllerCreateTest extends WebTestCase
|
||||
$form = $this->fillAValidCreationForm($form, 'dd', 'Charline');
|
||||
$client->submit($form);
|
||||
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'DEPARDIEU',
|
||||
$client->getCrawler()->text(),
|
||||
'check that the page has detected the lastname of a person existing in database'
|
||||
|
@ -83,10 +83,10 @@ final class PersonControllerViewTest extends WebTestCase
|
||||
|
||||
$this->assertGreaterThan(0, $crawler->filter('html:contains("TESTED PERSON")')->count());
|
||||
$this->assertGreaterThan(0, $crawler->filter('html:contains("Réginald")')->count());
|
||||
$this->assertContains('Email addresses', $crawler->text());
|
||||
$this->assertContains('Phonenumber', $crawler->text());
|
||||
$this->assertContains('Langues parlées', $crawler->text());
|
||||
$this->assertContains(/* Etat */ 'civil', $crawler->text());
|
||||
$this->assertStringContainsString('Email addresses', $crawler->text());
|
||||
$this->assertStringContainsString('Phonenumber', $crawler->text());
|
||||
$this->assertStringContainsString('Langues parlées', $crawler->text());
|
||||
$this->assertStringContainsString(/* Etat */ 'civil', $crawler->text());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,10 +94,15 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
||||
'hasRequestorThirdParty' => false,
|
||||
'requestorPerson' => '@ignored',
|
||||
'requestorThirdParty' => '@ignored',
|
||||
'administrativeLocation' => '@ignored',
|
||||
'hasAdministrativeLocation' => false,
|
||||
'hasLocation' => false,
|
||||
'hasLocationPerson' => false,
|
||||
'location' => '@ignored',
|
||||
'locationPerson' => '@ignored',
|
||||
];
|
||||
|
||||
$this->assertIsArray($data);
|
||||
$this->markTestSkipped('still in specification');
|
||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
|
||||
|
||||
foreach ($expected as $key => $item) {
|
||||
@ -149,10 +154,15 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
|
||||
'requestorPerson' => '@ignored',
|
||||
'requestorThirdParty' => '@ignored',
|
||||
'isNull' => true,
|
||||
'administrativeLocation' => '@ignored',
|
||||
'hasAdministrativeLocation' => false,
|
||||
'hasLocation' => false,
|
||||
'hasLocationPerson' => false,
|
||||
'location' => '@ignored',
|
||||
'locationPerson' => '@ignored',
|
||||
];
|
||||
|
||||
$this->assertIsArray($data);
|
||||
$this->markTestSkipped('still in specification');
|
||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($data));
|
||||
|
||||
foreach ($expected as $key => $item) {
|
||||
|
@ -23,6 +23,7 @@ use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
|
||||
use Chill\PersonBundle\Serializer\Normalizer\PersonDocGenNormalizer;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
@ -34,6 +35,8 @@ use function array_merge;
|
||||
*/
|
||||
final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private const BLANK = [
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
@ -88,6 +91,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
|
||||
public function testNormalizationNullOrNotNullHaveSameKeys()
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
$period = new Person();
|
||||
$notNullData = $this->buildPersonNormalizer()->normalize($period, 'docgen', ['docgen:expects' => Person::class]);
|
||||
$nullData = $this->buildPersonNormalizer()->normalize(null, 'docgen', ['docgen:expects' => Person::class]);
|
||||
@ -126,6 +130,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
|
||||
public function testNormalizePersonWithHousehold()
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
$household = new Household();
|
||||
$person = new Person();
|
||||
$person
|
||||
@ -166,6 +171,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
|
||||
public function testNormalizePersonWithRelationships()
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
$person = (new Person())->setFirstName('Renaud')->setLastName('megane');
|
||||
$father = (new Person())->setFirstName('Clément')->setLastName('megane');
|
||||
$mother = (new Person())->setFirstName('Mireille')->setLastName('Mathieu');
|
||||
@ -199,6 +205,55 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
|
||||
$this->assertCount(3, $actual['relations']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the @see{PersonDocGenNormalizer::class} works without interaction with other
|
||||
* serializers.
|
||||
*
|
||||
* @dataProvider generateData
|
||||
*
|
||||
* @param mixed $expected
|
||||
* @param mixed $msg
|
||||
*/
|
||||
public function testNormalizeUsingNormalizer(?Person $person, $expected, $msg)
|
||||
{
|
||||
$normalizer = $this->buildNormalizer();
|
||||
|
||||
$this->assertTrue($normalizer->supportsNormalization($person, 'docgen', [
|
||||
'docgen:expects' => Person::class,
|
||||
'groups' => ['docgen:read'],
|
||||
]), $msg);
|
||||
|
||||
$this->assertIsArray($normalizer->normalize($person, 'docgen', [
|
||||
'docgen:expects' => Person::class,
|
||||
'groups' => ['docgen:read'],
|
||||
]), $msg);
|
||||
}
|
||||
|
||||
private function buildNormalizer(
|
||||
?PersonRender $personRender = null,
|
||||
?RelationshipRepository $relationshipRepository = null,
|
||||
?TranslatorInterface $translator = null,
|
||||
?TranslatableStringHelper $translatableStringHelper = null,
|
||||
?NormalizerInterface $normalizer = null
|
||||
): PersonDocGenNormalizer {
|
||||
$personDocGenNormalizer = new PersonDocGenNormalizer(
|
||||
$personRender ?? self::$container->get(PersonRender::class),
|
||||
$relationshipRepository ?? self::$container->get(RelationshipRepository::class),
|
||||
$translator ?? self::$container->get(TranslatorInterface::class),
|
||||
$translatableStringHelper ?? self::$container->get(TranslatableStringHelperInterface::class)
|
||||
);
|
||||
|
||||
if (null === $normalizer) {
|
||||
$normalizer = $this->prophesize(NormalizerInterface::class);
|
||||
$normalizer->normalize(Argument::any(), 'docgen', Argument::any())
|
||||
->willReturn(['fake' => true]);
|
||||
}
|
||||
|
||||
$personDocGenNormalizer->setNormalizer($normalizer->reveal());
|
||||
|
||||
return $personDocGenNormalizer;
|
||||
}
|
||||
|
||||
private function buildPersonNormalizer(
|
||||
?PersonRender $personRender = null,
|
||||
?RelationshipRepository $relationshipRepository = null,
|
||||
|
@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||
use Chill\PersonBundle\Serializer\Normalizer\RelationshipDocGenNormalizer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use function is_object;
|
||||
|
||||
@ -27,6 +28,8 @@ use function is_object;
|
||||
*/
|
||||
final class RelationshipDocGenNormalizerTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testNormalizeRelationshipNull()
|
||||
{
|
||||
$relationship = null;
|
||||
|
@ -76,7 +76,7 @@ final class TimelineAccompanyingPeriodTest extends WebTestCase
|
||||
$crawler->filter('.timeline div')->count(),
|
||||
'the timeline page contains multiple div inside a .timeline element'
|
||||
);
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'est ouvert',
|
||||
$crawler->filter('.timeline')->text(),
|
||||
"the text 'est ouvert' is present"
|
||||
|
@ -17,6 +17,7 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter;
|
||||
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenterValidator;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
@ -26,6 +27,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
*/
|
||||
final class PersonHasCenterValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testValidateRequired()
|
||||
{
|
||||
$constraint = $this->getConstraint();
|
||||
|
@ -37,7 +37,7 @@ final class PersonValidationTest extends KernelTestCase
|
||||
{
|
||||
$person = (new Person())
|
||||
->setBirthdate(new Datetime('+2 months'));
|
||||
$errors = $this->validator->validate($person, null, ['creation']);
|
||||
$errors = $this->validator->validate($person, null);
|
||||
|
||||
foreach ($errors->getIterator() as $error) {
|
||||
if (Birthdate::BIRTHDATE_INVALID_CODE === $error->getCode()) {
|
||||
@ -59,7 +59,7 @@ final class PersonValidationTest extends KernelTestCase
|
||||
{
|
||||
$person = (new Person())
|
||||
->setFirstname(str_repeat('a', 500));
|
||||
$errors = $this->validator->validate($person, null, ['creation']);
|
||||
$errors = $this->validator->validate($person, null);
|
||||
|
||||
foreach ($errors->getIterator() as $error) {
|
||||
if (Length::TOO_LONG_ERROR === $error->getCode()) {
|
||||
|
@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Add location to AccompanyingPeriod.
|
||||
*/
|
||||
final class Version20211223150721 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86830F20868');
|
||||
$this->addSql('DROP INDEX IDX_E260A86830F20868');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP administrativeLocation_id');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add location to AccompanyingPeriod';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD administrativeLocation_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86830F20868 FOREIGN KEY (administrativeLocation_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_E260A86830F20868 ON chill_person_accompanying_period (administrativeLocation_id)');
|
||||
}
|
||||
}
|
@ -216,6 +216,9 @@ Add to household now: Ajouter à un ménage
|
||||
Any resource for this accompanying course: Aucun interlocuteur privilégié pour ce parcours
|
||||
course.draft: Brouillon
|
||||
Origin: Origine de la demande
|
||||
Delete accompanying period: Supprimer la période d'accompagnement
|
||||
Are you sure you want to remove the accompanying period "%id%" ?: Êtes-vous sûr de vouloir supprimer la période d'accompagnement %id% ?
|
||||
The accompanying course has been successfully removed.: La période d'accompagnement a été supprimée.
|
||||
|
||||
# pickAPersonType
|
||||
Pick a person: Choisir une personne
|
||||
@ -408,6 +411,8 @@ Choose a person to locate by: Localiser auprès d'un usager concerné
|
||||
Associate at least one member with an household, and set an address to this household: Associez au moins un membre du parcours à un ménage, et indiquez une adresse à ce ménage.
|
||||
Locate by: Localiser auprès de
|
||||
fix it: Compléter
|
||||
accompanying_course:
|
||||
administrative_location: Localisation administrative
|
||||
|
||||
# Accompanying Course comments
|
||||
Accompanying Course Comment: Commentaire
|
||||
|
@ -68,7 +68,7 @@ final class SingleTaskControllerTest extends WebTestCase
|
||||
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
$title,
|
||||
$crawler->text(),
|
||||
'Assert that newly created task title is shown in list page'
|
||||
|
@ -24,6 +24,7 @@ use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Context;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
@ -64,7 +65,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @var string
|
||||
* @ORM\Column(name="acronym", type="string", length=64, nullable=true)
|
||||
* @Assert\Length(min="2")
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?string $acronym = '';
|
||||
|
||||
@ -79,7 +80,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?Address $address = null;
|
||||
|
||||
@ -98,7 +100,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\JoinTable(name="chill_3party.thirdparty_category",
|
||||
* joinColumns={@ORM\JoinColumn(name="thirdparty_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")})
|
||||
* @Groups({"docgen:read"})
|
||||
* @Groups({"docgen:read", "docgen:read:3party:parent"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
||||
*/
|
||||
private Collection $categories;
|
||||
|
||||
@ -123,7 +126,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @var Civility
|
||||
* @ORM\ManyToOne(targetEntity=Civility::class)
|
||||
* ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
|
||||
* @Groups({"docgen:read", "read"})
|
||||
* @Groups({"docgen:read", "read", "docgen:read:3party:parent"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?Civility $civility = null;
|
||||
|
||||
@ -135,7 +139,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="contact_data_anonymous", type="boolean", options={"default": false})
|
||||
* @Groups({"read", "docgen:read"})
|
||||
* @Groups({"read", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private bool $contactDataAnonymous = false;
|
||||
|
||||
@ -153,7 +157,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* @ORM\Column(name="email", type="string", length=255, nullable=true)
|
||||
* @Assert\Email(checkMX=false)
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?string $email = null;
|
||||
|
||||
@ -162,7 +166,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
@ -176,7 +180,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @var string
|
||||
* @ORM\Column(name="name", type="string", length=255)
|
||||
* @Assert\Length(min="2")
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?string $name = '';
|
||||
|
||||
@ -186,7 +190,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @var string
|
||||
* @ORM\Column(name="name_company", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(min="3")
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?string $nameCompany = '';
|
||||
|
||||
@ -196,6 +200,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
* @Groups({"read", "docgen:read"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read:3party:parent"}, groups={"docgen:read"})
|
||||
*/
|
||||
private ?ThirdParty $parent = null;
|
||||
|
||||
@ -205,7 +210,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @var ThirdPartyProfession
|
||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
|
||||
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
|
||||
* @Groups({"docgen:read"})
|
||||
* @Groups({"docgen:read", "docgen:read:3party:parent"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?ThirdPartyProfession $profession = null;
|
||||
|
||||
@ -215,7 +221,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* message="Invalid phone number: it should begin with the international prefix starting with ""+"", hold only digits and be smaller than 20 characters. Ex: +33123456789"
|
||||
* )
|
||||
* @PhonenumberConstraint(type="any")
|
||||
* @Groups({"read", "write", "dogen:read"})
|
||||
* @Groups({"read", "write", "dogen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?string $telephone = null;
|
||||
|
||||
@ -498,7 +504,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read", "docgen:read"})
|
||||
* @Groups({"read", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
public function isChild(): bool
|
||||
{
|
||||
|
@ -0,0 +1,101 @@
|
||||
<?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\ThirdPartyBundle\Test\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ThirdPartyDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testAvoidRecursionWithNullParent()
|
||||
{
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']))
|
||||
->setParent(new ThirdParty());
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('parent', $actual);
|
||||
$this->assertIsArray($actual['parent']);
|
||||
$this->assertArrayNotHasKey('parent', $actual['parent']);
|
||||
// check that other keys exists for parent
|
||||
$this->assertArrayHasKey('acronym', $actual['parent']);
|
||||
$this->assertEquals('', $actual['parent']['acronym']);
|
||||
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']));
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('parent', $actual);
|
||||
$this->assertIsArray($actual['parent']);
|
||||
$this->assertArrayNotHasKey('parent', $actual['parent']);
|
||||
// check that other keys exists for parent
|
||||
$this->assertArrayHasKey('acronym', $actual['parent']);
|
||||
$this->assertEquals('', $actual['parent']['acronym']);
|
||||
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', ['groups' => ['docgen:read'], 'docgen:expects' => ThirdParty::class]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->assertArrayHasKey('parent', $actual);
|
||||
$this->assertIsArray($actual['parent']);
|
||||
$this->assertArrayNotHasKey('parent', $actual['parent']);
|
||||
// check that other keys exists for parent
|
||||
$this->assertArrayHasKey('acronym', $actual['parent']);
|
||||
$this->assertEquals('', $actual['parent']['acronym']);
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
{
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']));
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?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\ThirdPartyBundle\Test\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ThirdpartyDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
{
|
||||
$thirdparty = new ThirdParty();
|
||||
$thirdparty
|
||||
->setAcronym('ABCD')
|
||||
->setName('test')
|
||||
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
|
||||
->setEmail('info@cl.coop')
|
||||
->addTypesAndCategories('kind')
|
||||
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']));
|
||||
|
||||
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user