removed displayField
This commit is contained in:
@@ -278,19 +278,10 @@ function MobileCardRow({ row, config, onDelete, onNavigate, navigate, components
|
||||
);
|
||||
}
|
||||
|
||||
function getFormattedDisplayValue(item: any, displayFormat?: string | string[], enumValue?: string) {
|
||||
function getFormattedDisplayValue(item: any, displayFormat: string) {
|
||||
if (!item) return "";
|
||||
if (enumValue) return resolveTemplate(enumValue, item);
|
||||
if (!displayFormat) return item.name || item.title || item.label || item.id || JSON.stringify(item);
|
||||
|
||||
if (Array.isArray(displayFormat)) {
|
||||
return displayFormat
|
||||
.map(key => item[key])
|
||||
.filter(val => val !== undefined && val !== null)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
return item[displayFormat] || item.id || JSON.stringify(item);
|
||||
return resolveTemplate(displayFormat, item);
|
||||
}
|
||||
|
||||
function FieldRenderer({ params, field, fieldKey, config, onNavigate, navigate, isMobile, components }: any) {
|
||||
@@ -307,7 +298,7 @@ function FieldRenderer({ params, field, fieldKey, config, onNavigate, navigate,
|
||||
// 1. Single Relation
|
||||
if (field.relation && value && !Array.isArray(value)) {
|
||||
const relationId = typeof value === 'object' ? (value.id || value._id || value.pk) : value;
|
||||
const displayValue = getFormattedDisplayValue(value, field.displayFormat, field.enumOption?.value);
|
||||
const displayValue = getFormattedDisplayValue(value, field.displayFormat);
|
||||
|
||||
return (
|
||||
<Chip
|
||||
@@ -327,7 +318,7 @@ function FieldRenderer({ params, field, fieldKey, config, onNavigate, navigate,
|
||||
// 2. Multi-Select (Array of relations or simple strings)
|
||||
if (field.type === 'array' && Array.isArray(value)) {
|
||||
const enumValue = field.enumOption?.value;
|
||||
const tooltipTitle = value.map((item) => getFormattedDisplayValue(item, field.displayFormat, enumValue)).join(', ');
|
||||
const tooltipTitle = value.map((item) => getFormattedDisplayValue(item, field.displayFormat)).join(', ');
|
||||
|
||||
return (
|
||||
<Tooltip title={tooltipTitle} arrow placement="top">
|
||||
@@ -335,7 +326,7 @@ function FieldRenderer({ params, field, fieldKey, config, onNavigate, navigate,
|
||||
{value.map((item, idx) => (
|
||||
<Chip
|
||||
key={idx}
|
||||
label={getFormattedDisplayValue(item, field.displayFormat, enumValue)}
|
||||
label={getFormattedDisplayValue(item, field.displayFormat)}
|
||||
size="small"
|
||||
variant="filled"
|
||||
sx={{ maxWidth: 120 }}
|
||||
@@ -355,7 +346,7 @@ function FieldRenderer({ params, field, fieldKey, config, onNavigate, navigate,
|
||||
|
||||
// 3. Simple Objects
|
||||
if (field.type === 'object' && value) {
|
||||
return getFormattedDisplayValue(value, field.displayFormat, field.enumOption?.value) || (isMobile ? 'Object' : JSON.stringify(value));
|
||||
return getFormattedDisplayValue(value, field.displayFormat) || (isMobile ? 'Object' : JSON.stringify(value));
|
||||
}
|
||||
|
||||
if (field.type === 'number' && typeof value === 'number') {
|
||||
|
||||
Reference in New Issue
Block a user