mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-19 10:24:50 +02:00
Added filter constraint for manufacturing status.
This commit is contained in:
parent
7b3538a2c7
commit
ec5e956e31
11 changed files with 342 additions and 1 deletions
48
src/Form/Filters/Constraints/ChoiceConstraintType.php
Normal file
48
src/Form/Filters/Constraints/ChoiceConstraintType.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Filters\Constraints;
|
||||
|
||||
use App\DataTables\Filters\Constraints\ChoiceConstraint;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ChoiceConstraintType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setRequired('choices');
|
||||
$resolver->setAllowedTypes('choices', 'array');
|
||||
|
||||
$resolver->setDefaults([
|
||||
'compound' => true,
|
||||
'data_class' => ChoiceConstraint::class,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$choices = [
|
||||
'' => '',
|
||||
'filter.choice_constraint.operator.ANY' => 'ANY',
|
||||
'filter.choice_constraint.operator.NONE' => 'NONE',
|
||||
];
|
||||
|
||||
$builder->add('operator', ChoiceType::class, [
|
||||
'choices' => $choices,
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
$builder->add('value', ChoiceType::class, [
|
||||
'choices' => $options['choices'],
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'attr' => [
|
||||
'data-controller' => 'elements--select-multiple',
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ use App\Entity\Parts\Manufacturer;
|
|||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Form\Filters\Constraints\BooleanConstraintType;
|
||||
use App\Form\Filters\Constraints\ChoiceConstraintType;
|
||||
use App\Form\Filters\Constraints\DateTimeConstraintType;
|
||||
use App\Form\Filters\Constraints\NumberConstraintType;
|
||||
use App\Form\Filters\Constraints\StructuralEntityConstraintType;
|
||||
|
@ -123,6 +124,20 @@ class PartFilterType extends AbstractType
|
|||
'label' => 'part.edit.mpn'
|
||||
]);
|
||||
|
||||
$status_choices = [
|
||||
'm_status.unknown' => '',
|
||||
'm_status.announced' => 'announced',
|
||||
'm_status.active' => 'active',
|
||||
'm_status.nrfnd' => 'nrfnd',
|
||||
'm_status.eol' => 'eol',
|
||||
'm_status.discontinued' => 'discontinued',
|
||||
];
|
||||
|
||||
$builder->add('manufacturing_status', ChoiceConstraintType::class, [
|
||||
'label' => 'part.edit.manufacturing_status',
|
||||
'choices' => $status_choices,
|
||||
]);
|
||||
|
||||
/*
|
||||
* Purchasee informations
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue