mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-17 17:40:31 +08:00
fix: use advance instead of basic and put it at the bottom
This commit is contained in:
parent
eb58535565
commit
0aa55c7ad0
@ -12,17 +12,17 @@ import {
|
|||||||
Accordion,
|
Accordion,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
|
|
||||||
type ExpandedSpec = {
|
type ExpandSpec = {
|
||||||
category?: string;
|
category?: string;
|
||||||
weight?: string;
|
weight?: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Property = Record<string, JSONSchema7 & ExpandedSpec>;
|
type Property = Record<string, JSONSchema7 & ExpandSpec>;
|
||||||
|
|
||||||
type Category = {
|
type Category = {
|
||||||
name: string;
|
name: string;
|
||||||
schemas: (JSONSchema7 & ExpandedSpec)[];
|
schemas: (JSONSchema7 & ExpandSpec)[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const TopLevelField: React.FC<FieldProps> = props => {
|
const TopLevelField: React.FC<FieldProps> = props => {
|
||||||
@ -34,12 +34,23 @@ const TopLevelField: React.FC<FieldProps> = props => {
|
|||||||
const schema = properties[name];
|
const schema = properties[name];
|
||||||
schema.name = name;
|
schema.name = name;
|
||||||
});
|
});
|
||||||
const grouped = groupBy(properties, c => c.category || 'Basic');
|
const grouped = groupBy(properties, c => c.category || 'Advance');
|
||||||
|
|
||||||
return Object.keys(grouped).map(name => ({
|
const advance = grouped.Advance;
|
||||||
|
Reflect.deleteProperty(grouped, 'Advance');
|
||||||
|
|
||||||
|
const categories = Object.keys(grouped).map(name => ({
|
||||||
name,
|
name,
|
||||||
schemas: sortBy(grouped[name],'weight'),
|
schemas: sortBy(grouped[name], c => -(c.weight ?? -Infinity)),
|
||||||
}));
|
}));
|
||||||
|
if (advance) {
|
||||||
|
categories.push({
|
||||||
|
name: 'Advance',
|
||||||
|
schemas: sortBy(advance, c => -(c.weight ?? -Infinity)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return categories;
|
||||||
}, [schema.properties]);
|
}, [schema.properties]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user