mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Allow to filter logs by user who caused them
This commit is contained in:
parent
c7f5c23374
commit
d18ee704b8
6 changed files with 75 additions and 11 deletions
|
@ -23,6 +23,7 @@ use App\Form\Filters\Constraints\BooleanConstraintType;
|
|||
use App\Form\Filters\Constraints\DateTimeConstraintType;
|
||||
use App\Form\Filters\Constraints\InstanceOfConstraintType;
|
||||
use App\Form\Filters\Constraints\NumberConstraintType;
|
||||
use App\Form\Filters\Constraints\StructuralEntityConstraintType;
|
||||
use App\Form\Filters\Constraints\UserEntityConstraintType;
|
||||
use App\Form\Filters\Constraints\TextConstraintType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
@ -73,7 +74,7 @@ class AttachmentFilterType extends AbstractType
|
|||
]
|
||||
]);
|
||||
|
||||
$builder->add('attachmentType', UserEntityConstraintType::class, [
|
||||
$builder->add('attachmentType', StructuralEntityConstraintType::class, [
|
||||
'label' => 'attachment.attachment_type',
|
||||
'entity_class' => AttachmentType::class
|
||||
]);
|
||||
|
|
59
src/Form/Filters/Constraints/UserEntityConstraintType.php
Normal file
59
src/Form/Filters/Constraints/UserEntityConstraintType.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Filters\Constraints;
|
||||
|
||||
use App\DataTables\Filters\Constraints\EntityConstraint;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class UserEntityConstraintType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'compound' => true,
|
||||
'data_class' => EntityConstraint::class,
|
||||
'text_suffix' => '', // An suffix which is attached as text-append to the input group. This can for example be used for units
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$choices = [
|
||||
'' => '',
|
||||
'filter.entity_constraint.operator.EQ' => '=',
|
||||
'filter.entity_constraint.operator.NEQ' => '!=',
|
||||
];
|
||||
|
||||
$builder->add('value', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'data-controller' => 'elements--selectpicker',
|
||||
'data-live-search' => true,
|
||||
'title' => 'selectpicker.nothing_selected',
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
$builder->add('operator', ChoiceType::class, [
|
||||
'label' => 'filter.text_constraint.operator',
|
||||
'choices' => $choices,
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
parent::buildView($view, $form, $options);
|
||||
$view->vars['text_suffix'] = $options['text_suffix'];
|
||||
}
|
||||
}
|
|
@ -106,9 +106,8 @@ class LogFilterType extends AbstractType
|
|||
'choices' => self::TARGET_TYPE_CHOICES
|
||||
]);
|
||||
|
||||
$builder->add('user', StructuralEntityConstraintType::class, [
|
||||
$builder->add('user', UserEntityConstraintType::class, [
|
||||
'label' => 'log.user',
|
||||
'entity_class' => User::class,
|
||||
]);
|
||||
|
||||
$builder->add('targetType', ChoiceConstraintType::class, [
|
||||
|
|
|
@ -15,7 +15,7 @@ use App\Form\Filters\Constraints\ChoiceConstraintType;
|
|||
use App\Form\Filters\Constraints\DateTimeConstraintType;
|
||||
use App\Form\Filters\Constraints\NumberConstraintType;
|
||||
use App\Form\Filters\Constraints\ParameterConstraintType;
|
||||
use App\Form\Filters\Constraints\UserEntityConstraintType;
|
||||
use App\Form\Filters\Constraints\StructuralEntityConstraintType;
|
||||
use App\Form\Filters\Constraints\TagsConstraintType;
|
||||
use App\Form\Filters\Constraints\TextConstraintType;
|
||||
use Svg\Tag\Text;
|
||||
|
@ -54,12 +54,12 @@ class PartFilterType extends AbstractType
|
|||
'label' => 'part.edit.description',
|
||||
]);
|
||||
|
||||
$builder->add('category', UserEntityConstraintType::class, [
|
||||
$builder->add('category', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.category',
|
||||
'entity_class' => Category::class
|
||||
]);
|
||||
|
||||
$builder->add('footprint', UserEntityConstraintType::class, [
|
||||
$builder->add('footprint', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.footprint',
|
||||
'entity_class' => Footprint::class
|
||||
]);
|
||||
|
@ -96,7 +96,7 @@ class PartFilterType extends AbstractType
|
|||
'min' => 0,
|
||||
]);
|
||||
|
||||
$builder->add('measurementUnit', UserEntityConstraintType::class, [
|
||||
$builder->add('measurementUnit', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.partUnit',
|
||||
'entity_class' => MeasurementUnit::class
|
||||
]);
|
||||
|
@ -114,7 +114,7 @@ class PartFilterType extends AbstractType
|
|||
* Manufacturer tab
|
||||
*/
|
||||
|
||||
$builder->add('manufacturer', UserEntityConstraintType::class, [
|
||||
$builder->add('manufacturer', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.manufacturer.label',
|
||||
'entity_class' => Manufacturer::class
|
||||
]);
|
||||
|
@ -145,7 +145,7 @@ class PartFilterType extends AbstractType
|
|||
* Purchasee informations
|
||||
*/
|
||||
|
||||
$builder->add('supplier', UserEntityConstraintType::class, [
|
||||
$builder->add('supplier', StructuralEntityConstraintType::class, [
|
||||
'label' => 'supplier.label',
|
||||
'entity_class' => Manufacturer::class
|
||||
]);
|
||||
|
@ -163,7 +163,7 @@ class PartFilterType extends AbstractType
|
|||
/*
|
||||
* Stocks tabs
|
||||
*/
|
||||
$builder->add('storelocation', UserEntityConstraintType::class, [
|
||||
$builder->add('storelocation', StructuralEntityConstraintType::class, [
|
||||
'label' => 'storelocation.label',
|
||||
'entity_class' => Storelocation::class
|
||||
]);
|
||||
|
@ -210,7 +210,7 @@ class PartFilterType extends AbstractType
|
|||
'min' => 0,
|
||||
]);
|
||||
|
||||
$builder->add('attachmentType', UserEntityConstraintType::class, [
|
||||
$builder->add('attachmentType', StructuralEntityConstraintType::class, [
|
||||
'label' => 'attachment.attachment_type',
|
||||
'entity_class' => AttachmentType::class
|
||||
]);
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
{{ block('text_constraint_widget') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block user_entity_constraint_widget %}
|
||||
{{ block('text_constraint_widget') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block date_time_constraint_widget %}
|
||||
{{ block('number_constraint_widget') }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
{{ form_row(filterForm.dbId) }}
|
||||
{{ form_row(filterForm.timestamp) }}
|
||||
{{ form_row(filterForm.eventType) }}
|
||||
{{ form_row(filterForm.user) }}
|
||||
{{ form_row(filterForm.level) }}
|
||||
{{ form_row(filterForm.targetType) }}
|
||||
{{ form_row(filterForm.targetId) }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue