mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fixes person resources
This commit is contained in:
parent
6e554e74ab
commit
dc0fae7549
@ -45,8 +45,6 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
|||||||
{
|
{
|
||||||
$denormalized = json_decode($value, true);
|
$denormalized = json_decode($value, true);
|
||||||
|
|
||||||
dump($value);
|
|
||||||
|
|
||||||
if ($this->multiple) {
|
if ($this->multiple) {
|
||||||
if (null === $denormalized) {
|
if (null === $denormalized) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -7,7 +7,6 @@ const i18n = _createI18n(appMessages);
|
|||||||
|
|
||||||
let appsOnPage = new Map();
|
let appsOnPage = new Map();
|
||||||
|
|
||||||
|
|
||||||
function loadDynamicPicker(element) {
|
function loadDynamicPicker(element) {
|
||||||
|
|
||||||
let apps = element.querySelectorAll('[data-module="pick-dynamic"]');
|
let apps = element.querySelectorAll('[data-module="pick-dynamic"]');
|
||||||
@ -75,23 +74,23 @@ function loadDynamicPicker(element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// document.addEventListener('show-hide-show', function(e) {
|
document.addEventListener('show-hide-show', function(e) {
|
||||||
// console.log('creation event caught')
|
console.log('creation event caught')
|
||||||
// loadDynamicPicker(e.detail.container)
|
loadDynamicPicker(e.detail.container)
|
||||||
// })
|
})
|
||||||
|
|
||||||
// document.addEventListener('show-hide-hide', function(e) {
|
document.addEventListener('show-hide-hide', function(e) {
|
||||||
// console.log('hiding event caught')
|
console.log('hiding event caught')
|
||||||
// e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => {
|
e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => {
|
||||||
// let uniqId = el.dataset.uniqid;
|
let uniqId = el.dataset.uniqid;
|
||||||
// console.log(uniqId);
|
console.log(uniqId);
|
||||||
// if (appsOnPage.has(uniqId)) {
|
if (appsOnPage.has(uniqId)) {
|
||||||
// appsOnPage.get(uniqId).unmount();
|
appsOnPage.get(uniqId).unmount();
|
||||||
// console.log('App has been unmounted')
|
console.log('App has been unmounted')
|
||||||
// appsOnPage.delete(uniqId);
|
appsOnPage.delete(uniqId);
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function(e) {
|
document.addEventListener('DOMContentLoaded', function(e) {
|
||||||
console.log('loaded event', e)
|
console.log('loaded event', e)
|
||||||
|
@ -114,8 +114,6 @@ final class PersonResourceController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dump($resource);
|
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'ChillPersonBundle:PersonResource:edit.html.twig',
|
'ChillPersonBundle:PersonResource:edit.html.twig',
|
||||||
[
|
[
|
||||||
@ -139,7 +137,7 @@ final class PersonResourceController extends AbstractController
|
|||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($request->getMethod() === Request::METHOD_POST && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$this->denyAccessUnlessGranted(PersonVoter::CREATE, $personOwner);
|
$this->denyAccessUnlessGranted(PersonVoter::CREATE, $personOwner);
|
||||||
|
|
||||||
$personResource = new PersonResource();
|
$personResource = new PersonResource();
|
||||||
|
@ -55,7 +55,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\Column(type="text", nullable=true)
|
* @ORM\Column(type="text", nullable=true)
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $freeText;
|
private ?string $freeText = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
@ -204,6 +204,10 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
$this->setThirdParty(null);
|
$this->setThirdParty(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('' === $freeText) {
|
||||||
|
$this->freeText = null;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,9 +270,8 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
public function validate(ExecutionContextInterface $context, $payload)
|
public function validate(ExecutionContextInterface $context, $payload)
|
||||||
{
|
{
|
||||||
if (null === $this->person && null === $this->thirdParty && null === $this->freeText) {
|
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
|
||||||
$context->buildViolation('You must associate at least one entity')
|
$context->buildViolation('You must associate at least one entity')
|
||||||
->atPath('person')
|
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="col-md col-xxl">
|
<div class="col-md col-xxl">
|
||||||
<div id="collapseForm" class="collapse">
|
<div id="collapseForm" class="{% if not form.vars.submitted %}collapse{% endif %}">
|
||||||
<h3 style="margin-bottom: 2rem;">{{ 'Add a person resource'|trans }}</h3>
|
<h3 style="margin-bottom: 2rem;">{{ 'Add a person resource'|trans }}</h3>
|
||||||
{% include "@ChillPerson/PersonResource/form.html.twig" %}
|
{% include "@ChillPerson/PersonResource/form.html.twig" %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{{ form_start(form, {'attr' : {'id' : 'create-form'}}) }}
|
{{ form_start(form, {'attr' : {'id' : 'create-form'}}) }}
|
||||||
|
{{ form_errors(form) }}
|
||||||
{{ form_row(form.kind) }}
|
{{ form_row(form.kind) }}
|
||||||
|
|
||||||
<div id="linked-entity">
|
<div id="linked-entity">
|
||||||
<fieldset class="mb-3">
|
<fieldset class="mb-3">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -10,7 +9,7 @@
|
|||||||
<div id="entity-selector">
|
<div id="entity-selector">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
{% if resource is defined and resource.person is not null %}
|
{% if resource is defined and resource.person is not null %}
|
||||||
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" />
|
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" {% if form.vars.submitted and app.request.request.get('linked-entity', null) == 'person' %}checked{% endif %}/>
|
||||||
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_0">Usager</label>
|
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_0">Usager</label>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" />
|
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_0" name="linked-entity" class="form-check-input" value="person" />
|
||||||
@ -19,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
{% if resource is defined and resource.thirdparty is not null %}
|
{% if resource is defined and resource.thirdparty is not null %}
|
||||||
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" />
|
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" {% if form.vars.submitted and app.request.request.get('linked-entity', null) == 'thirdparty' %}checked{% endif %}/>
|
||||||
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_1">Tiers</label>
|
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_1">Tiers</label>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" />
|
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_1" name="linked-entity" class="form-check-input" value="thirdparty" />
|
||||||
@ -28,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
{% if resource is defined and resource.freeText is not null %}
|
{% if resource is defined and resource.freeText is not null %}
|
||||||
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" />
|
<input checked type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" {% if form.vars.submitted and app.request.request.get('linked-entity', null) == 'thirdparty' %}checked{% endif %}/>
|
||||||
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_2">Description libre</label>
|
<label class="form-check-label" for="chill_personbundle_person_resource_linkedEntity_2">Description libre</label>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" />
|
<input type="radio" id="chill_personbundle_person_resource_linkedEntity_2" name="linked-entity" class="form-check-input" value="freetext" />
|
||||||
|
@ -19,74 +19,66 @@
|
|||||||
<h1>{{ 'List of resources'|trans }}</h1>
|
<h1>{{ 'List of resources'|trans }}</h1>
|
||||||
|
|
||||||
{% if personResources|length > 0 %}
|
{% if personResources|length > 0 %}
|
||||||
{% for resource in personResources %}
|
<div class="flex-table">
|
||||||
<div class="flex-table">
|
{% for resource in personResources %}
|
||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
<div class="item-row">
|
<div class="item-row">
|
||||||
<div class="wrap-header">
|
<div class="item-col">
|
||||||
<div class="wh-row">
|
{% if resource.person is not null %}
|
||||||
<div class="wh-col">
|
<div class="denomination h3">
|
||||||
{% if resource.person is not null %}
|
<span class="name">{{ resource.person }}</span>
|
||||||
<div class="item-col">
|
<span class="badge rounded-pill bg-person">{{ 'person'|trans|capitalize }}</span>
|
||||||
<div class="denomination h3">
|
|
||||||
<span class="name">{{ resource.person }}</span>
|
|
||||||
<span class="badge rounded-pill bg-person">{{ 'person'|trans|capitalize }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% elseif resource.thirdparty is not null %}
|
|
||||||
<div class="item-col">
|
|
||||||
<div class="denomination h3">
|
|
||||||
<span class="name">{{ resource.thirdparty }}</span>
|
|
||||||
<span class="badge rounded-pill bg-thirdparty">
|
|
||||||
{{ 'thirdparty'|trans|capitalize }}
|
|
||||||
<i class="fa fa-fw fa-user-md"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="item-col">
|
|
||||||
<div class="denomination h3">
|
|
||||||
<span>{{ resource.freetext }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="wh-col">
|
|
||||||
{% if resource.kind %}
|
|
||||||
<span>{{ resource.kind.title.fr|capitalize }}</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
{% elseif resource.thirdparty is not null %}
|
||||||
|
<div class="denomination h3">
|
||||||
|
<span class="name">{{ resource.thirdparty }}</span>
|
||||||
|
<span class="badge rounded-pill bg-thirdparty">
|
||||||
|
{{ 'thirdparty'|trans|capitalize }}
|
||||||
|
<i class="fa fa-fw fa-user-md"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="denomination h3">
|
||||||
|
<span>{{ resource.freetext }}</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="item-col">
|
||||||
|
{% if resource.kind %}
|
||||||
|
<span>{{ resource.kind.title.fr|capitalize }}</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if resource.comment.comment is not null %}
|
{% if resource.comment.comment is not empty %}
|
||||||
<div class="item-row separator">
|
<div class="item-row separator">
|
||||||
<section class="chill-entity entity-comment-embeddable">
|
<section class="chill-entity entity-comment-embeddable">
|
||||||
<div>{{ resource.comment|chill_entity_render_box }}<div>
|
<div>{{ resource.comment|chill_entity_render_box }}<div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="item-row separator">
|
{% if is_granted('CHILL_PERSON_UPDATE', resource.person) %}
|
||||||
<div class="item-col">
|
<div class="item-row separator">
|
||||||
<ul class="record_actions">
|
<div class="item-col">
|
||||||
<li>
|
<ul class="record_actions">
|
||||||
<a href="{{ chill_path_add_return_path('chill_person_resource_edit', {'resource_id': resource.id,
|
<li>
|
||||||
'person_id': person.id,}) }}"
|
<a href="{{ chill_path_add_return_path('chill_person_resource_edit', {'resource_id': resource.id,
|
||||||
class="btn btn-sm btn-edit"
|
'person_id': person.id,}) }}"
|
||||||
title="{{ 'Edit'|trans }}"></a>
|
class="btn btn-sm btn-edit"
|
||||||
</li>
|
title="{{ 'Edit'|trans }}"></a>
|
||||||
<li>
|
</li>
|
||||||
<a href="{{ chill_path_add_return_path('chill_person_resource_delete', {'person_id': person.id,
|
<li>
|
||||||
'resource_id': resource.id}) }}"
|
<a href="{{ chill_path_add_return_path('chill_person_resource_delete', {'person_id': person.id,
|
||||||
class="btn btn-sm btn-delete"
|
'resource_id': resource.id}) }}"
|
||||||
title="{{ 'Delete'|trans }}"></a>
|
class="btn btn-sm btn-delete"
|
||||||
</li>
|
title="{{ 'Delete'|trans }}"></a>
|
||||||
</ul>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endfor %}
|
||||||
{% endfor %}
|
</div>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="chill-no-data-statement">{{ 'There are no available resources'|trans }}</p>
|
<p class="chill-no-data-statement">{{ 'There are no available resources'|trans }}</p>
|
||||||
|
@ -76,8 +76,8 @@ class PersonDocGenNormalizer implements
|
|||||||
'type' => 'person',
|
'type' => 'person',
|
||||||
'isNull' => false,
|
'isNull' => false,
|
||||||
'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])),
|
'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])),
|
||||||
'firstname' => $person->getFirstName(),
|
'firstName' => $person->getFirstName(),
|
||||||
'lastname' => $person->getLastName(),
|
'lastName' => $person->getLastName(),
|
||||||
'altNames' => implode(
|
'altNames' => implode(
|
||||||
', ',
|
', ',
|
||||||
array_map(
|
array_map(
|
||||||
|
@ -50,3 +50,6 @@ household_membership:
|
|||||||
A course must contains at least one social issue: 'Un parcours doit être associé à au moins une problématique sociale'
|
A course must contains at least one social issue: 'Un parcours doit être associé à au moins une problématique sociale'
|
||||||
A course must be associated to at least one scope: 'Un parcours doit être associé à au moins un service'
|
A course must be associated to at least one scope: 'Un parcours doit être associé à au moins un service'
|
||||||
The social %name% issue cannot be deleted because it is associated with an activity or an action: 'La problématique sociale "%name%" ne peut pas être supprimée car elle est associée à une activité ou une action'
|
The social %name% issue cannot be deleted because it is associated with an activity or an action: 'La problématique sociale "%name%" ne peut pas être supprimée car elle est associée à une activité ou une action'
|
||||||
|
|
||||||
|
# resource
|
||||||
|
You must associate at least one entity: Associez un usager, un tiers ou indiquez une description libre
|
||||||
|
Loading…
x
Reference in New Issue
Block a user