cleanup
This commit is contained in:
@@ -124,6 +124,7 @@ function extractOptions(
|
||||
|
||||
if (field.enumOption?.value) return resolveTemplate(field.enumOption.value, item);
|
||||
|
||||
if (fieldName == 'payee') debugger;
|
||||
const df = field.displayField;
|
||||
if (!df) return null;
|
||||
|
||||
@@ -294,7 +295,7 @@ export default function FilterBar({
|
||||
const field = fields[fieldName];
|
||||
if (!field) return null;
|
||||
|
||||
const needsOptions = !field.filterType || field.filterType === "autocomplete" || field.filterType === "multiselect";
|
||||
const needsOptions = field.filterType === "autocomplete" || field.filterType === "multiselect";
|
||||
const options = needsOptions ? extractOptions(fieldName, field, data ?? []) : [];
|
||||
const raw = draft[fieldName];
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ export default function ResourceView({ config, onNavigateToResource, fieldCompon
|
||||
const { useList, useRead, useCreate, useUpdate, useDelete, components } = useResource(config, { fieldComponents });
|
||||
|
||||
const queryParams = React.useMemo(() => {
|
||||
if (!isServer) return { limit: 10000 };
|
||||
if (!isServer) return { limit: 10 };
|
||||
return {
|
||||
skip: paginationModel.page * paginationModel.pageSize,
|
||||
limit: paginationModel.pageSize,
|
||||
|
||||
@@ -65,6 +65,7 @@ function parseSchemaFields(
|
||||
const fields: Record<string, ResourceField> = {};
|
||||
const { properties, required } = mergeProperties(schema);
|
||||
const overrides = configuration[resourceName]?.fields || {};
|
||||
console.log('inside parseSchemaFields configuration...', configuration['accounts']['referenceOptions'])
|
||||
|
||||
for (const [key, prop] of Object.entries(properties) as [string, any]) {
|
||||
// Resolve oneOf/anyOf by merging all branch properties
|
||||
@@ -115,23 +116,24 @@ function parseSchemaFields(
|
||||
fields[key].relation = relation;
|
||||
|
||||
// Propagate enumOption from target resource config, or derive from target schema
|
||||
const explicitEnumOption = configuration[relation]?.enumOption;
|
||||
const explicitEnumOption = configuration[relation].referenceOptions.enumOption;
|
||||
console.log('if relation configuration...', configuration['accounts']['referenceOptions'])
|
||||
if (explicitEnumOption) {
|
||||
fields[key].enumOption = explicitEnumOption;
|
||||
} else {
|
||||
const targetProps = targetSchema.properties || {};
|
||||
const valueField = Object.entries(targetProps).find(
|
||||
([name, p]: [string, any]) => name !== 'id' && p.type === 'string'
|
||||
)?.[0];
|
||||
fields[key].enumOption = {
|
||||
key: 'id',
|
||||
value: valueField ?? 'id',
|
||||
};
|
||||
// No explicit enumOption supplied – this is a configuration error.
|
||||
// We abort loading so the problem is visible immediately.
|
||||
throw new Error(
|
||||
`Missing enumOption for relation "${relation}" on field "${key}". ` +
|
||||
`Define referenceOptions.enumOption in the configuration for resource "${relation}".`
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Recursively parse nested objects (only if not a relation)
|
||||
if (fields[key].type === "object" && resolvedProp.properties && !relation) {
|
||||
console.log('recursive configuration...', configuration['accounts']['referenceOptions'])
|
||||
fields[key].schema = parseSchemaFields(resolvedProp, resourceName, schemaToResourceMap, configuration);
|
||||
}
|
||||
}
|
||||
@@ -143,6 +145,7 @@ function parseSchemaFields(
|
||||
* Scans paths to identify resources and their basic configuration
|
||||
*/
|
||||
export async function loadConfigFromOpenApi(baseUrl: string, configuration: Record<string, any> = {}, profileConfiguration: any = {}): Promise<AppConfig> {
|
||||
console.log('init configuration...', configuration['accounts']['referenceOptions'])
|
||||
// Use SwaggerParser to dereference the spec.
|
||||
// Dereferencing preserves object identity for $ref targets.
|
||||
const api = await SwaggerParser.dereference(
|
||||
@@ -198,6 +201,7 @@ export async function loadConfigFromOpenApi(baseUrl: string, configuration: Reco
|
||||
const label = name.charAt(0).toUpperCase() + name.slice(1, -1);
|
||||
const pluralLabel = name.charAt(0).toUpperCase() + name.slice(1);
|
||||
|
||||
console.log('before parseSchemaFields configuration...', configuration['accounts']['referenceOptions'])
|
||||
const fields = parseSchemaFields(schema, name, schemaToResourceMap, configuration);
|
||||
|
||||
const resourceOverride = configuration[name] || {};
|
||||
|
||||
@@ -17,7 +17,13 @@ export function getFieldOptions(field: ResourceField, relationData?: any[]): Sel
|
||||
|
||||
if (field.relation) {
|
||||
const data = relationData ?? [];
|
||||
const enumOption = field.enumOption ?? { key: 'id', value: 'name' };
|
||||
const enumOption = field.enumOption;
|
||||
if (!enumOption) {
|
||||
throw new Error(
|
||||
`Missing enumOption for relation "${field.relation}" on field "${field}". ` +
|
||||
`Define referenceOptions.enumOption in the configuration for resource "${field.relation}".`
|
||||
);
|
||||
}
|
||||
|
||||
return data.map(item => ({
|
||||
key: String(item[enumOption.key] ?? ''),
|
||||
|
||||
Reference in New Issue
Block a user