mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Display a part as 'starred' in the part table
This commit is contained in:
parent
b850beb687
commit
124fab3eee
@ -147,6 +147,10 @@ function loadPartTable(table, url, options={}) {
|
|||||||
display += `<span class='fas fa-tools label-right' title='Assembled part'></span>`;
|
display += `<span class='fas fa-tools label-right' title='Assembled part'></span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (row.starred) {
|
||||||
|
display += `<span class='fas fa-star label-right' title='Starred part'></span>`;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (row.component) {
|
if (row.component) {
|
||||||
display = display + `<span class='fas fa-cogs label-right' title='Component part'></span>`;
|
display = display + `<span class='fas fa-cogs label-right' title='Component part'></span>`;
|
||||||
|
@ -258,12 +258,18 @@ class PartList(generics.ListCreateAPIView):
|
|||||||
# Filter items which have an 'in_stock' level higher than 'minimum_stock'
|
# Filter items which have an 'in_stock' level higher than 'minimum_stock'
|
||||||
data = data.filter(Q(in_stock__gte=F('minimum_stock')))
|
data = data.filter(Q(in_stock__gte=F('minimum_stock')))
|
||||||
|
|
||||||
|
# Get a list of the parts that this user has starred
|
||||||
|
starred_parts = [star.part.pk for star in self.request.user.starred_parts.all()]
|
||||||
|
|
||||||
# Reduce the number of lookups we need to do for the part categories
|
# Reduce the number of lookups we need to do for the part categories
|
||||||
categories = {}
|
categories = {}
|
||||||
|
|
||||||
for item in data:
|
for item in data:
|
||||||
|
|
||||||
if item['image']:
|
if item['image']:
|
||||||
|
# Is this part 'starred' for the current user?
|
||||||
|
item['starred'] = item['pk'] in starred_parts
|
||||||
|
|
||||||
img = item['image']
|
img = item['image']
|
||||||
|
|
||||||
# Use the 'thumbnail' image here instead of the full-size image
|
# Use the 'thumbnail' image here instead of the full-size image
|
||||||
|
Loading…
Reference in New Issue
Block a user