add sort condition by field code

This commit is contained in:
2025-06-26 20:09:43 +09:00
parent 2d84e24d61
commit 03f3d2fcb0

View File

@@ -23,13 +23,13 @@ const naturalCompare = (a: string, b: string): number => {
const filterAttachmentFields = (properties: KintoneFormFieldProperties): KintoneFormFieldProperty.File[] => {
return Object.values(properties)
.filter((property) => property.type === 'FILE')
.sort((a, b) => naturalCompare(a.label, b.label));
.sort((a, b) => naturalCompare(`${a.label} (${a.code})`, `${b.label} (${b.code})`));
};
const filterLookupFields = (properties: KintoneFormFieldProperties): KintoneFormFieldProperty.Lookup[] => {
return Object.values(properties)
.filter((property) => 'lookup' in property)
.sort((a, b) => naturalCompare(a.label, b.label));
.sort((a, b) => naturalCompare(`${a.label} (${a.code})`, `${b.label} (${b.code})`));
};
const getFormFieldsProperties = async (appId: KintoneAppId): Promise<KintoneFormFieldProperties> => {