fixes
This commit is contained in:
@@ -3,7 +3,7 @@ import { getFieldOptions } from '../../utils/options';
|
||||
import { FieldComponentProps } from '../../types/overrides';
|
||||
|
||||
export default function RelationField({ field, value, onChange, disabled, relationDataMap = {} }: FieldComponentProps) {
|
||||
console.log('RelationField render', field.label, 'enumOption:', field.enumOption, 'value prop:', value);
|
||||
// console.log('RelationField render', field.label, 'enumOption:', field.enumOption, 'value prop:', value);
|
||||
const relationName = field.relation ?? (field as any).refers;
|
||||
if (!relationName || !relationDataMap[relationName]) {
|
||||
throw new Error(`Relation data for "${relationName}" is missing – cannot render options for field "${field.label}"`);
|
||||
@@ -13,7 +13,7 @@ if (!relationName || !relationDataMap[relationName]) {
|
||||
const relationData = relationDataMap[relationName];
|
||||
const isArrayRelation = field.type === 'array';
|
||||
const options = getFieldOptions(field, relationData);
|
||||
console.log('Options for', field.label, 'keys:', options.map(o=>o.key));
|
||||
// console.log('Options for', field.label, 'keys:', options.map(o=>o.key));
|
||||
if (options.length === 0) {
|
||||
throw new Error(`No selectable options available for field "${field.label}" (relation "${relationName}")`);
|
||||
}
|
||||
@@ -47,12 +47,12 @@ if (!relationName || !relationDataMap[relationName]) {
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
disabled={disabled}
|
||||
renderValue={(selected: any) => {
|
||||
console.log('Select renderValue for', field.label, 'selected:', selected);
|
||||
// console.log('Select renderValue for', field.label, 'selected:', selected);
|
||||
if (isArrayRelation) {
|
||||
return (selected as string[]).map(k => options.find(o => o.key === k)?.value ?? k).join(', ');
|
||||
}
|
||||
const display = options.find(o => o.key === selected)?.value ?? selected;
|
||||
console.log('Display value for', field.label, ':', display);
|
||||
// console.log('Display value for', field.label, ':', display);
|
||||
return display;
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user