Compare commits

..

2 Commits

Author SHA1 Message Date
714d0ed991 DX [changie] 2023-06-07 19:40:56 +02:00
ed96017c49 FEATURE [task filter][person] filter tasks on the basis of a person 2023-06-07 19:38:24 +02:00
14 changed files with 125 additions and 63 deletions

View File

@@ -0,0 +1,6 @@
kind: DX
body: Add methods to RegroupmentRepository and fullfill Center / Regroupment Doctrine
mapping
time: 2023-06-07T13:03:44.177864269+02:00
custom:
Issue: ""

View File

@@ -0,0 +1,6 @@
kind: Feature
body: Add the possibility to filter tasks on the basis of the person involved. Expansion
of FilterOrderHelper.
time: 2023-06-07T19:40:40.506964817+02:00
custom:
Issue: ""

View File

@@ -0,0 +1,7 @@
kind: Security
body: Rights are checked for display of 'accompanying period' tab in household menu.
Rights are also checked for creation of 'accompanying period' from within household
context
time: 2023-06-07T17:47:02.488819553+02:00
custom:
Issue: "105"

View File

@@ -1,17 +0,0 @@
## v2.1.0 - 2023-06-12
### Feature
* [docgen] allow to pick a third party when generating a document in context Activity, AccompanyingPeriod
### Fixed
* ([#111](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/111)) List of "my accompanying periods": separate the active and closed periods in two different lists, and show the inactive_long and inactive_short periods
### Security
* ([#105](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/105)) Rights are checked for display of 'accompanying period' tab in household menu. Rights are also checked for creation of 'accompanying period' from within household context
### DX
* Add methods to RegroupmentRepository and fullfill Center / Regroupment Doctrine mapping

View File

@@ -6,24 +6,6 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
## v2.1.0 - 2023-06-12
### Feature
* [docgen] allow to pick a third party when generating a document in context Activity, AccompanyingPeriod
### Fixed
* ([#111](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/111)) List of "my accompanying periods": separate the active and closed periods in two different lists, and show the inactive_long and inactive_short periods
### Security
* ([#105](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/105)) Rights are checked for display of 'accompanying period' tab in household menu. Rights are also checked for creation of 'accompanying period' from within household context
### DX
* Add methods to RegroupmentRepository and fullfill Center / Regroupment Doctrine mapping
## 2.0.0
* this is a release to relaunch our proceess of release with semantic versioning

View File

@@ -13,6 +13,8 @@ namespace Chill\MainBundle\Form\Type\Listing;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
use Chill\PersonBundle\Form\Type\PickPersonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SearchType;
@@ -97,6 +99,30 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
$builder->add($dateRangesBuilder);
}
if (0 < count($helper->getPersonPickers())) {
$personPickersBuilder = $builder->create('personPicker', null, ['compound' => true]);
foreach ($helper->getPersonPickers() as $name => $opts) {
$personPicker = $personPickersBuilder->create($name, null, [
'compound' => true,
'label' => null === $opts['label'] ? false : $opts['label'] ?? $name,
]);
$personPicker->add(
'person',
PickPersonDynamicType::class,
[
'multiple' => false,
]
);
$personPickersBuilder->add($personPicker);
}
$builder->add($personPickersBuilder);
}
foreach ($this->requestStack->getCurrentRequest()->query->getIterator() as $key => $value) {
switch ($key) {
case 'q':

View File

@@ -34,6 +34,35 @@
{% endfor %}
{% endif %}
{% endif %}
{% if form.personPicker is defined %}
{% if form.personPicker|length > 0 %}
{% for personPickerName, options in form.personPicker %}
<div class="row gx-0">
{% if form.personPicker[personPickerName].vars.label is not same as(false) %}
<div class="col-md-2">
{{ form_label(form.personPicker[personPickerName])}}
</div>
{% endif %}
<div class="col-md-9">
{{ form_widget(form.personPicker[personPickerName]) }}
</div>
</div>
{% if form.checkboxes is not defined %}
<div class="row gx-0">
<div class="col-md-12">
<ul class="record_actions">
<li>
<button type="submit" class="btn btn-misc"><i class="fa fa-filter"></i></button>
</li>
</ul>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% if form.checkboxes is defined %}
{% if form.checkboxes|length > 0 %}
{% for checkbox_name, options in form.checkboxes %}
@@ -61,5 +90,6 @@
{% endfor %}
{% endif %}
{% endif %}
</div>
{{ form_end(form) }}

View File

@@ -26,6 +26,8 @@ class FilterOrderHelper
private array $dateRanges = [];
private array $personPickers = [];
private FormFactoryInterface $formFactory;
private ?string $formName = 'f';
@@ -70,6 +72,13 @@ class FilterOrderHelper
return $this;
}
public function addPersonPickers(string $name, ?string $label = null): self
{
$this->personPickers[$name] = ['label' => $label];
return $this;
}
public function buildForm(): FormInterface
{
return $this->formFactory
@@ -91,6 +100,16 @@ class FilterOrderHelper
return $this->checkboxes;
}
public function getPersonPickers(): array
{
return $this->personPickers;
}
public function getPersonPickerData(string $name): array
{
return $this->getFormData()['personPickers'][$name];
}
/**
* @return array<'to': DateTimeImmutable, 'from': DateTimeImmutable>
*/
@@ -133,6 +152,10 @@ class FilterOrderHelper
$r['checkboxes'][$name] = $c['default'];
}
foreach ($this->personPickers as $name => $defaults) {
$r['personPickers'][$name]['label'] = $defaults['label'];
}
foreach ($this->dateRanges as $name => $defaults) {
$r['dateRanges'][$name]['from'] = $defaults['from'];
$r['dateRanges'][$name]['to'] = $defaults['to'];

View File

@@ -21,6 +21,8 @@ class FilterOrderHelperBuilder
private array $dateRanges = [];
private array $personPickers = [];
private FormFactoryInterface $formFactory;
private RequestStack $requestStack;
@@ -56,6 +58,13 @@ class FilterOrderHelperBuilder
return $this;
}
public function addPersonPicker(string $name, ?string $label = null): self
{
$this->personPickers[$name] = ['label' => $label];
return $this;
}
public function build(): FilterOrderHelper
{
$helper = new FilterOrderHelper(
@@ -85,6 +94,14 @@ class FilterOrderHelperBuilder
$helper->addDateRange($name, $label, $from, $to);
}
foreach (
$this->personPickers as $name => [
'label' => $label,
]
) {
$helper->addPersonPickers($name, $label);
}
return $helper;
}
}

View File

@@ -12,11 +12,9 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class UserAccompanyingPeriodController extends AbstractController
@@ -34,24 +32,12 @@ class UserAccompanyingPeriodController extends AbstractController
/**
* @Route("/{_locale}/person/accompanying-periods/my", name="chill_person_accompanying_period_user")
*/
public function listAction(Request $request): Response
public function listAction(Request $request)
{
$active = $request->query->getBoolean('active', true);
$steps = match ($active) {
true => [
AccompanyingPeriod::STEP_CONFIRMED,
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG,
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT,
],
false => [
AccompanyingPeriod::STEP_CLOSED,
]
};
$total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => $steps]);
$total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => ['CONFIRMED', 'CLOSED']]);
$pagination = $this->paginatorFactory->create($total);
$accompanyingPeriods = $this->accompanyingPeriodRepository->findBy(
['user' => $this->getUser(), 'step' => $steps],
['user' => $this->getUser(), 'step' => ['CONFIRMED', 'CLOSED']],
['openingDate' => 'DESC'],
$pagination->getItemsPerPage(),
$pagination->getCurrentPageFirstItemNumber()
@@ -60,14 +46,13 @@ class UserAccompanyingPeriodController extends AbstractController
return $this->render('@ChillPerson/AccompanyingPeriod/user_periods_list.html.twig', [
'accompanyingPeriods' => $accompanyingPeriods,
'pagination' => $pagination,
'active' => $active,
]);
}
/**
* @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user")
*/
public function listDraftsAction(): Response
public function listDraftsAction(Request $request)
{
$total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => 'DRAFT']);
$pagination = $this->paginatorFactory->create($total);

View File

@@ -17,15 +17,6 @@
<div class="col-md-10">
<h1>{{ 'My accompanying periods'|trans }}</h1>
<ul class="nav nav-pills justify-content-center">
<li class="nav-item">
<a class="nav-link {% if active == true %}active{% endif %}" aria-current="page" href="{{ chill_path_forward_return_path('chill_person_accompanying_period_user', {'active': true}) }}">{{ ['Confirmed'|trans, 'course.inactive_short'|trans, 'course.inactive_long'|trans]|join(', ') }}</a>
</li>
<li class="nav-item ">
<a class="nav-link {% if active == false %}active{% endif %}" href="{{ chill_path_forward_return_path('chill_person_accompanying_period_user', {'active': false}) }}">{{ 'course.closed'|trans }}</a>
</li>
</ul>
<p>{{ 'Number of periods'|trans }}: <span class="badge rounded-pill bg-primary">{{ pagination.totalItems }}</span></p>
<div class="flex-table accompanyingcourse-list">

View File

@@ -303,6 +303,7 @@ final class SingleTaskController extends AbstractController
$filterOrder->getCheckboxData('status'),
array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states'))
);
$nb = $this->singleTaskAclAwareRepository->countByAllViewable(
$filterOrder->getQueryString(),
$flags
@@ -678,6 +679,7 @@ final class SingleTaskController extends AbstractController
return $this->filterOrderHelperFactory
->create(self::class)
->addSearchBox()
->addPersonPicker('personPicker')
->addCheckbox('status', $statuses, $statuses, $statusTrans)
->addCheckbox('states', $states, ['new', 'in_progress'])
->build();

View File

@@ -27,8 +27,10 @@
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('page_task_list') }}
{{ encore_entry_link_tags('mod_pickentity_type') }}
{% endblock %}
{% block js %}
{{ parent() }}
{{ encore_entry_script_tags('page_task_list') }}
{{ encore_entry_script_tags('mod_pickentity_type') }}
{% endblock %}

View File

@@ -119,3 +119,5 @@ CHILL_TASK_TASK_UPDATE: Modifier une tâche
CHILL_TASK_TASK_CREATE_FOR_COURSE: Créer une tâche pour un parcours
CHILL_TASK_TASK_CREATE_FOR_PERSON: Créer une tâche pour un usager
filter:
Filter on user: Filtrer par utilisateur/ utilisatrice