mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Ordering and rendering for StockLocation
This commit is contained in:
parent
36cf614aed
commit
753fe9c80f
@ -363,6 +363,15 @@ class StockLocationList(generics.ListCreateAPIView):
|
|||||||
ordering_fields = [
|
ordering_fields = [
|
||||||
'name',
|
'name',
|
||||||
'items',
|
'items',
|
||||||
|
'level',
|
||||||
|
'tree_id',
|
||||||
|
'lft',
|
||||||
|
]
|
||||||
|
|
||||||
|
ordering = [
|
||||||
|
'tree_id',
|
||||||
|
'lft',
|
||||||
|
'name',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,12 +260,15 @@ class LocationSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
items = serializers.IntegerField(source='item_count', read_only=True)
|
items = serializers.IntegerField(source='item_count', read_only=True)
|
||||||
|
|
||||||
|
level = serializers.IntegerField(read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockLocation
|
model = StockLocation
|
||||||
fields = [
|
fields = [
|
||||||
'pk',
|
'pk',
|
||||||
'url',
|
'url',
|
||||||
'name',
|
'name',
|
||||||
|
'level',
|
||||||
'description',
|
'description',
|
||||||
'parent',
|
'parent',
|
||||||
'pathstring',
|
'pathstring',
|
||||||
|
@ -67,7 +67,9 @@ function renderStockItem(name, data, parameters, options) {
|
|||||||
// Renderer for "StockLocation" model
|
// Renderer for "StockLocation" model
|
||||||
function renderStockLocation(name, data, parameters, options) {
|
function renderStockLocation(name, data, parameters, options) {
|
||||||
|
|
||||||
var html = `<span>${data.name}</span>`;
|
var level = '-'.repeat(data.level);
|
||||||
|
|
||||||
|
var html = `<span>${level} ${data.pathstring}</span>`;
|
||||||
|
|
||||||
if (data.description) {
|
if (data.description) {
|
||||||
html += ` - <i>${data.description}</i>`;
|
html += ` - <i>${data.description}</i>`;
|
||||||
@ -75,10 +77,6 @@ function renderStockLocation(name, data, parameters, options) {
|
|||||||
|
|
||||||
html += `<span class='float-right'>{% trans "Location ID" %}: ${data.pk}</span>`;
|
html += `<span class='float-right'>{% trans "Location ID" %}: ${data.pk}</span>`;
|
||||||
|
|
||||||
if (data.pathstring) {
|
|
||||||
html += `<p><small>${data.pathstring}</small></p>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user