mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge remote-tracking branch 'origin/master' into features/household-members-list
This commit is contained in:
@@ -72,7 +72,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
$loader->load('services/command.yaml');
|
||||
$loader->load('services/actions.yaml');
|
||||
$loader->load('services/form.yaml');
|
||||
$loader->load('services/templating.yaml');
|
||||
$loader->load('services/alt_names.yaml');
|
||||
$loader->load('services/household.yaml');
|
||||
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
|
||||
|
@@ -53,36 +53,36 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* Mark an accompanying period as "occasional"
|
||||
*
|
||||
*
|
||||
* used in INTENSITY
|
||||
*/
|
||||
public const INTENSITY_OCCASIONAL = 'occasional';
|
||||
|
||||
|
||||
/**
|
||||
* Mark an accompanying period as "regular"
|
||||
*
|
||||
*
|
||||
* used in INTENSITY
|
||||
*/
|
||||
public const INTENSITY_REGULAR = 'regular';
|
||||
|
||||
|
||||
public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR];
|
||||
|
||||
|
||||
/**
|
||||
* Mark an accompanying period as "draft".
|
||||
*
|
||||
* This means that the accompanying period is not yet
|
||||
*
|
||||
* This means that the accompanying period is not yet
|
||||
* confirmed by the creator
|
||||
*/
|
||||
public const STEP_DRAFT = 'DRAFT';
|
||||
|
||||
|
||||
/**
|
||||
* Mark an accompanying period as "confirmed".
|
||||
*
|
||||
* This means that the accompanying period **is**
|
||||
*
|
||||
* This means that the accompanying period **is**
|
||||
* confirmed by the creator
|
||||
*/
|
||||
public const STEP_CONFIRMED = 'CONFIRMED';
|
||||
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
@@ -176,7 +176,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $step = self::STEP_DRAFT;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Origin::class)
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
@@ -274,7 +274,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
* )
|
||||
*/
|
||||
private User $updatedBy;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||
*/
|
||||
@@ -412,7 +412,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
if (NULL !== $this->initialComment) {
|
||||
$this->removeComment($this->initialComment);
|
||||
}
|
||||
}
|
||||
if ($comment instanceof Comment) {
|
||||
$this->addComment($comment);
|
||||
}
|
||||
@@ -471,7 +471,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the accompanying period contains a person.
|
||||
* Return true if the accompanying period contains a person.
|
||||
*
|
||||
* **Note**: this participation can be opened or not.
|
||||
*/
|
||||
@@ -518,7 +518,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
return $participation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove Person
|
||||
@@ -822,6 +822,44 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
$this->socialIssues->removeElement($socialIssue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialIssues[] All social issues and their descendants
|
||||
*/
|
||||
public function getRecursiveSocialIssues(): Collection
|
||||
{
|
||||
$recursiveSocialIssues = new ArrayCollection();
|
||||
|
||||
foreach( $this->socialIssues as $socialIssue) {
|
||||
foreach ($socialIssue->getDescendantsWithThis() as $descendant) {
|
||||
if(! $recursiveSocialIssues->contains($descendant)) {
|
||||
$recursiveSocialIssues->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $recursiveSocialIssues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of all
|
||||
* the descendants of the entity
|
||||
*/
|
||||
public function getRecursiveSocialActions(): Collection
|
||||
{
|
||||
$recursiveSocialActions = new ArrayCollection();
|
||||
|
||||
foreach( $this->socialIssues as $socialIssue) {
|
||||
foreach ($socialIssue->getRecursiveSocialActions() as $descendant) {
|
||||
if(! $recursiveSocialActions->contains($descendant)) {
|
||||
$recursiveSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $recursiveSocialActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all persons which are participating to this course
|
||||
*
|
||||
|
@@ -102,6 +102,11 @@ class SocialAction
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return $this->getParent() instanceof self;
|
||||
}
|
||||
|
||||
public function setParent(?self $parent): self
|
||||
{
|
||||
$this->parent = $parent;
|
||||
@@ -139,6 +144,41 @@ class SocialAction
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[] All the descendants (children, children of children, ...)
|
||||
*/
|
||||
public function getDescendants(): Collection
|
||||
{
|
||||
$descendants = new ArrayCollection();
|
||||
|
||||
foreach ($this->getChildren() as $child) {
|
||||
if(! $descendants->contains($child)) {
|
||||
$descendants->add($child);
|
||||
foreach($child->getDescendants() as $descendantsOfChild) {
|
||||
if(! $descendants->contains($descendantsOfChild)) {
|
||||
$descendants->add($descendantsOfChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $descendants;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[] All the descendants with the current entity (this)
|
||||
*/
|
||||
public function getDescendantsWithThis(): Collection
|
||||
{
|
||||
$descendants = $this->getDescendants();
|
||||
|
||||
if(! $descendants->contains($this)) {
|
||||
$descendants->add($this);
|
||||
}
|
||||
|
||||
return $descendants;
|
||||
}
|
||||
|
||||
public function getDefaultNotificationDelay(): ?\DateInterval
|
||||
{
|
||||
return $this->defaultNotificationDelay;
|
||||
|
@@ -107,6 +107,42 @@ class SocialIssue
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[] All the descendants (children, children of children, ...)
|
||||
*/
|
||||
public function getDescendants(): Collection
|
||||
{
|
||||
$descendants = new ArrayCollection();
|
||||
|
||||
foreach ($this->getChildren() as $child) {
|
||||
if(! $descendants->contains($child)) {
|
||||
$descendants->add($child);
|
||||
foreach($child->getDescendants() as $descendantsOfChild) {
|
||||
if(! $descendants->contains($descendantsOfChild)) {
|
||||
$descendants->add($descendantsOfChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $descendants;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[] All the descendants with the current entity (this)
|
||||
*/
|
||||
public function getDescendantsWithThis(): Collection
|
||||
{
|
||||
$descendants = $this->getDescendants();
|
||||
|
||||
if(! $descendants->contains($this)) {
|
||||
$descendants->add($this);
|
||||
}
|
||||
|
||||
return $descendants;
|
||||
}
|
||||
|
||||
|
||||
public function getDesactivationDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
@@ -160,4 +196,41 @@ class SocialIssue
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of the entity
|
||||
*/
|
||||
public function getDescendantsSocialActions(): Collection
|
||||
{
|
||||
$descendantsSocialActions = new ArrayCollection();
|
||||
|
||||
foreach ($this->getSocialActions() as $socialAction) {
|
||||
foreach ($socialAction->getDescendantsWithThis() as $descendant) {
|
||||
if(! $descendantsSocialActions->contains($descendant)) {
|
||||
$descendantsSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $descendantsSocialActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of all
|
||||
* the descendants of the entity
|
||||
*/
|
||||
public function getRecursiveSocialActions(): Collection
|
||||
{
|
||||
$recursiveSocialActions = new ArrayCollection();
|
||||
|
||||
foreach ($this->getDescendantsWithThis() as $socialIssue) {
|
||||
foreach ($socialIssue->getDescendantsSocialActions() as $descendant) {
|
||||
if(! $recursiveSocialActions->contains($descendant)) {
|
||||
$recursiveSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $recursiveSocialActions;
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ use Chill\PersonBundle\Form\Type\PersonPhoneType;
|
||||
use Chill\PersonBundle\Entity\PersonPhone;
|
||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
@@ -79,7 +79,9 @@ class PersonType extends AbstractType
|
||||
$builder
|
||||
->add('firstName')
|
||||
->add('lastName')
|
||||
->add('birthdate', DateType::class, array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
|
||||
->add('birthdate', ChillDateType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
->add('gender', GenderType::class, array(
|
||||
'required' => true
|
||||
));
|
||||
|
@@ -2,6 +2,15 @@
|
||||
div.list-with-period,
|
||||
div.list-household-members,
|
||||
div.list-household-members--summary {
|
||||
|
||||
.chill-entity__person {
|
||||
.chill-entity__person__first-name,
|
||||
.chill-entity__person__last-name {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
div.person {
|
||||
ul.record_actions {
|
||||
li {
|
||||
@@ -44,14 +53,6 @@ div.list-household-members--summary {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chill-entity__person {
|
||||
.chill-entity__person__first-name,
|
||||
.chill-entity__person__last-name {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<a @click="toggleIntensity" class="flag-toggle">
|
||||
{{ $t('course.occasional') }}
|
||||
<span :class="{ 'on': !isRegular }">{{ $t('course.occasional') }}</span>
|
||||
<i class="fa" :class="{ 'fa-toggle-on': isRegular, 'fa-toggle-on fa-flip-horizontal': !isRegular }"></i>
|
||||
{{ $t('course.regular') }}
|
||||
<span :class="{ 'on': isRegular }">{{ $t('course.regular') }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -76,6 +76,9 @@ export default {
|
||||
i {
|
||||
margin: auto 0.4em;
|
||||
}
|
||||
span.on {
|
||||
font-weight: bolder;
|
||||
}
|
||||
}
|
||||
button.badge {
|
||||
margin-left: 0.8em;
|
||||
|
@@ -56,7 +56,6 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<button class="sc-button bt-remove"
|
||||
@@ -66,7 +65,6 @@
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div v-else>
|
||||
<label>{{ $t('requestor.counter') }}</label>
|
||||
@@ -147,7 +145,6 @@ div.flex-table {
|
||||
}
|
||||
div.item-bloc {
|
||||
background-color: white !important;
|
||||
border: 1px solid #000;
|
||||
padding: 1em;
|
||||
margin-top: 1em;
|
||||
.content-bloc {
|
||||
|
@@ -13,7 +13,7 @@
|
||||
track-by="id"
|
||||
label="text"
|
||||
:multiple="true"
|
||||
:searchable="false"
|
||||
:searchable="true"
|
||||
:placeholder="$t('social_issue.label')"
|
||||
@update:model-value="updateSocialIssues"
|
||||
:model-value="value"
|
||||
@@ -75,6 +75,6 @@ export default {
|
||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||
<style lang="scss">
|
||||
span.multiselect__tag {
|
||||
background: #e2793d;
|
||||
background: var(--chill-orange);
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<button class="sc-button bt-create" @click="openModal">
|
||||
<li class="add-persons">
|
||||
<a class="sc-button bt-create" @click="openModal">
|
||||
{{ $t(buttonTitle) }}
|
||||
</button>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -220,6 +220,11 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
li.add-persons {
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
div.body-head {
|
||||
overflow-y: unset;
|
||||
div.modal-body:first-child {
|
||||
|
@@ -15,5 +15,5 @@
|
||||
window.accompanyingCourseId = {{ accompanyingCourse.id|e('js') }};
|
||||
window.vueRootComponent = 'app';
|
||||
</script>
|
||||
{{ encore_entry_script_tags('accompanying_course') }}
|
||||
{{ encore_entry_script_tags('vue_accourse') }}
|
||||
{% endblock %}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('accompanying_course') }}
|
||||
{{ encore_entry_link_tags('vue_accourse') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
@@ -24,5 +24,5 @@
|
||||
window.accompanyingCourseId = {{ accompanyingCourse.id|e('js') }};
|
||||
window.vueRootComponent = 'banner';
|
||||
</script>
|
||||
{{ encore_entry_script_tags('accompanying_course') }}
|
||||
{{ encore_entry_script_tags('vue_accourse') }}
|
||||
{% endblock %}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<span class="chill-entity chill-entity__person">
|
||||
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
|
||||
{%- set showLink = true -%}<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">{%- endif -%}
|
||||
<span class="chill-entity__person__first-name">{{ person.firstName }}</span>
|
||||
<span class="chill-entity__person__last-name">{{ person.lastName }}</span>
|
||||
<span class="chill_denomination">{{ person.firstName }}</span>
|
||||
<span class="chill_denomination">{{ person.lastName }}</span>
|
||||
{%- if addAltNames -%}
|
||||
{%- for n in person.altNames -%}
|
||||
{%- if loop.first -%}({% else %} {%- endif -%}
|
||||
|
@@ -0,0 +1,13 @@
|
||||
{% set reversed_parents = parents|reverse %}
|
||||
<span class="chill-entity chill-entity__social-action">
|
||||
<span class="badge badge-primary">
|
||||
{%- for p in reversed_parents %}
|
||||
<span class="chill-entity__social-action__parent--{{ loop.revindex0 }}">
|
||||
{{ p.title|localize_translatable_string }}{{ options['default.separator'] }}
|
||||
</span>
|
||||
{%- endfor -%}
|
||||
<span class="chill-entity__social-action__child">
|
||||
{{ socialAction.title|localize_translatable_string }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
class SocialActionRender implements ChillEntityRenderInterface
|
||||
{
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
private EngineInterface $engine;
|
||||
|
||||
public const SEPARATOR_KEY = 'default.separator';
|
||||
|
||||
public const DEFAULT_ARGS = [
|
||||
self::SEPARATOR_KEY => ' > ',
|
||||
];
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->engine = $engine;
|
||||
}
|
||||
|
||||
public function supports($entity, array $options): bool
|
||||
{
|
||||
return $entity instanceof SocialAction;
|
||||
}
|
||||
|
||||
public function renderString($socialAction, array $options): string
|
||||
{
|
||||
/** @var $socialAction SocialAction */
|
||||
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
||||
|
||||
$str = $this->translatableStringHelper->localize($socialAction->getTitle());
|
||||
|
||||
while ($socialAction->hasParent()) {
|
||||
$socialAction = $socialAction->getParent();
|
||||
$str .= $options[self::SEPARATOR_KEY].$this->translatableStringHelper->localize(
|
||||
$socialAction->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
protected function buildParents($socialAction): array
|
||||
{
|
||||
$parents = [];
|
||||
while ($socialAction->hasParent()) {
|
||||
$socialAction = $parents[] = $socialAction->getParent();
|
||||
}
|
||||
|
||||
return $parents;
|
||||
}
|
||||
|
||||
public function renderBox($socialAction, array $options): string
|
||||
{
|
||||
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
||||
// give some help to twig: an array of parents
|
||||
$parents = $this->buildParents($socialAction);
|
||||
|
||||
return $this->engine->render('@ChillPerson/Entity/social_action.html.twig', [
|
||||
'socialAction' => $socialAction,
|
||||
'parents' => $parents,
|
||||
'options' => $options
|
||||
]);
|
||||
}
|
||||
}
|
@@ -5,9 +5,10 @@ namespace Chill\PersonBundle\Templating\Entity;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
class SocialIssueRender implements ChillEntityRenderInterface
|
||||
final class SocialIssueRender implements ChillEntityRenderInterface
|
||||
{
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
private EngineInterface $engine;
|
||||
@@ -28,11 +29,14 @@ class SocialIssueRender implements ChillEntityRenderInterface
|
||||
{
|
||||
return $entity instanceof SocialIssue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SocialIssue $socialIssue
|
||||
*/
|
||||
public function renderString($socialIssue, array $options): string
|
||||
{
|
||||
/** @var $socialIssue SocialIssue */
|
||||
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
||||
$options = array_merge(self::DEFAULT_ARGS, $options);
|
||||
|
||||
$str = $this->translatableStringHelper->localize($socialIssue->getTitle());
|
||||
|
||||
@@ -46,26 +50,36 @@ class SocialIssueRender implements ChillEntityRenderInterface
|
||||
return $str;
|
||||
}
|
||||
|
||||
protected function buildParents($socialIssue): array
|
||||
protected function buildParents(SocialIssue $socialIssue): array
|
||||
{
|
||||
$parents = [];
|
||||
|
||||
while ($socialIssue->hasParent()) {
|
||||
$socialIssue = $parents[] = $socialIssue->getParent();
|
||||
}
|
||||
|
||||
return $parents;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SocialIssue $socialIssue
|
||||
*/
|
||||
public function renderBox($socialIssue, array $options): string
|
||||
{
|
||||
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
||||
$options = array_merge(self::DEFAULT_ARGS, $options);
|
||||
// give some help to twig: an array of parents
|
||||
$parents = $this->buildParents($socialIssue);
|
||||
|
||||
return $this->engine->render('@ChillPerson/Entity/social_issue.html.twig', [
|
||||
'socialIssue' => $socialIssue,
|
||||
'parents' => $parents,
|
||||
'options' => $options
|
||||
]);
|
||||
return $this
|
||||
->engine
|
||||
->render(
|
||||
'@ChillPerson/Entity/social_issue.html.twig',
|
||||
[
|
||||
'socialIssue' => $socialIssue,
|
||||
'parents' => $parents,
|
||||
'options' => $options
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -3,17 +3,17 @@
|
||||
/*
|
||||
* Chill is a suite of a modules, Chill is a software for social workers
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -27,7 +27,7 @@ use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* Test the edition of persons
|
||||
*
|
||||
*
|
||||
* As I am logged in as "center a_social"
|
||||
*
|
||||
*/
|
||||
@@ -37,66 +37,66 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
|
||||
/** @var \Doctrine\ORM\EntityManagerInterface The entity manager */
|
||||
private $em;
|
||||
|
||||
|
||||
/** @var Person The person on which the test is executed */
|
||||
private $person;
|
||||
|
||||
|
||||
/** @var string The url using for editing the person's information */
|
||||
private $editUrl;
|
||||
|
||||
/** @var string The url using for seeing the person's information */
|
||||
private $viewUrl;
|
||||
|
||||
|
||||
/**
|
||||
* Prepare client and create a random person
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
$this->em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
|
||||
$center = $this->em->getRepository('ChillMainBundle:Center')
|
||||
->findOneBy(array('name' => 'Center A'));
|
||||
|
||||
|
||||
$this->person = (new Person())
|
||||
->setLastName("My Beloved")
|
||||
->setFirstName("Jesus")
|
||||
->setCenter($center)
|
||||
->setGender(Person::MALE_GENDER);
|
||||
|
||||
|
||||
$this->em->persist($this->person);
|
||||
$this->em->flush();
|
||||
|
||||
|
||||
$this->editUrl = '/fr/person/'.$this->person->getId().'/general/edit';
|
||||
$this->viewUrl = '/fr/person/'.$this->person->getId().'/general';
|
||||
|
||||
|
||||
$this->client = $this->getClientAuthenticated();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reload the person from the db
|
||||
*/
|
||||
protected function refreshPerson()
|
||||
protected function refreshPerson()
|
||||
{
|
||||
$this->person = $this->em->getRepository('ChillPersonBundle:Person')
|
||||
->find($this->person->getId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the edit page are accessible
|
||||
*/
|
||||
public function testEditPageIsSuccessful()
|
||||
{
|
||||
$this->client->request('GET', $this->editUrl);
|
||||
$this->assertTrue($this->client->getResponse()->isSuccessful(),
|
||||
$this->assertTrue($this->client->getResponse()->isSuccessful(),
|
||||
"The person edit form is accessible");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the configurable fields are present
|
||||
*
|
||||
*
|
||||
* @group configurable_fields
|
||||
*/
|
||||
public function testHiddenFielsArePresent()
|
||||
@@ -106,12 +106,12 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
$configurables = array('placeOfBirth', 'phonenumber', 'email',
|
||||
'countryOfBirth', 'nationality', 'spokenLanguages', 'maritalStatus');
|
||||
$form = $crawler->selectButton('Enregistrer')->form(); //;
|
||||
|
||||
|
||||
foreach($configurables as $key) {
|
||||
$this->assertTrue($form->has('chill_personbundle_person['.$key.']'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the edit page of a given person is not accessible for a user
|
||||
* of another center of the person
|
||||
@@ -122,12 +122,12 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
'PHP_AUTH_USER' => 'center b_social',
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
));
|
||||
|
||||
|
||||
$client->request('GET', $this->editUrl);
|
||||
$this->assertEquals(403, $client->getResponse()->getStatusCode(),
|
||||
"The edit page of a person of a center A must not be accessible for user of center B");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the edit page of a given person are not accessible for an
|
||||
* administrative user
|
||||
@@ -138,19 +138,19 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
'PHP_AUTH_USER' => 'center a_administrative',
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
));
|
||||
|
||||
|
||||
$client->request('GET', $this->editUrl);
|
||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the edition of a field
|
||||
*
|
||||
*
|
||||
* Given I fill the field with $value
|
||||
* And I submit the form
|
||||
* Then I am redirected to the 'general' page
|
||||
* And the person is updated in the db
|
||||
*
|
||||
*
|
||||
* @dataProvider validTextFieldsProvider
|
||||
* @param string $field
|
||||
* @param string $value
|
||||
@@ -159,7 +159,7 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
public function testEditTextField($field, $value, \Closure $callback)
|
||||
{
|
||||
$crawler = $this->client->request('GET', $this->editUrl);
|
||||
|
||||
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
//transform countries into value if needed
|
||||
@@ -177,13 +177,13 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
default:
|
||||
$transformedValue = $value;
|
||||
}
|
||||
|
||||
|
||||
$form->get('chill_personbundle_person['.$field. ']')
|
||||
->setValue($transformedValue);
|
||||
|
||||
|
||||
$this->client->submit($form);
|
||||
$this->refreshPerson();
|
||||
|
||||
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect($this->viewUrl),
|
||||
'the page is redirected to general view');
|
||||
$this->assertEquals($value, $callback($this->person),
|
||||
@@ -200,20 +200,20 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
$this->assertGreaterThan(0, $crawler->filter('html:contains("'.$value.'")')->count());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testEditLanguages()
|
||||
{
|
||||
$crawler = $this->client->request('GET', $this->editUrl);
|
||||
$selectedLanguages = array('en', 'an', 'bbj');
|
||||
|
||||
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
$form->get('chill_personbundle_person[spokenLanguages]')
|
||||
->setValue($selectedLanguages);
|
||||
|
||||
|
||||
$this->client->submit($form);
|
||||
$this->refreshPerson();
|
||||
|
||||
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect($this->viewUrl),
|
||||
'the page is redirected to /general view');
|
||||
//retrieve languages codes present in person
|
||||
@@ -223,10 +223,10 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
$this->assertEquals(asort($selectedLanguages), asort($languagesCodesPresents),
|
||||
'the person speaks the expected languages');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test tbe detection of invalid data during the update procedure
|
||||
* Test tbe detection of invalid data during the update procedure
|
||||
*
|
||||
* @dataProvider providesInvalidFieldsValues
|
||||
* @param string $field
|
||||
@@ -235,33 +235,33 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
public function testInvalidFields($field, $value)
|
||||
{
|
||||
$crawler = $this->client->request('GET', $this->editUrl);
|
||||
|
||||
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
$form->get('chill_personbundle_person['.$field.']')
|
||||
->setValue($value);
|
||||
|
||||
|
||||
$crawler = $this->client->submit($form);
|
||||
|
||||
|
||||
$this->assertFalse($this->client->getResponse()->isRedirect(),
|
||||
'the page is not redirected to /general');
|
||||
$this->assertGreaterThan(0, $crawler->filter('.error')->count(),
|
||||
'a element .error is shown');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* provide valid values to test, with field name and
|
||||
* provide valid values to test, with field name and
|
||||
* a function to find the value back from person entity
|
||||
*
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function validTextFieldsProvider()
|
||||
{
|
||||
{
|
||||
return array(
|
||||
['firstName', 'random Value', function(Person $person) { return $person->getFirstName(); } ],
|
||||
['lastName' , 'random Value', function(Person $person) { return $person->getLastName(); } ],
|
||||
['placeOfBirth', 'none place', function(Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '15-12-1980', function(Person $person) { return $person->getBirthdate()->format('d-m-Y'); }],
|
||||
['birthdate', '1980-12-15', function(Person $person) { return $person->getBirthdate()->format('Y-m-d'); }],
|
||||
['phonenumber', '+32123456789', function(Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function(Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', 'BE', function(Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }],
|
||||
@@ -275,7 +275,7 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
['gender', Person::FEMALE_GENDER, function(Person $person) { return $person->getGender(); }],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function providesInvalidFieldsValues()
|
||||
{
|
||||
return array(
|
||||
@@ -286,18 +286,18 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
['birthdate', 'false date']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->refreshPerson();
|
||||
$this->em->remove($this->person);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
|
||||
private function getVeryLongText()
|
||||
{
|
||||
return <<<EOT
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse molestie at enim id auctor. Vivamus malesuada elit ipsum, ac mollis ex facilisis sit amet. Phasellus accumsan, quam ut aliquet accumsan, augue ligula consequat erat, condimentum iaculis orci magna egestas eros. In vel blandit sapien. Duis ut dui vitae tortor iaculis malesuada vitae vitae lorem. Morbi efficitur dolor orci, a rhoncus urna blandit quis. Aenean at placerat dui, ut tincidunt nulla. In ultricies tempus ligula ac rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce urna nibh, placerat vel auctor sed, maximus quis magna. Vivamus quam ante, consectetur vel feugiat quis, aliquet id ante. Integer gravida erat dignissim ante commodo mollis. Donec imperdiet mauris elit, nec blandit dolor feugiat ut. Proin iaculis enim ut tortor pretium commodo. Etiam aliquet hendrerit dolor sed fringilla. Vestibulum facilisis nibh tincidunt dui egestas, vitae congue mi imperdiet. Duis vulputate ultricies lectus id cursus. Fusce bibendum sem dignissim, bibendum purus quis, mollis ex. Cras ac est justo. Duis congue mattis ipsum, vitae sagittis justo dictum sit amet. Duis aliquam pharetra sem, non laoreet ante laoreet ac. Mauris ornare mi tempus rutrum consequat.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse molestie at enim id auctor. Vivamus malesuada elit ipsum, ac mollis ex facilisis sit amet. Phasellus accumsan, quam ut aliquet accumsan, augue ligula consequat erat, condimentum iaculis orci magna egestas eros. In vel blandit sapien. Duis ut dui vitae tortor iaculis malesuada vitae vitae lorem. Morbi efficitur dolor orci, a rhoncus urna blandit quis. Aenean at placerat dui, ut tincidunt nulla. In ultricies tempus ligula ac rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce urna nibh, placerat vel auctor sed, maximus quis magna. Vivamus quam ante, consectetur vel feugiat quis, aliquet id ante. Integer gravida erat dignissim ante commodo mollis. Donec imperdiet mauris elit, nec blandit dolor feugiat ut. Proin iaculis enim ut tortor pretium commodo. Etiam aliquet hendrerit dolor sed fringilla. Vestibulum facilisis nibh tincidunt dui egestas, vitae congue mi imperdiet. Duis vulputate ultricies lectus id cursus. Fusce bibendum sem dignissim, bibendum purus quis, mollis ex. Cras ac est justo. Duis congue mattis ipsum, vitae sagittis justo dictum sit amet. Duis aliquam pharetra sem, non laoreet ante laoreet ac. Mauris ornare mi tempus rutrum consequat.
|
||||
EOT;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Validator\Constraints\Household;
|
||||
|
||||
class MaxHolderValidator
|
||||
{
|
||||
|
||||
}
|
@@ -8,5 +8,5 @@ module.exports = function(encore, entries)
|
||||
ChillPersonAssets: __dirname + '/Resources/public'
|
||||
});
|
||||
|
||||
encore.addEntry('accompanying_course', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
||||
encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
parameters:
|
||||
# cl_chill_person.example.class: Chill\PersonBundle\Example
|
||||
|
||||
services:
|
||||
services:
|
||||
_defaults:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
@@ -67,3 +67,10 @@ services:
|
||||
autowire: true
|
||||
resource: '../Controller/'
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
Chill\PersonBundle\Templating\Entity\:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
resource: '../Templating/Entity'
|
||||
tags:
|
||||
- 'chill.render_entity'
|
||||
|
@@ -1,25 +0,0 @@
|
||||
services:
|
||||
Chill\PersonBundle\Templating\Entity\:
|
||||
resource: '../../Templating/Entity'
|
||||
tags:
|
||||
- 'chill.render_entity'
|
||||
|
||||
Chill\PersonBundle\Templating\Entity\PersonRender:
|
||||
arguments:
|
||||
$configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
||||
$engine: '@Symfony\Component\Templating\EngineInterface'
|
||||
tags:
|
||||
- 'chill.render_entity'
|
||||
|
||||
Chill\PersonBundle\Templating\Entity\ClosingMotiveRender:
|
||||
arguments:
|
||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
||||
tags:
|
||||
- 'chill.render_entity'
|
||||
|
||||
Chill\PersonBundle\Templating\Entity\SocialIssueRender:
|
||||
arguments:
|
||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
||||
$engine: '@Symfony\Component\Templating\EngineInterface'
|
||||
tags:
|
||||
- 'chill.render_entity'
|
@@ -172,6 +172,7 @@ This accompanying course is still a draft: Ce parcours est à l'état brouillon
|
||||
Associated peoples: Usagers concernés
|
||||
Resources: Interlocuteurs privilégiés
|
||||
Social actions: Actions d'accompagnement
|
||||
Social issues: Problématiques sociales
|
||||
Last events on accompanying course: Dernières actions de suivi
|
||||
Edit & activate accompanying course: Modifier et valider
|
||||
See accompanying periods: Voir les périodes d'accompagnement
|
||||
|
Reference in New Issue
Block a user