From fb583885042c79f4cfdfff21ffa220bceba8aca5 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 21 Nov 2023 20:21:02 -0300 Subject: [PATCH] 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. --- src/frontend/src/CustomNodes/GenericNode/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 2b6661a83..c1a6f2f3f 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -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) => (
{data.node!.template[templateField].show &&