mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1900 from SchrodingersGat/part-image-search
Make the part thumbnail selection window searchable
This commit is contained in:
commit
7911801dbf
@ -338,9 +338,7 @@ class PartThumbs(generics.ListAPIView):
|
|||||||
- Images may be used for multiple parts!
|
- Images may be used for multiple parts!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = self.get_queryset()
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
|
|
||||||
# TODO - We should return the thumbnails here, not the full image!
|
|
||||||
|
|
||||||
# Return the most popular parts first
|
# Return the most popular parts first
|
||||||
data = queryset.values(
|
data = queryset.values(
|
||||||
@ -349,6 +347,19 @@ class PartThumbs(generics.ListAPIView):
|
|||||||
|
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
|
filter_backends = [
|
||||||
|
filters.SearchFilter,
|
||||||
|
]
|
||||||
|
|
||||||
|
search_fields = [
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'IPN',
|
||||||
|
'revision',
|
||||||
|
'keywords',
|
||||||
|
'category__name',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class PartThumbsUpdate(generics.RetrieveUpdateAPIView):
|
class PartThumbsUpdate(generics.RetrieveUpdateAPIView):
|
||||||
""" API endpoint for updating Part thumbnails"""
|
""" API endpoint for updating Part thumbnails"""
|
||||||
|
@ -415,13 +415,16 @@
|
|||||||
// Callback when the image-selection modal form is displayed
|
// Callback when the image-selection modal form is displayed
|
||||||
// Populate the form with image data (requested via AJAX)
|
// Populate the form with image data (requested via AJAX)
|
||||||
|
|
||||||
$("#modal-form").find("#image-select-table").bootstrapTable({
|
$("#modal-form").find("#image-select-table").inventreeTable({
|
||||||
pagination: true,
|
|
||||||
pageSize: 25,
|
|
||||||
url: "{% url 'api-part-thumbs' %}",
|
url: "{% url 'api-part-thumbs' %}",
|
||||||
showHeader: false,
|
showHeader: false,
|
||||||
|
showColumns: false,
|
||||||
clickToSelect: true,
|
clickToSelect: true,
|
||||||
|
sidePagination: 'server',
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
|
formatNoMatches: function() {
|
||||||
|
return '{% trans "No matching images found" %}';
|
||||||
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
checkbox: true,
|
checkbox: true,
|
||||||
@ -429,6 +432,7 @@
|
|||||||
{
|
{
|
||||||
field: 'image',
|
field: 'image',
|
||||||
title: 'Image',
|
title: 'Image',
|
||||||
|
searchable: true,
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
return "<img src='/media/" + value + "' class='grid-image'/>"
|
return "<img src='/media/" + value + "' class='grid-image'/>"
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ $.fn.inventreeTable = function(options) {
|
|||||||
if (!options.disablePagination) {
|
if (!options.disablePagination) {
|
||||||
options.pagination = true;
|
options.pagination = true;
|
||||||
options.paginationVAlign = options.paginationVAlign || 'both';
|
options.paginationVAlign = options.paginationVAlign || 'both';
|
||||||
options.pageSize = inventreeLoad(varName, 25);
|
options.pageSize = options.pageSize || inventreeLoad(varName, 25);
|
||||||
options.pageList = [25, 50, 100, 250, 'all'];
|
options.pageList = [25, 50, 100, 250, 'all'];
|
||||||
options.totalField = 'count';
|
options.totalField = 'count';
|
||||||
options.dataField = 'results';
|
options.dataField = 'results';
|
||||||
|
Loading…
Reference in New Issue
Block a user