added table-column ordering (#1086)

This commit is contained in:
Kevin Papst
2019-09-09 23:47:42 +02:00
committed by GitHub
parent d041a3f4f9
commit a651e55dc9
82 changed files with 932 additions and 516 deletions

View File

@@ -23,6 +23,7 @@ use App\Repository\ActivityRepository;
use App\Repository\CustomerRepository;
use App\Repository\ProjectRepository;
use App\Repository\Query\ActivityFormTypeQuery;
use App\Repository\Query\BaseQuery;
use App\Repository\Query\CustomerFormTypeQuery;
use App\Repository\Query\ProjectFormTypeQuery;
use App\Repository\Query\TimesheetQuery;
@@ -32,6 +33,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Validator\Constraints\Choice;
/**
* Defines the base form used for all toolbars.
@@ -51,9 +53,15 @@ abstract class AbstractToolbarForm extends AbstractType
return '';
}
/**
* Returns whether the Javascript select-picker is allowed.
* TODO can be removed... once all bugs are fixed.
*
* @return bool
*/
protected function getSelectpickerConfig(): bool
{
return false;
return true;
}
protected function addUserChoice(FormBuilderInterface $builder)
@@ -203,6 +211,24 @@ abstract class AbstractToolbarForm extends AbstractType
]);
}
protected function addHiddenOrder(FormBuilderInterface $builder)
{
$builder->add('order', HiddenType::class, [
'constraints' => [
new Choice(['choices' => [BaseQuery::ORDER_ASC, BaseQuery::ORDER_DESC]])
]
]);
}
protected function addHiddenOrderBy(FormBuilderInterface $builder, array $allowedColumns)
{
$builder->add('orderBy', HiddenType::class, [
'constraints' => [
new Choice(['choices' => $allowedColumns])
]
]);
}
protected function addTagInputField(FormBuilderInterface $builder)
{
$builder->add('tags', TagsInputType::class, [

View File

@@ -40,6 +40,8 @@ class ActivityToolbarForm extends AbstractToolbarForm
$this->addVisibilityChoice($builder);
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
$this->addHiddenOrder($builder);
$this->addHiddenOrderBy($builder, ActivityQuery::ACTIVITY_ORDER_ALLOWED);
}
/**

View File

@@ -27,6 +27,8 @@ class CustomerToolbarForm extends AbstractToolbarForm
$this->addVisibilityChoice($builder);
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
$this->addHiddenOrder($builder);
$this->addHiddenOrderBy($builder, CustomerQuery::CUSTOMER_ORDER_ALLOWED);
}
/**

View File

@@ -28,6 +28,8 @@ class ProjectToolbarForm extends AbstractToolbarForm
$this->addVisibilityChoice($builder);
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
$this->addHiddenOrder($builder);
$this->addHiddenOrderBy($builder, ProjectQuery::PROJECT_ORDER_ALLOWED);
}
/**

View File

@@ -23,6 +23,8 @@ class TagToolbarForm extends AbstractToolbarForm
$this->addSearchTermInputField($builder);
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
$this->addHiddenOrder($builder);
$this->addHiddenOrderBy($builder, TagQuery::TAG_ORDER_ALLOWED);
}
/**

View File

@@ -23,6 +23,8 @@ class TeamToolbarForm extends AbstractToolbarForm
$this->addSearchTermInputField($builder);
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
$this->addHiddenOrder($builder);
$this->addHiddenOrderBy($builder, TeamQuery::TEAM_ORDER_ALLOWED);
}
/**

View File

@@ -35,6 +35,8 @@ class TimesheetToolbarForm extends AbstractToolbarForm
$this->addTimesheetStateChoice($builder);
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
$this->addHiddenOrder($builder);
$this->addHiddenOrderBy($builder, TimesheetQuery::TIMESHEET_ORDER_ALLOWED);
}
/**

View File

@@ -28,6 +28,8 @@ class UserToolbarForm extends AbstractToolbarForm
$this->addVisibilityChoice($builder, 'label.active');
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
$this->addHiddenOrder($builder);
$this->addHiddenOrderBy($builder, UserQuery::USER_ORDER_ALLOWED);
}
/**