mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
js files put in place + select menus added for selecting person/thirdparty/... show-hide not working yet
This commit is contained in:
parent
4a5a1440ff
commit
94c9505c05
@ -11,30 +11,50 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person\PersonResource;
|
||||
use Chill\PersonBundle\Form\PersonResourceType;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Repository\PersonResourceRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class PersonResourceController extends AbstractController
|
||||
{
|
||||
private PersonResourceRepository $personResourceRepository;
|
||||
private PersonRepository $personRepository;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(
|
||||
PersonResourceRepository $personResourceRepository,
|
||||
PersonRepository $personRepository
|
||||
PersonRepository $personRepository,
|
||||
EntityManagerInterface $em
|
||||
)
|
||||
{
|
||||
$this->personResourceRepository = $personResourceRepository;
|
||||
$this->personRepository = $personRepository;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function listAction($person_id)
|
||||
public function listAction(Request $request, $person_id)
|
||||
{
|
||||
$person = $this->personRepository->find($person_id);
|
||||
$personResource = new PersonResource();
|
||||
|
||||
$form = $this->createForm(PersonResourceType::class);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_POST && $form->isValid()) {
|
||||
$this->em->persist($personResource);
|
||||
$this->em->flush();
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'chill_person_resource',
|
||||
['person_id' => $person->getId()]
|
||||
);
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'ChillPersonBundle:PersonResource:list.html.twig',
|
||||
[
|
||||
|
@ -31,7 +31,7 @@ class PersonResourceKind
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255)
|
||||
*/
|
||||
private array $label;
|
||||
private array $title;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
@ -48,14 +48,14 @@ class PersonResourceKind
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
public function getLabel(): ?array
|
||||
public function getTitle(): ?array
|
||||
{
|
||||
return $this->label;
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setLabel(array $label): self
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->label = $label;
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -13,8 +13,12 @@ namespace Chill\PersonBundle\Form;
|
||||
|
||||
use Chill\AsideActivityBundle\Templating\Entity\CategoryRender;
|
||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\PersonResource;
|
||||
use Chill\PersonBundle\Entity\Person\PersonResourceKind;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
@ -26,10 +30,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
final class PersonResourceType extends AbstractType
|
||||
{
|
||||
private CategoryRender $categoryRender;
|
||||
private PersonRender $personRender;
|
||||
private ThirdPartyRender $thirdPartyRender;
|
||||
|
||||
public function __construct(CategoryRender $categoryRender)
|
||||
public function __construct(CategoryRender $categoryRender, PersonRender $personRender, ThirdPartyRender $thirdPartyRender)
|
||||
{
|
||||
$this->categoryRender = $categoryRender;
|
||||
$this->personRender = $personRender;
|
||||
$this->thirdPartyRender = $thirdPartyRender;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
@ -58,6 +66,28 @@ final class PersonResourceType extends AbstractType
|
||||
'expanded' => true,
|
||||
'label' => 'Associer un'
|
||||
])
|
||||
->add('person', EntityType::class, [
|
||||
'label' => 'Usager',
|
||||
'class' => Person::class,
|
||||
'required' => false,
|
||||
'choice_label' => function (Person $person) {
|
||||
$options = [];
|
||||
return $this->personRender->renderString($person, $options);
|
||||
}
|
||||
])
|
||||
->add('thirdparty', EntityType::class, [
|
||||
'label' => 'Tiers',
|
||||
'class' => ThirdParty::class,
|
||||
'required' => false,
|
||||
'choice_label' => function (ThirdParty $thirdParty) {
|
||||
$options = [];
|
||||
return $this->thirdPartyRender->renderString($thirdParty, $options);
|
||||
}
|
||||
])
|
||||
->add('freetext', ChillTextareaType::class, [
|
||||
'label' => 'Description libre',
|
||||
'required' => false
|
||||
])
|
||||
->add('comment', ChillTextareaType::class, [
|
||||
'label' => 'Note',
|
||||
'required' => false
|
||||
@ -71,9 +101,9 @@ final class PersonResourceType extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
// public function getBlockPrefix(): string
|
||||
// {
|
||||
// return 'chill_personbundle_personresource';
|
||||
// }
|
||||
public function getBlockPrefix(): string
|
||||
{
|
||||
return 'chill_personbundle_person_resource';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js';
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
let
|
||||
linkedEntityContainer = document.querySelector('#linked-entity'),
|
||||
personContainer = document.querySelector('#person-entity'),
|
||||
thirdpartyContainer = document.querySelector('#thirdparty-entity'),
|
||||
freetextContainer = document.querySelector('#freetext-entity')
|
||||
;
|
||||
|
||||
if (null === linkedEntityContainer) {
|
||||
return;
|
||||
}
|
||||
|
||||
new ShowHide({
|
||||
debug: true,
|
||||
load_event: null,
|
||||
froms: [linkedEntityContainer],
|
||||
container: [personContainer, thirdpartyContainer, freetextContainer],
|
||||
test: function(containers, arg2, arg3) {
|
||||
for (let container of containers) {
|
||||
for (let input of container.querySelectorAll('input')) {
|
||||
if (!input.checked) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
});
|
@ -6,7 +6,19 @@
|
||||
|
||||
{{ form_row(form.kind) }}
|
||||
|
||||
<div id="linked-entity">
|
||||
{{ form_row(form.linkedEntity) }}
|
||||
</div>
|
||||
|
||||
<div id="person-entity">
|
||||
{{ form_row(form.person) }}
|
||||
</div>
|
||||
<div id="thirdparty-entity">
|
||||
{{ form_row(form.thirdparty) }}
|
||||
</div>
|
||||
<div id="freetext-entity">
|
||||
{{ form_row(form.freetext) }}
|
||||
</div>
|
||||
|
||||
{{ form_row(form.comment) }}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
<div class="item-bloc">
|
||||
<div class="item-row">
|
||||
<div class="item-col">comment zone</div>
|
||||
<div class="item-col">doing</div>
|
||||
<div class="item-col">....</div>
|
||||
</div>
|
||||
<div class="item-row">
|
||||
{# <div class="item-col">today</div> #}
|
||||
@ -32,3 +32,7 @@
|
||||
{% include "@ChillPerson/PersonResource/create.html.twig" %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{# {{ encore_entry_script_tags('page_person_resource') }} #}
|
||||
{% endblock %}
|
@ -19,4 +19,5 @@ module.exports = function(encore, entries)
|
||||
encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js');
|
||||
encore.addEntry('page_accompanying_course_index_masonry', __dirname + '/Resources/public/page/accompanying_course_index/masonry.js');
|
||||
encore.addEntry('page_suggest_names', __dirname + '/Resources/public/page/person/suggest-names.js');
|
||||
encore.addEntry('page_person_resource', __dirname + '/Resources/public/page/person_resource/index.js');
|
||||
};
|
||||
|
@ -226,8 +226,8 @@ Concerned scopes: Services concernés
|
||||
# person resource
|
||||
|
||||
person_resources_menu: "Ressources"
|
||||
Person resources: "Réssources de la personne"
|
||||
Add a person resource: "Ajouter une réssource"
|
||||
Person resources: "Ressources de la personne"
|
||||
Add a person resource: "Ajouter une ressource"
|
||||
|
||||
# pickAPersonType
|
||||
Pick a person: Choisir une personne
|
||||
|
Loading…
x
Reference in New Issue
Block a user