mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-13 21:59:34 +00:00
Assembly-Filter und -Tab ergänzen
Fügt Unterstützung für Assembly-Filter in der Suche sowie ein neues Tab für Assemblies in der Filteransicht hinzu. Anpassungen beinhalten Änderungen an Datenbankabfragen, Formularen und Templates.
This commit is contained in:
parent
980657eec4
commit
07d4ffa956
7 changed files with 75 additions and 3 deletions
|
|
@ -330,7 +330,7 @@ class PartListsController extends AbstractController
|
|||
$filter->setSupplier($request->query->getBoolean('supplier'));
|
||||
$filter->setManufacturer($request->query->getBoolean('manufacturer'));
|
||||
$filter->setFootprint($request->query->getBoolean('footprint'));
|
||||
|
||||
$filter->setAssembly($request->query->getBoolean('assembly'));
|
||||
|
||||
$filter->setRegex($request->query->getBoolean('regex'));
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ use App\DataTables\Filters\Constraints\Part\LessThanDesiredConstraint;
|
|||
use App\DataTables\Filters\Constraints\Part\ParameterConstraint;
|
||||
use App\DataTables\Filters\Constraints\Part\TagsConstraint;
|
||||
use App\DataTables\Filters\Constraints\TextConstraint;
|
||||
use App\Entity\AssemblySystem\Assembly;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
|
|
@ -107,6 +108,14 @@ class PartFilter implements FilterInterface
|
|||
public readonly TextConstraint $bomName;
|
||||
public readonly TextConstraint $bomComment;
|
||||
|
||||
/*************************************************
|
||||
* Assembly
|
||||
*************************************************/
|
||||
|
||||
public readonly EntityConstraint $assembly;
|
||||
public readonly NumberConstraint $assemblyBomQuantity;
|
||||
public readonly TextConstraint $assemblyBomName;
|
||||
|
||||
/*************************************************
|
||||
* Bulk Import Job tab
|
||||
*************************************************/
|
||||
|
|
@ -180,6 +189,10 @@ class PartFilter implements FilterInterface
|
|||
$this->bomName = new TextConstraint('_projectBomEntries.name');
|
||||
$this->bomComment = new TextConstraint('_projectBomEntries.comment');
|
||||
|
||||
$this->assembly = new EntityConstraint($nodesListBuilder, Assembly::class, '_assemblyBomEntries.assembly');
|
||||
$this->assemblyBomQuantity = new NumberConstraint('_assemblyBomEntries.quantity');
|
||||
$this->assemblyBomName = new TextConstraint('_assemblyBomEntries.name');
|
||||
|
||||
// Bulk Import Job filters
|
||||
$this->inBulkImportJob = new BulkImportJobExistsConstraint();
|
||||
$this->bulkImportJobStatus = new BulkImportJobStatusConstraint();
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ class PartSearchFilter implements FilterInterface
|
|||
/** @var bool Use Internal Part number for searching */
|
||||
protected bool $ipn = true;
|
||||
|
||||
/** @var bool Use assembly name for searching */
|
||||
protected bool $assembly = true;
|
||||
|
||||
public function __construct(
|
||||
/** @var string The string to query for */
|
||||
protected string $keyword
|
||||
|
|
@ -113,6 +116,9 @@ class PartSearchFilter implements FilterInterface
|
|||
if ($this->ipn) {
|
||||
$fields_to_search[] = 'part.ipn';
|
||||
}
|
||||
if ($this->assembly) {
|
||||
$fields_to_search[] = '_assembly.name';
|
||||
}
|
||||
|
||||
return $fields_to_search;
|
||||
}
|
||||
|
|
@ -304,5 +310,14 @@ class PartSearchFilter implements FilterInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function isAssembly(): bool
|
||||
{
|
||||
return $this->assembly;
|
||||
}
|
||||
|
||||
public function setAssembly(bool $assembly): PartSearchFilter
|
||||
{
|
||||
$this->assembly = $assembly;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -474,6 +474,13 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
//Do not group by many-to-* relations, as it would restrict the COUNT having clauses to be maximum 1
|
||||
//$builder->addGroupBy('_projectBomEntries');
|
||||
}
|
||||
if (str_contains($dql, '_assembly.')) {
|
||||
$builder->leftJoin('part.assembly_bom_entries', '_assemblyBomEntries');
|
||||
$builder->leftJoin('_assemblyBomEntries.assembly', '_assembly');
|
||||
}
|
||||
if (str_contains($dql, '_assemblyBomEntries')) {
|
||||
$builder->leftJoin('part.assembly_bom_entries', '_assemblyBomEntries');
|
||||
}
|
||||
if (str_contains($dql, '_jobPart')) {
|
||||
$builder->leftJoin('part.bulkImportJobParts', '_jobPart');
|
||||
$builder->leftJoin('_jobPart.job', '_bulkImportJob');
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ namespace App\Form\Filters;
|
|||
use App\DataTables\Filters\Constraints\Part\BulkImportPartStatusConstraint;
|
||||
use App\DataTables\Filters\Constraints\Part\ParameterConstraint;
|
||||
use App\DataTables\Filters\PartFilter;
|
||||
use App\Entity\AssemblySystem\Assembly;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\InfoProviderSystem\BulkImportJobStatus;
|
||||
use App\Entity\InfoProviderSystem\BulkImportPartStatus;
|
||||
|
|
@ -313,6 +314,26 @@ class PartFilterType extends AbstractType
|
|||
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Assembly tab
|
||||
**************************************************************************/
|
||||
if ($this->security->isGranted('read', Assembly::class)) {
|
||||
$builder
|
||||
->add('assembly', StructuralEntityConstraintType::class, [
|
||||
'label' => 'assembly.label',
|
||||
'entity_class' => Assembly::class
|
||||
])
|
||||
->add('assemblyBomQuantity', NumberConstraintType::class, [
|
||||
'label' => 'assembly.bom.quantity',
|
||||
'min' => 0,
|
||||
'step' => "any",
|
||||
])
|
||||
->add('assemblyBomName', TextConstraintType::class, [
|
||||
'label' => 'assembly.bom.name',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Bulk Import Job tab
|
||||
**************************************************************************/
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@
|
|||
<label for="search_footprint" class="form-check-label justify-content-start">{% trans %}footprint.label{% endtrans %}</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="search_assembly" name="assembly" value="1" {{ stimulus_controller('elements/localStorage_checkbox') }}>
|
||||
<label for="search_assembly" class="form-check-label justify-content-start">{% trans %}assembly.label{% endtrans %}</label>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="regex" name="regex" value="1" {{ stimulus_controller('elements/localStorage_checkbox') }}>
|
||||
|
|
@ -102,4 +106,4 @@
|
|||
{{ _self.settings_drodown(is_navbar) }}
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endmacro %}
|
||||
{% endmacro %}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@
|
|||
<button class="nav-link" id="filter-projects-tab" data-bs-toggle="tab" data-bs-target="#filter-projects"><i class="fas fa-archive fa-fw"></i> {% trans %}project.labelp{% endtrans %}</button>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if filterForm.assembly is defined %}
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="filter-assemblies-tab" data-bs-toggle="tab" data-bs-target="#filter-assemblies"><i class="fas fa-archive fa-fw"></i> {% trans %}assembly.labelp{% endtrans %}</button>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if filterForm.inBulkImportJob is defined %}
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="filter-bulk-import-tab" data-bs-toggle="tab" data-bs-target="#filter-bulk-import"><i class="fas fa-download fa-fw"></i> {% trans %}part.edit.tab.bulk_import{% endtrans %}</button>
|
||||
|
|
@ -132,6 +137,13 @@
|
|||
{{ form_row(filterForm.bomComment) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if filterForm.assembly is defined %}
|
||||
<div class="tab-pane pt-3" id="filter-assemblies" role="tabpanel" aria-labelledby="filter-assemblies-tab" tabindex="0">
|
||||
{{ form_row(filterForm.assembly) }}
|
||||
{{ form_row(filterForm.assemblyBomQuantity) }}
|
||||
{{ form_row(filterForm.assemblyBomName) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if filterForm.inBulkImportJob is defined %}
|
||||
<div class="tab-pane pt-3" id="filter-bulk-import" role="tabpanel" aria-labelledby="filter-bulk-import-tab" tabindex="0">
|
||||
{{ form_row(filterForm.inBulkImportJob) }}
|
||||
|
|
@ -163,4 +175,4 @@
|
|||
{{ form_end(filterForm) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue