Handle undefined properly
This commit is contained in:
parent
13418a56f8
commit
ee962380b3
|
@ -75,36 +75,32 @@ export function getRelatedTableValues(row, field, fromField) {
|
||||||
fromField?.relationshipType === RelationshipType.ONE_TO_MANY
|
fromField?.relationshipType === RelationshipType.ONE_TO_MANY
|
||||||
|
|
||||||
let result = ""
|
let result = ""
|
||||||
try {
|
|
||||||
if (fromSingle) {
|
|
||||||
result = row[field.related.field]?.[0]?.[field.related.subField]
|
|
||||||
} else {
|
|
||||||
const parser = columnTypeManyParser[field.type] || (value => value)
|
|
||||||
|
|
||||||
result = parser(
|
if (fromSingle) {
|
||||||
row[field.related.field]
|
result = row[field.related.field]?.[0]?.[field.related.subField]
|
||||||
.flatMap(r => r[field.related.subField])
|
} else {
|
||||||
.filter(i => i !== undefined && i !== null),
|
const parser = columnTypeManyParser[field.type] || (value => value)
|
||||||
field
|
|
||||||
)
|
|
||||||
|
|
||||||
if (
|
result = parser(
|
||||||
[
|
row[field.related.field]
|
||||||
FieldType.STRING,
|
?.flatMap(r => r[field.related.subField])
|
||||||
FieldType.NUMBER,
|
?.filter(i => i !== undefined && i !== null),
|
||||||
FieldType.BIGINT,
|
field
|
||||||
FieldType.BOOLEAN,
|
)
|
||||||
FieldType.DATETIME,
|
|
||||||
FieldType.LONGFORM,
|
if (
|
||||||
FieldType.BARCODEQR,
|
[
|
||||||
].includes(field.type)
|
FieldType.STRING,
|
||||||
) {
|
FieldType.NUMBER,
|
||||||
result = result.join(", ")
|
FieldType.BIGINT,
|
||||||
}
|
FieldType.BOOLEAN,
|
||||||
|
FieldType.DATETIME,
|
||||||
|
FieldType.LONGFORM,
|
||||||
|
FieldType.BARCODEQR,
|
||||||
|
].includes(field.type)
|
||||||
|
) {
|
||||||
|
result = result?.join(", ")
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
result = "Not rendable"
|
|
||||||
console.error(e.message)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in New Issue