Skip to content

Commit 4e7e369

Browse files
committed
Added search option for part.id
1 parent 98b8c5b commit 4e7e369

File tree

5 files changed

+11209
-21233
lines changed

5 files changed

+11209
-21233
lines changed

src/Controller/PartListsController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ private function searchRequestToFilter(Request $request): PartSearchFilter
319319

320320
//As an unchecked checkbox is not set in the query, the default value for all bools have to be false (which is the default argument value)!
321321
$filter->setName($request->query->getBoolean('name'));
322+
$filter->setDbId($request->query->getBoolean('dbid'));
322323
$filter->setCategory($request->query->getBoolean('category'));
323324
$filter->setDescription($request->query->getBoolean('description'));
324325
$filter->setMpn($request->query->getBoolean('mpn'));

src/DataTables/Filters/PartSearchFilter.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class PartSearchFilter implements FilterInterface
3333
/** @var bool Use name field for searching */
3434
protected bool $name = true;
3535

36+
/** @var bool Use id field for searching */
37+
protected bool $dbId = true;
38+
3639
/** @var bool Use category name for searching */
3740
protected bool $category = true;
3841

@@ -80,6 +83,9 @@ protected function getFieldsToSearch(): array
8083
if($this->name) {
8184
$fields_to_search[] = 'part.name';
8285
}
86+
if($this->dbId) {
87+
$fields_to_search[] = 'part.id';
88+
}
8389
if($this->category) {
8490
$fields_to_search[] = '_category.name';
8591
}
@@ -183,6 +189,17 @@ public function setName(bool $name): PartSearchFilter
183189
return $this;
184190
}
185191

192+
public function isDbId(): bool
193+
{
194+
return $this->dbId;
195+
}
196+
197+
public function setDbId(bool $dbId): PartSearchFilter
198+
{
199+
$this->dbId = $dbId;
200+
return $this;
201+
}
202+
186203
public function isCategory(): bool
187204
{
188205
return $this->category;

templates/components/search.macro.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
<input type="checkbox" class="form-check-input" id="search_name" name="name" value="1" checked {{ stimulus_controller('elements/localStorage_checkbox') }}>
1212
<label for="search_name" class="form-check-label justify-content-start">{% trans %}name.label{% endtrans %}</label>
1313
</div>
14+
<div class="form-check">
15+
<input type="checkbox" class="form-check-input" id="search_dbid" name="dbid" value="1" checked {{ stimulus_controller('elements/localStorage_checkbox') }}>
16+
<label for="search_dbid" class="form-check-label justify-content-start">{% trans %}id.label{% endtrans %}</label>
17+
</div>
1418
<div class="form-check">
1519
<input type="checkbox" class="form-check-input" id="search_category" name="category" value="1" checked {{ stimulus_controller('elements/localStorage_checkbox') }}>
1620
<label for="search_category" class="form-check-label justify-content-start">{% trans %}category.label{% endtrans %}</label>

0 commit comments

Comments
 (0)