2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 05:46:34 +00:00

Make the part thumbnail selection window searchable

This commit is contained in:
Oliver
2021-08-04 12:10:49 +10:00
parent 8daf601f00
commit f95346f214
3 changed files with 21 additions and 7 deletions

View File

@ -338,9 +338,7 @@ class PartThumbs(generics.ListAPIView):
- Images may be used for multiple parts!
"""
queryset = self.get_queryset()
# TODO - We should return the thumbnails here, not the full image!
queryset = self.filter_queryset(self.get_queryset())
# Return the most popular parts first
data = queryset.values(
@ -349,6 +347,18 @@ class PartThumbs(generics.ListAPIView):
return Response(data)
filter_backends = [
filters.SearchFilter,
]
search_fields = [
'name',
'description',
'IPN',
'revision',
'keywords',
'category__name',
]
class PartThumbsUpdate(generics.RetrieveUpdateAPIView):
""" API endpoint for updating Part thumbnails"""

View File

@ -415,13 +415,16 @@
// Callback when the image-selection modal form is displayed
// Populate the form with image data (requested via AJAX)
$("#modal-form").find("#image-select-table").bootstrapTable({
pagination: true,
pageSize: 25,
$("#modal-form").find("#image-select-table").inventreeTable({
url: "{% url 'api-part-thumbs' %}",
showHeader: false,
showColumns: false,
clickToSelect: true,
sidePagination: 'server',
singleSelect: true,
formatNoMatches: function() {
return '{% trans "No matching images found" %}';
},
columns: [
{
checkbox: true,
@ -429,6 +432,7 @@
{
field: 'image',
title: 'Image',
searchable: true,
formatter: function(value, row, index, field) {
return "<img src='/media/" + value + "' class='grid-image'/>"
}