mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
improve filter form
- hide form in some places ; - i18n - hide status filtering with a parameter (redundant)
This commit is contained in:
@@ -73,22 +73,33 @@ class SingleTaskListType extends AbstractType
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$statuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]);
|
||||
$statuses = [
|
||||
'Tasks not started' => SingleTaskRepository::DATE_STATUS_NOT_STARTED,
|
||||
'Tasks with expired deadline' => SingleTaskRepository::DATE_STATUS_ENDED,
|
||||
'Tasks with warning deadline reached' => SingleTaskRepository::DATE_STATUS_WARNING,
|
||||
'Current tasks' => SingleTaskRepository::DATE_STATUS_CURRENT,
|
||||
'Closed tasks' => 'closed'
|
||||
];
|
||||
|
||||
$builder
|
||||
->add('user_id', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'choices' => $this->getUsersAssigneedToTask($options),
|
||||
'placeholder' => 'Choose a user',
|
||||
'required' => false
|
||||
])
|
||||
->add('status', ChoiceType::class, [
|
||||
'choices' => array_combine($statuses, $statuses),
|
||||
'expanded' => true,
|
||||
'multiple' => true
|
||||
])
|
||||
->add('user_id', ChoiceType::class, [
|
||||
'choices' => $this->getUserChoices($options),
|
||||
'placeholder' => 'Any user',
|
||||
'required' => false,
|
||||
'label' => 'Assignee'
|
||||
])
|
||||
;
|
||||
|
||||
if ($options['add_status'] === true) {
|
||||
$builder
|
||||
->add('status', ChoiceType::class, [
|
||||
'choices' => $statuses,
|
||||
'expanded' => true,
|
||||
'multiple' => true,
|
||||
'label' => 'status'
|
||||
]);
|
||||
}
|
||||
|
||||
if ($options['person'] === null) {
|
||||
$builder
|
||||
->add('person_id', PickPersonType::class, [
|
||||
@@ -97,7 +108,8 @@ class SingleTaskListType extends AbstractType
|
||||
$this->tokenStorage->getToken()->getUser(),
|
||||
new Role(TaskVoter::SHOW)
|
||||
),
|
||||
'required' => false
|
||||
'required' => false,
|
||||
'label' => 'Associated person'
|
||||
])
|
||||
;
|
||||
} else {
|
||||
@@ -110,6 +122,20 @@ class SingleTaskListType extends AbstractType
|
||||
}
|
||||
}
|
||||
|
||||
protected function getUserChoices($options)
|
||||
{
|
||||
$users = $this->getUsersAssigneedToTask($options);
|
||||
$choices = \array_combine(
|
||||
// get usernames
|
||||
\array_map(function(User $user) { return $user->getUsername(); }, $users),
|
||||
// get ids
|
||||
\array_map(function(User $user) { return $user->getId(); }, $users)
|
||||
);
|
||||
$choices['Unassigned'] = '_unassigned';
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of user having a task assigned.
|
||||
*
|
||||
@@ -162,6 +188,9 @@ class SingleTaskListType extends AbstractType
|
||||
->setDefined('person')
|
||||
->setDefault('person', null)
|
||||
->setAllowedTypes('person', [Person::class, 'null'])
|
||||
->setDefined('add_status')
|
||||
->setDefault('add_status', false)
|
||||
->setAllowedTypes('add_status', ['bool'])
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,8 @@ class SingleTaskType extends AbstractType
|
||||
->add('assignee', UserPickerType::class, [
|
||||
'required' => false,
|
||||
'center' => $options['center'],
|
||||
'role' => $options['role']
|
||||
'role' => $options['role'],
|
||||
'placeholder' => 'Not assigned'
|
||||
])
|
||||
->add('circle', ScopePickerType::class, [
|
||||
'center' => $options['center'],
|
||||
|
Reference in New Issue
Block a user