mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Improved usability of part select element
This commit is contained in:
parent
7558d57545
commit
64e7ce4ad6
3 changed files with 8 additions and 6 deletions
|
@ -13,12 +13,13 @@ export default class extends Controller {
|
||||||
let settings = {
|
let settings = {
|
||||||
allowEmptyOption: true,
|
allowEmptyOption: true,
|
||||||
plugins: ['dropdown_input'],
|
plugins: ['dropdown_input'],
|
||||||
searchField: "name",
|
searchField: ["name", "description", "category", "footprint"],
|
||||||
valueField: "id",
|
valueField: "id",
|
||||||
labelField: "name",
|
labelField: "name",
|
||||||
|
preload: "focus",
|
||||||
render: {
|
render: {
|
||||||
item: (data, escape) => {
|
item: (data, escape) => {
|
||||||
return '<span>' + (data.image ? "<img style='height: 1.5rem;' ' src='" + data.image + "'/>" : "") + escape(data.name) + '</span>';
|
return '<span>' + (data.image ? "<img style='height: 1.5rem; margin-right: 5px;' ' src='" + data.image + "'/>" : "") + escape(data.name) + '</span>';
|
||||||
},
|
},
|
||||||
option: (data, escape) => {
|
option: (data, escape) => {
|
||||||
if(data.text) {
|
if(data.text) {
|
||||||
|
|
|
@ -136,14 +136,14 @@ class TypeaheadController extends AbstractController
|
||||||
* @param EntityManagerInterface $entityManager
|
* @param EntityManagerInterface $entityManager
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function parts(string $query, EntityManagerInterface $entityManager, PartPreviewGenerator $previewGenerator,
|
public function parts(EntityManagerInterface $entityManager, PartPreviewGenerator $previewGenerator,
|
||||||
AttachmentURLGenerator $attachmentURLGenerator): JsonResponse
|
AttachmentURLGenerator $attachmentURLGenerator, string $query = ""): JsonResponse
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('@parts.read');
|
$this->denyAccessUnlessGranted('@parts.read');
|
||||||
|
|
||||||
$repo = $entityManager->getRepository(Part::class);
|
$repo = $entityManager->getRepository(Part::class);
|
||||||
|
|
||||||
$parts = $repo->autocompleteSearch($query);
|
$parts = $repo->autocompleteSearch($query, 100);
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
|
|
|
@ -72,11 +72,12 @@ class PartRepository extends NamedDBElementRepository
|
||||||
$qb = $this->createQueryBuilder('part');
|
$qb = $this->createQueryBuilder('part');
|
||||||
$qb->select('part')
|
$qb->select('part')
|
||||||
->leftJoin('part.category', 'category')
|
->leftJoin('part.category', 'category')
|
||||||
|
->leftJoin('part.footprint', 'footprint')
|
||||||
|
|
||||||
->where('part.name LIKE :query')
|
->where('part.name LIKE :query')
|
||||||
->orWhere('part.description LIKE :query')
|
->orWhere('part.description LIKE :query')
|
||||||
->orWhere('category.name LIKE :query')
|
->orWhere('category.name LIKE :query')
|
||||||
|
->orWhere('footprint.name LIKE :query')
|
||||||
;
|
;
|
||||||
|
|
||||||
$qb->setParameter('query', '%'.$query.'%');
|
$qb->setParameter('query', '%'.$query.'%');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue