sort fields by label.
This commit is contained in:
@@ -12,12 +12,24 @@ export interface PluginContext {
|
||||
lookupFields: KintoneFormFieldProperty.Lookup[];
|
||||
}
|
||||
|
||||
const naturalCompare = (a: string, b: string): number => {
|
||||
const locales = new Set<string>([...navigator.languages, 'en-US', 'ja-JP']);
|
||||
return new Intl.Collator(Array.from(locales), {
|
||||
sensitivity: 'variant',
|
||||
numeric: true,
|
||||
}).compare(a, b);
|
||||
};
|
||||
|
||||
const filterAttachmentFields = (properties: KintoneFormFieldProperties): KintoneFormFieldProperty.File[] => {
|
||||
return Object.values(properties).filter((property) => property.type === 'FILE');
|
||||
return Object.values(properties)
|
||||
.filter((property) => property.type === 'FILE')
|
||||
.sort((a, b) => naturalCompare(a.label, b.label));
|
||||
};
|
||||
|
||||
const filterLookupFields = (properties: KintoneFormFieldProperties): KintoneFormFieldProperty.Lookup[] => {
|
||||
return Object.values(properties).filter((property) => 'lookup' in property);
|
||||
return Object.values(properties)
|
||||
.filter((property) => 'lookup' in property)
|
||||
.sort((a, b) => naturalCompare(a.label, b.label));
|
||||
};
|
||||
|
||||
const getFormFieldsProperties = async (appId: KintoneAppId): Promise<KintoneFormFieldProperties> => {
|
||||
|
Reference in New Issue
Block a user