fix(GenericNode): sort template fields alphabetically with special handling for "code" field to be displayed first

The changes in this commit fix the sorting of template fields in the GenericNode component. Previously, the fields were sorted alphabetically, but with this change, the "code" field is prioritized and displayed first. This change improves the user experience by making the "code" field more prominent and easily accessible.
This commit is contained in:
anovazzi1 2023-11-21 20:21:02 -03:00
commit fb58388504

View file

@ -417,7 +417,15 @@ export default function GenericNode({
<>
{Object.keys(data.node!.template)
.filter((templateField) => templateField.charAt(0) !== "_")
.sort()
.sort((a, b) => {
if (a.toLowerCase() === "code") {
return -1;
} else if (b.toLowerCase() === "code") {
return 1;
} else {
return a.localeCompare(b);
}
})
.map((templateField: string, idx) => (
<div key={idx}>
{data.node!.template[templateField].show &&