mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-10 05:40:55 +00:00
Fix API to match existing frontend type StatusCodeListInterface
This commit is contained in:
@@ -70,7 +70,7 @@ class StatusView(GenericAPIView):
|
|||||||
if not issubclass(status_class, StatusCode):
|
if not issubclass(status_class, StatusCode):
|
||||||
raise NotImplementedError('`status_class` not a valid StatusCode class')
|
raise NotImplementedError('`status_class` not a valid StatusCode class')
|
||||||
|
|
||||||
data = {'class_name': status_class.__name__, 'values': status_class.dict()}
|
data = {'status_class': status_class.__name__, 'values': status_class.dict()}
|
||||||
|
|
||||||
# Extend with custom values
|
# Extend with custom values
|
||||||
try:
|
try:
|
||||||
@@ -108,7 +108,7 @@ class AllStatusViews(StatusView):
|
|||||||
status_classes = inheritors(StatusCode)
|
status_classes = inheritors(StatusCode)
|
||||||
|
|
||||||
for cls in status_classes:
|
for cls in status_classes:
|
||||||
cls_data = {'class_name': cls.__name__, 'values': cls.dict()}
|
cls_data = {'status_class': cls.__name__, 'values': cls.dict()}
|
||||||
|
|
||||||
# Extend with custom values
|
# Extend with custom values
|
||||||
for item in cls.custom_values():
|
for item in cls.custom_values():
|
||||||
|
@@ -30,9 +30,9 @@ class GenericStateClassSerializer(serializers.Serializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
"""Meta class for GenericStateClassSerializer."""
|
"""Meta class for GenericStateClassSerializer."""
|
||||||
|
|
||||||
fields = ['class_name', 'values']
|
fields = ['status_class', 'values']
|
||||||
|
|
||||||
class_name = serializers.CharField(label=_('Class'), read_only=True)
|
status_class = serializers.CharField(label=_('Class'), read_only=True)
|
||||||
|
|
||||||
values = serializers.DictField(
|
values = serializers.DictField(
|
||||||
child=GenericStateValueSerializer(), label=_('Values'), required=True
|
child=GenericStateValueSerializer(), label=_('Values'), required=True
|
||||||
|
@@ -13,7 +13,7 @@ export interface StatusCodeInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface StatusCodeListInterface {
|
export interface StatusCodeListInterface {
|
||||||
statusClass: string;
|
status_class: string;
|
||||||
values: {
|
values: {
|
||||||
[key: string]: StatusCodeInterface;
|
[key: string]: StatusCodeInterface;
|
||||||
};
|
};
|
||||||
|
@@ -30,7 +30,7 @@ export function useCustomStateFields(): ApiFormFieldSet {
|
|||||||
const options: any[] = [];
|
const options: any[] = [];
|
||||||
|
|
||||||
const valuesList = Object.values(statusCodes.status ?? {}).find(
|
const valuesList = Object.values(statusCodes.status ?? {}).find(
|
||||||
(value: StatusCodeListInterface) => value.statusClass === statusClass
|
(value: StatusCodeListInterface) => value.status_class === statusClass
|
||||||
);
|
);
|
||||||
|
|
||||||
Object.values(valuesList?.values ?? {}).forEach(
|
Object.values(valuesList?.values ?? {}).forEach(
|
||||||
|
@@ -36,7 +36,7 @@ export default function CustomStateTable() {
|
|||||||
const getLogicalState = useCallback(
|
const getLogicalState = useCallback(
|
||||||
(group: string, key: number) => {
|
(group: string, key: number) => {
|
||||||
const valuesList = Object.values(statusCodes.status ?? {}).find(
|
const valuesList = Object.values(statusCodes.status ?? {}).find(
|
||||||
(value: StatusCodeListInterface) => value.statusClass === group
|
(value: StatusCodeListInterface) => value.status_class === group
|
||||||
);
|
);
|
||||||
|
|
||||||
const value = Object.values(valuesList?.values ?? {}).find(
|
const value = Object.values(valuesList?.values ?? {}).find(
|
||||||
|
Reference in New Issue
Block a user