create.config.ts 2.99 KB
import {
  DirectionEnum,
  DirectionNameEnum,
  EntityTypeEnum,
  EntityTypeNameEnum,
} from '../../../enum/form';
import {
  DeleteRelationFieldsEnum,
  DeleteRelationFieldsNameEnum,
} from '../../../enum/formField/action';
import { FormSchema } from '/@/components/Form';

export const formSchemas: FormSchema[] = [
  {
    field: DeleteRelationFieldsEnum.DELETE_FOR_SINGLE_ENTITY,
    component: 'Checkbox',
    label: DeleteRelationFieldsNameEnum.DELETE_FOR_SINGLE_ENTITY,
    renderComponentContent: () => ({
      default: () =>
        'Deletes relation from the originator of the incoming message to the specified entity or list of entities based on direction and type.',
    }),
  },
  {
    field: DeleteRelationFieldsEnum.DIRECTION,
    component: 'Select',
    label: DeleteRelationFieldsNameEnum.DIRECTION,
    required: true,
    show: ({ model }) => model[DeleteRelationFieldsEnum.DELETE_FOR_SINGLE_ENTITY],
    componentProps: {
      options: Object.keys(DirectionEnum).map((value) => ({
        label: DirectionNameEnum[value],
        value,
      })),
      getPopupContainer: () => document.body,
      placeholder: `请选择${DeleteRelationFieldsNameEnum.DELETE_FOR_SINGLE_ENTITY}`,
    },
  },
  {
    field: DeleteRelationFieldsEnum.ENTITY_TYPE,
    component: 'Select',
    label: DeleteRelationFieldsNameEnum.ENTITY_TYPE,
    required: true,
    colProps: { span: 12 },
    componentProps: {
      options: Object.keys(EntityTypeEnum).map((value) => ({
        label: EntityTypeNameEnum[value],
        value,
      })),
      getPopupContainer: () => document.body,
      placeholder: `请选择${DeleteRelationFieldsNameEnum.ENTITY_TYPE}`,
    },
  },
  {
    field: DeleteRelationFieldsEnum.ENTITY_NAME_PATTERN,
    component: 'Input',
    label: DeleteRelationFieldsNameEnum.ENTITY_NAME_PATTERN,
    required: true,
    colProps: { span: 12 },
    show: ({ model }) => model[DeleteRelationFieldsEnum.DELETE_FOR_SINGLE_ENTITY],
    helpMessage: [
      'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
    ],
    componentProps: {
      placeholder: `请输入${DeleteRelationFieldsNameEnum.ENTITY_NAME_PATTERN}`,
    },
  },
  {
    field: DeleteRelationFieldsEnum.RELATION_TYPE,
    component: 'Input',
    label: DeleteRelationFieldsNameEnum.RELATION_TYPE,
    required: true,
    helpMessage: [
      'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
    ],
    componentProps: {
      placeholder: `请输入${DeleteRelationFieldsNameEnum.RELATION_TYPE}`,
    },
  },
  {
    field: DeleteRelationFieldsEnum.ENTITY_CACHE_EXPIRATION,
    component: 'InputNumber',
    label: DeleteRelationFieldsNameEnum.ENTITY_CACHE_EXPIRATION,
    required: true,
    helpMessage: [
      'Specifies maximum time interval allowed to store found entity records. 0 value means that records will never expire.',
    ],
    componentProps: {
      min: 0,
      placeholder: `请输入${DeleteRelationFieldsNameEnum.DELETE_FOR_SINGLE_ENTITY}`,
    },
  },
];