mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-20 19:05:14 +02:00
Added an filter constraint based on part tags.
This commit is contained in:
parent
4d3ff7d7b5
commit
4ba58cc621
7 changed files with 234 additions and 4 deletions
56
src/Form/Filters/Constraints/TagsConstraintType.php
Normal file
56
src/Form/Filters/Constraints/TagsConstraintType.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Filters\Constraints;
|
||||
|
||||
use App\DataTables\Filters\Constraints\Part\TagsConstraint;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SearchType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
class TagsConstraintType extends AbstractType
|
||||
{
|
||||
protected $urlGenerator;
|
||||
|
||||
public function __construct(UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'compound' => true,
|
||||
'data_class' => TagsConstraint::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$choices = [
|
||||
'' => '',
|
||||
'filter.tags_constraint.operator.ANY' => 'ANY',
|
||||
'filter.tags_constraint.operator.ALL' => 'ALL',
|
||||
'filter.tags_constraint.operator.NONE' => 'NONE'
|
||||
];
|
||||
|
||||
$builder->add('value', SearchType::class, [
|
||||
'attr' => [
|
||||
'class' => 'tagsinput',
|
||||
'data-controller' => 'elements--tagsinput',
|
||||
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => '__QUERY__']),
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
|
||||
$builder->add('operator', ChoiceType::class, [
|
||||
'label' => 'filter.text_constraint.operator',
|
||||
'choices' => $choices,
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ use App\Form\Filters\Constraints\BooleanConstraintType;
|
|||
use App\Form\Filters\Constraints\DateTimeConstraintType;
|
||||
use App\Form\Filters\Constraints\NumberConstraintType;
|
||||
use App\Form\Filters\Constraints\StructuralEntityConstraintType;
|
||||
use App\Form\Filters\Constraints\TagsConstraintType;
|
||||
use App\Form\Filters\Constraints\TextConstraintType;
|
||||
use Svg\Tag\Text;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
@ -56,6 +57,10 @@ class PartFilterType extends AbstractType
|
|||
'entity_class' => Footprint::class
|
||||
]);
|
||||
|
||||
$builder->add('tags', TagsConstraintType::class, [
|
||||
'label' => 'part.edit.tags'
|
||||
]);
|
||||
|
||||
$builder->add('comment', TextConstraintType::class, [
|
||||
'label' => 'part.edit.comment'
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue