Refactor the React OpenAPI admin framework to support fully customizable field rendering and UI composition. #11
@@ -124,17 +124,10 @@ function extractOptions(
|
|||||||
|
|
||||||
if (field.enumOption?.value) return resolveTemplate(field.enumOption.value, item);
|
if (field.enumOption?.value) return resolveTemplate(field.enumOption.value, item);
|
||||||
|
|
||||||
if (fieldName == 'payee') debugger;
|
// Use displayFormat if defined, otherwise fall back to displayField logic (for backward compatibility)
|
||||||
const df = field.displayField;
|
if (field.displayFormat) {
|
||||||
if (!df) return null;
|
return resolveTemplate(field.displayFormat, item);
|
||||||
|
|
||||||
if (Array.isArray(df)) {
|
|
||||||
const parts = df.map((k) => item[k]).filter((v) => v != null);
|
|
||||||
if (parts.length > 0) return parts.join(" ");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
const v = item[df];
|
|
||||||
if (v != null) return String(v);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ export interface EnumOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ResourceField {
|
export interface ResourceField {
|
||||||
|
displayFormat: string;
|
||||||
type: FieldType;
|
type: FieldType;
|
||||||
label: string;
|
label: string;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
options?: string[];
|
options?: string[];
|
||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
schema?: Record<string, ResourceField>;
|
schema?: Record<string, ResourceField>;
|
||||||
displayField?: string | string[];
|
|
||||||
formatter?: (value: any) => string;
|
formatter?: (value: any) => string;
|
||||||
relation?: string;
|
relation?: string;
|
||||||
filterType?: "autocomplete" | "multiselect" | "number-range" | "date-range";
|
filterType?: "autocomplete" | "multiselect" | "number-range" | "date-range";
|
||||||
|
|||||||
Reference in New Issue
Block a user