Added option to search in internal part number (enabled by default)

This should fix issue #232
This commit is contained in:
Jan Böhmer 2023-03-04 22:53:36 +01:00
parent 0efb32c891
commit 222e76ce47
3 changed files with 25 additions and 3 deletions

View file

@ -294,6 +294,7 @@ class PartListsController extends AbstractController
$filter->setTags($request->query->getBoolean('tags', true));
$filter->setStorelocation($request->query->getBoolean('storelocation', true));
$filter->setComment($request->query->getBoolean('comment', true));
$filter->setIPN($request->query->getBoolean('ipn', true));
$filter->setOrdernr($request->query->getBoolean('ordernr', true));
$filter->setSupplier($request->query->getBoolean('supplier', false));
$filter->setManufacturer($request->query->getBoolean('manufacturer', false));

View file

@ -65,6 +65,9 @@ class PartSearchFilter implements FilterInterface
/** @var bool Use footprint name for searching */
protected bool $footprint = false;
/** @var bool Use Internal Part number for searching */
protected bool $ipn = true;
public function __construct(string $query)
{
$this->keyword = $query;
@ -104,6 +107,9 @@ class PartSearchFilter implements FilterInterface
if($this->footprint) {
$fields_to_search[] = 'footprint.name';
}
if ($this->ipn) {
$fields_to_search[] = 'part.ipn';
}
return $fields_to_search;
}
@ -301,6 +307,17 @@ class PartSearchFilter implements FilterInterface
return $this;
}
public function isIPN(): bool
{
return $this->ipn;
}
public function setIPN(bool $ipn): PartSearchFilter
{
$this->ipn = $ipn;
return $this;
}
/**
* @return bool
*/