Merge pull request #1833 from SchrodingersGat/part-cat-form-improvements

Part cat form improvements
This commit is contained in:
Oliver 2021-07-18 21:32:31 +10:00 committed by GitHub
commit b1165af3c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 13 deletions

View File

@ -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',

View File

@ -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',
]

View File

@ -363,6 +363,15 @@ class StockLocationList(generics.ListCreateAPIView):
ordering_fields = [
'name',
'items',
'level',
'tree_id',
'lft',
]
ordering = [
'tree_id',
'lft',
'name',
]

View File

@ -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',

View File

@ -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;
}