mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
ajout métadonnées membres
This commit is contained in:
parent
41617295c1
commit
f827e50431
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Form\HouseholdType;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
@ -15,6 +17,16 @@ use Chill\PersonBundle\Entity\Household\Position;
|
|||||||
*/
|
*/
|
||||||
class HouseholdController extends AbstractController
|
class HouseholdController extends AbstractController
|
||||||
{
|
{
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
|
*/
|
||||||
|
public function __construct(TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{household_id}/summary",
|
* "/{household_id}/summary",
|
||||||
@ -108,4 +120,38 @@ class HouseholdController extends AbstractController
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(
|
||||||
|
* "/{household_id}/members/metadata/edit",
|
||||||
|
* name="chill_person_household_members_metadata_edit",
|
||||||
|
* methods={"GET", "POST"}
|
||||||
|
* )
|
||||||
|
* @ParamConverter("household", options={"id" = "household_id"})
|
||||||
|
*/
|
||||||
|
public function editHouseholdMetadata(Request $request, Household $household)
|
||||||
|
{
|
||||||
|
// TODO ACL
|
||||||
|
$form = $this->createForm(
|
||||||
|
HouseholdType::class,
|
||||||
|
$household
|
||||||
|
);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() and $form->isValid()) {
|
||||||
|
$this->getDoctrine()->getManager()->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->translator->trans('household.data_saved'));
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_person_household_members', [
|
||||||
|
'household_id' => $household->getId()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('@ChillPerson/Household/edit_member_metadata.html.twig', [
|
||||||
|
'household' => $household,
|
||||||
|
'form' => $form->createView()
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,21 @@ class Household
|
|||||||
*/
|
*/
|
||||||
private Collection $members;
|
private Collection $members;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="text", name="comment_members", options={"default": ""})
|
||||||
|
*/
|
||||||
|
private string $commentMembers = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
|
||||||
|
*/
|
||||||
|
private bool $waitingForBirth = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
|
||||||
|
*/
|
||||||
|
private ?\DateTimeImmutable $waitingForBirthDate = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->addresses = new ArrayCollection();
|
$this->addresses = new ArrayCollection();
|
||||||
@ -206,4 +221,40 @@ class Household
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCommentMembers(): ?string
|
||||||
|
{
|
||||||
|
return $this->commentMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCommentMembers(string $commentMembers): self
|
||||||
|
{
|
||||||
|
$this->commentMembers = $commentMembers;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWaitingForBirth(): bool
|
||||||
|
{
|
||||||
|
return $this->waitingForBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setWaitingForBirth(bool $waitingForBirth): self
|
||||||
|
{
|
||||||
|
$this->waitingForBirth = $waitingForBirth;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWaitingForBirthDate(): ?\DateTimeImmutable
|
||||||
|
{
|
||||||
|
return $this->waitingForBirthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setWaitingForBirthDate(?\DateTimeImmutable $waitingForBirthDate): self
|
||||||
|
{
|
||||||
|
$this->waitingForBirthDate = $waitingForBirthDate;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
40
src/Bundle/ChillPersonBundle/Form/HouseholdType.php
Normal file
40
src/Bundle/ChillPersonBundle/Form/HouseholdType.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Form;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class HouseholdType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('commentMembers', ChillTextareaType::class, [
|
||||||
|
'label' => 'household.comment_membership',
|
||||||
|
'required' => false
|
||||||
|
])
|
||||||
|
->add('waitingForBirth', CheckboxType::class, [
|
||||||
|
'required' => false,
|
||||||
|
'label' => 'household.expecting_birth'
|
||||||
|
])
|
||||||
|
->add('waitingForBirthDate', ChillDateType::class, [
|
||||||
|
'required' => false,
|
||||||
|
'label' => 'household.date_expecting_birth',
|
||||||
|
'input' => 'datetime_immutable'
|
||||||
|
])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => Household::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ShowHide } from 'ShowHide/show_hide.js';
|
||||||
|
|
||||||
|
let
|
||||||
|
k = document.getElementById('waitingForBirthContainer'),
|
||||||
|
waitingForBirthDate = document.getElementById('waitingForBirthDateContainer')
|
||||||
|
;
|
||||||
|
|
||||||
|
console.log(k );
|
||||||
|
|
||||||
|
new ShowHide({
|
||||||
|
'container': [waitingForBirthDate],
|
||||||
|
'froms': [k ],
|
||||||
|
'event_name': 'input',
|
||||||
|
'debug': true,
|
||||||
|
'test': function(froms, event) {
|
||||||
|
for (let f of froms.values()) {
|
||||||
|
console.log(f);
|
||||||
|
for (let input of f.querySelectorAll('input').values()) {
|
||||||
|
return input.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,42 @@
|
|||||||
|
{% extends '@ChillPerson/Household/layout.html.twig' %}
|
||||||
|
|
||||||
|
{% block title 'household.Edit member metadata'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
|
||||||
|
{{ form_row(form.commentMembers) }}
|
||||||
|
|
||||||
|
<div id="waitingForBirthContainer">
|
||||||
|
{{ form_row(form.waitingForBirth) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="waitingForBirthDateContainer">
|
||||||
|
{{ form_row(form.waitingForBirthDate) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path('chill_person_household_members', { 'household_id': household.id }) }}"
|
||||||
|
class="sc-button bt-cancel"
|
||||||
|
/>
|
||||||
|
{{ 'Cancel'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="submit" class="sc-button bt-save">
|
||||||
|
{{ 'Save'|trans }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ encore_entry_script_tags('household_edit_metadata') }}
|
||||||
|
{% endblock %}
|
@ -5,6 +5,20 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ block('title') }}</h1>
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
|
{% if household.commentMembers is not empty %}
|
||||||
|
<blockquote class="chill-user-quote">
|
||||||
|
{{ household.commentMembers|chill_markdown_to_html }}
|
||||||
|
</blockquote>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if household.waitingForBirth %}
|
||||||
|
{% if household.waitingForBirthDate is not null %}
|
||||||
|
{{ 'household.Expecting for birth on date'|trans({ 'date': household.waitingForBirthDate|format_date('long') }) }}
|
||||||
|
{% else %}
|
||||||
|
{{ 'household.Expecting for birth'|trans }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for p in positions %}
|
{% for p in positions %}
|
||||||
<h3>{{ p.label|localize_translatable_string }}</h3>
|
<h3>{{ p.label|localize_translatable_string }}</h3>
|
||||||
|
|
||||||
@ -139,6 +153,14 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<ul class="record_actions sticky-form-buttons">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path('chill_person_household_members_metadata_edit', { 'household_id': household.id }) }}"
|
||||||
|
class="sc-button bt-edit"
|
||||||
|
>
|
||||||
|
{{ 'household.Edit member metadata'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
href="{{ chill_path_add_return_path('chill_person_household_members_editor', {'household': household.id }) }}"
|
href="{{ chill_path_add_return_path('chill_person_household_members_editor', {'household': household.id }) }}"
|
||||||
|
@ -11,4 +11,5 @@ module.exports = function(encore, entries)
|
|||||||
encore.addEntry('accompanying_course', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
encore.addEntry('accompanying_course', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
||||||
encore.addEntry('household_members_editor', __dirname + '/Resources/public/vuejs/HouseholdMembersEditor/index.js');
|
encore.addEntry('household_members_editor', __dirname + '/Resources/public/vuejs/HouseholdMembersEditor/index.js');
|
||||||
encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
||||||
|
encore.addEntry('household_edit_metadata', __dirname + '/Resources/public/modules/household_edit_metadata/index.js');
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add comments and expecting birth to household
|
||||||
|
*/
|
||||||
|
final class Version20210614191600 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add comments and expecting birth to household';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_person_household ADD comment_members TEXT DEFAULT \'\' NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_household ADD waiting_for_birth BOOLEAN DEFAULT \'false\' NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_household ADD waiting_for_birth_date DATE DEFAULT NULL');
|
||||||
|
$this->addSql('COMMENT ON COLUMN chill_person_household.waiting_for_birth_date IS \'(DC2Type:date_immutable)\'');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_person_household DROP comment_members');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_household DROP waiting_for_birth');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_household DROP waiting_for_birth_date');
|
||||||
|
}
|
||||||
|
}
|
@ -40,3 +40,12 @@ household:
|
|||||||
many {et # autres personnes}
|
many {et # autres personnes}
|
||||||
other {et # autres personnes}
|
other {et # autres personnes}
|
||||||
}
|
}
|
||||||
|
Expecting for birth on date: Naissance attendue pour le {date}
|
||||||
|
Expecting for birth: Naissance attendue (date inconnue)
|
||||||
|
Edit member metadata: Données supplémentaires
|
||||||
|
comment_membership: Commentaire général sur les membres
|
||||||
|
expecting_birth: Naissance attendue ?
|
||||||
|
date_expecting_birth: Date de la naissance attendue
|
||||||
|
data_saved: Données enregistrées
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user