Fix for Category Parameters

This commit is contained in:
Oliver Walters 2025-11-26 00:27:14 +00:00
parent b39c42dfba
commit 2478b08a60
3 changed files with 23 additions and 14 deletions

View File

@ -318,7 +318,7 @@ class CategoryTree(ListAPI):
return queryset
class CategoryParameterList(DataExportViewMixin, ListCreateAPI):
class CategoryParameterList(DataExportViewMixin, OutputOptionsMixin, ListCreateAPI):
"""API endpoint for accessing a list of PartCategoryParameterTemplate objects.
- GET: Return a list of PartCategoryParameterTemplate objects

View File

@ -1745,7 +1745,9 @@ class BomItemSerializer(
@register_importer()
class CategoryParameterTemplateSerializer(
DataImportExportSerializerMixin, InvenTree.serializers.InvenTreeModelSerializer
InvenTree.serializers.FilterableSerializerMixin,
DataImportExportSerializerMixin,
InvenTree.serializers.InvenTreeModelSerializer,
):
"""Serializer for the PartCategoryParameterTemplate model."""
@ -1758,17 +1760,22 @@ class CategoryParameterTemplateSerializer(
'category',
'category_detail',
'template',
# 'parameter_template_detail',
'template_detail',
'default_value',
]
# TODO: Re-implement this, but point to the ParameterTemplate model
# parameter_template_detail = PartParameterTemplateSerializer(
# source='parameter_template', many=False, read_only=True
# )
template_detail = enable_filter(
common.serializers.ParameterTemplateSerializer(
source='template', many=False, read_only=True
),
True,
)
category_detail = CategorySerializer(
source='category', many=False, read_only=True, allow_null=True
category_detail = enable_filter(
CategorySerializer(
source='category', many=False, read_only=True, allow_null=True
),
True,
)

View File

@ -37,7 +37,7 @@ export default function PartCategoryTemplateTable({
value: categoryId,
disabled: categoryId !== undefined
},
parameter_template: {},
template: {},
default_value: {}
};
}, [categoryId]);
@ -83,7 +83,7 @@ export default function PartCategoryTemplateTable({
accessor: 'category_detail.pathstring'
},
{
accessor: 'parameter_template_detail.name',
accessor: 'template_detail.name',
title: t`Parameter Template`,
sortable: true,
switchable: false
@ -99,8 +99,8 @@ export default function PartCategoryTemplateTable({
let units = '';
if (record?.parameter_template_detail?.units) {
units = `[${record.parameter_template_detail.units}]`;
if (record?.template_detail?.units) {
units = `[${record.template_detail.units}]`;
}
return (
@ -162,7 +162,9 @@ export default function PartCategoryTemplateTable({
tableActions: tableActions,
enableDownload: true,
params: {
category: categoryId
category: categoryId,
template_detail: true,
category_detail: true
}
}}
/>