mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Added more filters
This commit is contained in:
parent
c9151c65ba
commit
ff5b59e25d
4 changed files with 253 additions and 12 deletions
|
@ -8,6 +8,11 @@ use App\DataTables\Filters\Constraints\EntityConstraint;
|
|||
use App\DataTables\Filters\Constraints\NumberConstraint;
|
||||
use App\DataTables\Filters\Constraints\TextConstraint;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Services\Trees\NodesListBuilder;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
|
@ -16,12 +21,21 @@ class PartFilter implements FilterInterface
|
|||
|
||||
use CompoundFilterTrait;
|
||||
|
||||
/** @var NumberConstraint */
|
||||
protected $dbId;
|
||||
|
||||
/** @var TextConstraint */
|
||||
protected $name;
|
||||
|
||||
/** @var TextConstraint */
|
||||
protected $description;
|
||||
|
||||
/** @var TextConstraint */
|
||||
protected $comment;
|
||||
|
||||
/** @var NumberConstraint */
|
||||
protected $minAmount;
|
||||
|
||||
/** @var BooleanConstraint */
|
||||
protected $favorite;
|
||||
|
||||
|
@ -40,17 +54,51 @@ class PartFilter implements FilterInterface
|
|||
/** @var EntityConstraint */
|
||||
protected $category;
|
||||
|
||||
/** @var EntityConstraint */
|
||||
protected $footprint;
|
||||
|
||||
/** @var EntityConstraint */
|
||||
protected $manufacturer;
|
||||
|
||||
/** @var EntityConstraint */
|
||||
protected $supplier;
|
||||
|
||||
/** @var EntityConstraint */
|
||||
protected $storelocation;
|
||||
|
||||
/** @var EntityConstraint */
|
||||
protected $measurementUnit;
|
||||
|
||||
/** @var TextConstraint */
|
||||
protected $manufacturer_product_url;
|
||||
|
||||
/** @var TextConstraint */
|
||||
protected $manufacturer_product_number;
|
||||
|
||||
public function __construct(NodesListBuilder $nodesListBuilder)
|
||||
{
|
||||
$this->favorite =
|
||||
$this->needsReview = new BooleanConstraint('part.needs_review');
|
||||
$this->mass = new NumberConstraint('part.mass');
|
||||
$this->name = new TextConstraint('part.name');
|
||||
$this->description = new TextConstraint('part.description');
|
||||
$this->comment = new TextConstraint('part.comment');
|
||||
$this->category = new EntityConstraint($nodesListBuilder, Category::class, 'part.category');
|
||||
$this->footprint = new EntityConstraint($nodesListBuilder, Footprint::class, 'part.footprint');
|
||||
|
||||
$this->favorite = new BooleanConstraint('part.favorite');
|
||||
$this->needsReview = new BooleanConstraint('part.needs_review');
|
||||
$this->measurementUnit = new EntityConstraint($nodesListBuilder, MeasurementUnit::class, 'part.partUnit');
|
||||
$this->mass = new NumberConstraint('part.mass');
|
||||
$this->dbId = new NumberConstraint('part.id');
|
||||
$this->addedDate = new DateTimeConstraint('part.addedDate');
|
||||
$this->lastModified = new DateTimeConstraint('part.lastModified');
|
||||
|
||||
$this->category = new EntityConstraint($nodesListBuilder, Category::class, 'part.category');
|
||||
$this->minAmount = new NumberConstraint('part.minAmount');
|
||||
$this->supplier = new EntityConstraint($nodesListBuilder, Supplier::class, 'orderdetails.supplier');
|
||||
|
||||
$this->manufacturer = new EntityConstraint($nodesListBuilder, Manufacturer::class, 'part.manufacturer');
|
||||
$this->manufacturer_product_number = new TextConstraint('part.manufacturer_product_number');
|
||||
$this->manufacturer_product_url = new TextConstraint('part.manufacturer_product_url');
|
||||
|
||||
$this->storelocation = new EntityConstraint($nodesListBuilder, Storelocation::class, 'partLots.storage_location');
|
||||
}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
|
@ -110,4 +158,88 @@ class PartFilter implements FilterInterface
|
|||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EntityConstraint
|
||||
*/
|
||||
public function getFootprint(): EntityConstraint
|
||||
{
|
||||
return $this->footprint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EntityConstraint
|
||||
*/
|
||||
public function getManufacturer(): EntityConstraint
|
||||
{
|
||||
return $this->manufacturer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EntityConstraint
|
||||
*/
|
||||
public function getSupplier(): EntityConstraint
|
||||
{
|
||||
return $this->supplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EntityConstraint
|
||||
*/
|
||||
public function getStorelocation(): EntityConstraint
|
||||
{
|
||||
return $this->storelocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EntityConstraint
|
||||
*/
|
||||
public function getMeasurementUnit(): EntityConstraint
|
||||
{
|
||||
return $this->measurementUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NumberConstraint
|
||||
*/
|
||||
public function getDbId(): NumberConstraint
|
||||
{
|
||||
return $this->dbId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TextConstraint
|
||||
*/
|
||||
public function getComment(): TextConstraint
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NumberConstraint
|
||||
*/
|
||||
public function getMinAmount(): NumberConstraint
|
||||
{
|
||||
return $this->minAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TextConstraint
|
||||
*/
|
||||
public function getManufacturerProductUrl(): TextConstraint
|
||||
{
|
||||
return $this->manufacturer_product_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TextConstraint
|
||||
*/
|
||||
public function getManufacturerProductNumber(): TextConstraint
|
||||
{
|
||||
return $this->manufacturer_product_number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,16 @@ namespace App\Form\Filters;
|
|||
|
||||
use App\DataTables\Filters\PartFilter;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
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\DateTimeConstraintType;
|
||||
use App\Form\Filters\Constraints\NumberConstraintType;
|
||||
use App\Form\Filters\Constraints\StructuralEntityConstraintType;
|
||||
use App\Form\Filters\Constraints\TextConstraintType;
|
||||
use Svg\Tag\Text;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
@ -29,11 +34,41 @@ class PartFilterType extends AbstractType
|
|||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
/*
|
||||
* Common tab
|
||||
*/
|
||||
|
||||
$builder->add('name', TextConstraintType::class, [
|
||||
'label' => 'part.edit.name',
|
||||
]);
|
||||
|
||||
$builder->add('description', TextConstraintType::class, [
|
||||
'label' => 'part.edit.description',
|
||||
]);
|
||||
|
||||
$builder->add('category', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.category',
|
||||
'entity_class' => Category::class
|
||||
]);
|
||||
|
||||
$builder->add('footprint', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.footprint',
|
||||
'entity_class' => Footprint::class
|
||||
]);
|
||||
|
||||
$builder->add('comment', TextConstraintType::class, [
|
||||
'label' => 'part.edit.comment'
|
||||
]);
|
||||
|
||||
/*
|
||||
* Advanced tab
|
||||
*/
|
||||
|
||||
$builder->add('dbId', NumberConstraintType::class, [
|
||||
'label' => 'part.filter.dbId',
|
||||
'min' => 1,
|
||||
]);
|
||||
|
||||
$builder->add('favorite', BooleanConstraintType::class, [
|
||||
'label' => 'part.edit.is_favorite'
|
||||
]);
|
||||
|
@ -48,12 +83,9 @@ class PartFilterType extends AbstractType
|
|||
'min' => 0,
|
||||
]);
|
||||
|
||||
$builder->add('name', TextConstraintType::class, [
|
||||
'label' => 'part.edit.name',
|
||||
]);
|
||||
|
||||
$builder->add('description', TextConstraintType::class, [
|
||||
'label' => 'part.edit.description',
|
||||
$builder->add('measurementUnit', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.partUnit',
|
||||
'entity_class' => MeasurementUnit::class
|
||||
]);
|
||||
|
||||
$builder->add('lastModified', DateTimeConstraintType::class, [
|
||||
|
@ -65,6 +97,47 @@ class PartFilterType extends AbstractType
|
|||
]);
|
||||
|
||||
|
||||
/*
|
||||
* Manufacturer tab
|
||||
*/
|
||||
|
||||
$builder->add('manufacturer', StructuralEntityConstraintType::class, [
|
||||
'label' => 'part.edit.manufacturer.label',
|
||||
'entity_class' => Manufacturer::class
|
||||
]);
|
||||
|
||||
$builder->add('manufacturer_product_url', TextConstraintType::class, [
|
||||
'label' => 'part.edit.manufacturer_url.label'
|
||||
]);
|
||||
|
||||
$builder->add('manufacturer_product_number', TextConstraintType::class, [
|
||||
'label' => 'part.edit.mpn'
|
||||
]);
|
||||
|
||||
/*
|
||||
* Purchasee informations
|
||||
*/
|
||||
|
||||
$builder->add('supplier', StructuralEntityConstraintType::class, [
|
||||
'label' => 'supplier.label',
|
||||
'entity_class' => Manufacturer::class
|
||||
]);
|
||||
|
||||
|
||||
/*
|
||||
* Stocks tabs
|
||||
*/
|
||||
$builder->add('storelocation', StructuralEntityConstraintType::class, [
|
||||
'label' => 'storelocation.label',
|
||||
'entity_class' => Storelocation::class
|
||||
]);
|
||||
|
||||
$builder->add('minAmount', NumberConstraintType::class, [
|
||||
'label' => 'part.edit.mininstock',
|
||||
'min' => 0,
|
||||
]);
|
||||
|
||||
|
||||
$builder->add('submit', SubmitType::class, [
|
||||
'label' => 'Update',
|
||||
]);
|
||||
|
|
|
@ -3,10 +3,19 @@
|
|||
<div class="card-body">
|
||||
<ul class="nav nav-tabs" id="filterTabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="filter-common-tab" data-bs-toggle="tab" data-bs-target="#filter-common">Common</button>
|
||||
<button class="nav-link active" id="filter-common-tab" data-bs-toggle="tab" data-bs-target="#filter-common"><i class="fas fa-id-card fa-fw"></i> {% trans %}part.edit.tab.common{% endtrans %}</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="filter-advanced-tab" data-bs-toggle="tab" data-bs-target="#filter-advanced">Advanced</button>
|
||||
<button class="nav-link" id="filter-manufacturer-tab" data-bs-toggle="tab" data-bs-target="#filter-manufacturer"><i class="fas fa-industry fa-fw"></i> {% trans %}part.edit.tab.manufacturer{% endtrans %}</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="filter-advanced-tab" data-bs-toggle="tab" data-bs-target="#filter-advanced"><i class="fas fa-shapes fa-fw"></i> {% trans %}part.edit.tab.advanced{% endtrans %}</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="filter-stocks-tab" data-bs-toggle="tab" data-bs-target="#filter-stocks"><i class="fas fa-boxes fa-fw"></i> {% trans %}part.edit.tab.part_lots{% endtrans %}</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="filter-orderdetails-tab" data-bs-toggle="tab" data-bs-target="#filter-orderdetails"><i class="fas fa-shopping-cart fa-fw"></i> {% trans %}part.edit.tab.orderdetails{% endtrans %}</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
@ -16,16 +25,37 @@
|
|||
<div class="tab-pane active pt-3" id="filter-common" role="tabpanel" aria-labelledby="filter-common-tab" tabindex="0">
|
||||
{{ form_row(filterForm.name) }}
|
||||
{{ form_row(filterForm.description) }}
|
||||
{{ form_row(filterForm.category) }}
|
||||
{{ form_row(filterForm.footprint) }}
|
||||
{{ form_row(filterForm.comment) }}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane pt-3" id="filter-manufacturer" role="tabpanel" aria-labelledby="filter-manufacturer-tab" tabindex="0">
|
||||
{{ form_row(filterForm.manufacturer) }}
|
||||
{{ form_row(filterForm.manufacturer_product_number) }}
|
||||
{{ form_row(filterForm.manufacturer_product_url) }}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane pt-3" id="filter-advanced" role="tabpanel" aria-labelledby="filter-advanced-tab" tabindex="0">
|
||||
{{ form_row(filterForm.favorite) }}
|
||||
{{ form_row(filterForm.needsReview) }}
|
||||
{{ form_row(filterForm.measurementUnit) }}
|
||||
{{ form_row(filterForm.mass) }}
|
||||
{{ form_row(filterForm.dbId) }}
|
||||
{{ form_row(filterForm.lastModified) }}
|
||||
{{ form_row(filterForm.addedDate) }}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane pt-3" id="filter-stocks" role="tabpanel" aria-labelledby="filter-stocks-tab" tabindex="0">
|
||||
{{ form_row(filterForm.storelocation) }}
|
||||
{{ form_row(filterForm.minAmount) }}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane pt-3" id="filter-orderdetails" role="tabpanel" aria-labelledby="filter-orderdetails-tab" tabindex="0">
|
||||
{{ form_row(filterForm.supplier) }}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -9435,5 +9435,11 @@ Element 3</target>
|
|||
<target>Is not (excluding children)</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="7.bq.cZ" name="part.filter.dbId">
|
||||
<segment>
|
||||
<source>part.filter.dbId</source>
|
||||
<target>Database ID</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue