mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-04 05:08:42 +08:00
feat: add relation field component for table and detail
This commit is contained in:
parent
d755558009
commit
272b64b81b
@ -3,6 +3,7 @@ import React, { useEffect, useState } from 'react';
|
||||
import moment from 'moment';
|
||||
import { Tag } from 'antd';
|
||||
import Icon from '@/components/icons';
|
||||
import get from 'lodash/get';
|
||||
|
||||
const InterfaceTypes = new Map<string, any>();
|
||||
|
||||
@ -111,6 +112,18 @@ export function DataSourceField(props: any) {
|
||||
)
|
||||
}
|
||||
|
||||
export function RealtionField(props: any) {
|
||||
const { schema: { labelField }, value } = props;
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
console.log(labelField, value);
|
||||
const items = Array.isArray(value) ? value : [value];
|
||||
return items.map(item => (
|
||||
<span>{get(item, labelField)}</span>
|
||||
));
|
||||
}
|
||||
|
||||
registerFieldComponents({
|
||||
string: StringField,
|
||||
textarea: TextareaField,
|
||||
@ -125,6 +138,8 @@ registerFieldComponents({
|
||||
createdAt: DateTimeField,
|
||||
updatedAt: DateTimeField,
|
||||
icon: IconField,
|
||||
createdBy: RealtionField,
|
||||
updatedBy: RealtionField,
|
||||
});
|
||||
|
||||
export default function Field(props: any) {
|
||||
|
Loading…
Reference in New Issue
Block a user