mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-03 05:55:16 +01:00
Allow tags to contain any character and only show exact matching parts.
This commit is contained in:
@@ -203,12 +203,13 @@ class PartListsController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/parts/by_tag/{tag}", name="part_list_tags")
|
||||
* @Route("/parts/by_tag/{tag}", name="part_list_tags", requirements={"tag": ".*"})
|
||||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showTag(string $tag, Request $request, DataTableFactory $dataTable)
|
||||
{
|
||||
$tag = trim($tag);
|
||||
$table = $dataTable->createFromType(PartsDataTable::class, ['tag' => $tag])
|
||||
->handleRequest($request);
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ final class PartsDataTable implements DataTableTypeInterface
|
||||
}
|
||||
|
||||
if (isset($options['tag'])) {
|
||||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%');
|
||||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', $options['tag']);
|
||||
}
|
||||
|
||||
if (!empty($options['search'])) {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
{% macro string_to_tags(string, class="badge bg-info") %}
|
||||
{% for tag in string|split(',') %}
|
||||
<a href="{{ url('part_list_tags', {'tag': tag | trim}) }}" class="{{ class }}" >{{ tag | trim }}</a>
|
||||
<a href="{{ url('part_list_tags', {'tag': tag | trim | url_encode}) }}" class="{{ class }}" >{{ tag | trim }}</a>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user