mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1833 from SchrodingersGat/part-cat-form-improvements
Part cat form improvements
This commit is contained in:
commit
b1165af3c3
@ -118,9 +118,17 @@ class CategoryList(generics.ListCreateAPIView):
|
||||
|
||||
ordering_fields = [
|
||||
'name',
|
||||
'level',
|
||||
'tree_id',
|
||||
'lft',
|
||||
]
|
||||
|
||||
ordering = 'name'
|
||||
# Use hierarchical ordering by default
|
||||
ordering = [
|
||||
'tree_id',
|
||||
'lft',
|
||||
'name'
|
||||
]
|
||||
|
||||
search_fields = [
|
||||
'name',
|
||||
|
@ -32,6 +32,8 @@ class CategorySerializer(InvenTreeModelSerializer):
|
||||
|
||||
parts = serializers.IntegerField(source='item_count', read_only=True)
|
||||
|
||||
level = serializers.IntegerField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = PartCategory
|
||||
fields = [
|
||||
@ -40,10 +42,11 @@ class CategorySerializer(InvenTreeModelSerializer):
|
||||
'description',
|
||||
'default_location',
|
||||
'default_keywords',
|
||||
'pathstring',
|
||||
'url',
|
||||
'level',
|
||||
'parent',
|
||||
'parts',
|
||||
'pathstring',
|
||||
'url',
|
||||
]
|
||||
|
||||
|
||||
|
@ -363,6 +363,15 @@ class StockLocationList(generics.ListCreateAPIView):
|
||||
ordering_fields = [
|
||||
'name',
|
||||
'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)
|
||||
|
||||
level = serializers.IntegerField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = StockLocation
|
||||
fields = [
|
||||
'pk',
|
||||
'url',
|
||||
'name',
|
||||
'level',
|
||||
'description',
|
||||
'parent',
|
||||
'pathstring',
|
||||
|
@ -67,7 +67,9 @@ function renderStockItem(name, data, parameters, options) {
|
||||
// Renderer for "StockLocation" model
|
||||
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) {
|
||||
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>`;
|
||||
|
||||
if (data.pathstring) {
|
||||
html += `<p><small>${data.pathstring}</small></p>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
@ -154,7 +152,9 @@ function renderOwner(name, data, parameters, options) {
|
||||
// Renderer for "PartCategory" model
|
||||
function renderPartCategory(name, data, parameters, options) {
|
||||
|
||||
var html = `<span><b>${data.name}</b></span>`;
|
||||
var level = '- '.repeat(data.level);
|
||||
|
||||
var html = `<span>${level}${data.pathstring}</span>`;
|
||||
|
||||
if (data.description) {
|
||||
html += ` - <i>${data.description}</i>`;
|
||||
@ -162,10 +162,6 @@ function renderPartCategory(name, data, parameters, options) {
|
||||
|
||||
html += `<span class='float-right'>{% trans "Category ID" %}: ${data.pk}</span>`;
|
||||
|
||||
if (data.pathstring) {
|
||||
html += `<p><small>${data.pathstring}</small></p>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user