create.config.ts 1.35 KB
import { AttributeConfiguration } from '/@/views/rule/designer/src/components/AttributeConfiguration';
import { FormSchema, useComponentRegister } from '/@/components/Form';
import { RelationsQuery } from '/@/views/rule/designer/src/components/RelationsQuery';

import { useRuleChainI18n } from '../../../hook/useRuleChainI18n';

const { tLabel } = useRuleChainI18n('enrichment', 'relatedAttributes');

export enum RelatedAttributesFieldsEnum {
  RELATIONS_QUERY = 'relationsQuery',
  ATTR_MAPPING = 'attrMapping',
  TELEMETRY = 'telemetry',
}

useComponentRegister('RelationsQuery', RelationsQuery);
useComponentRegister('AttributeConfiguration', AttributeConfiguration);

export const formSchemas: FormSchema[] = [
  {
    field: RelatedAttributesFieldsEnum.RELATIONS_QUERY,
    component: 'RelationsQuery',
    label: tLabel(RelatedAttributesFieldsEnum.RELATIONS_QUERY),
    changeEvent: 'update:value',
    valueField: 'value',
    slot: RelatedAttributesFieldsEnum.RELATIONS_QUERY,
  },
  {
    field: RelatedAttributesFieldsEnum.TELEMETRY,
    component: 'Checkbox',
    label: '',
    renderComponentContent: () => ({
      default: () => tLabel(RelatedAttributesFieldsEnum.TELEMETRY),
    }),
  },
  {
    field: RelatedAttributesFieldsEnum.ATTR_MAPPING,
    component: 'AttributeConfiguration',
    label: '',
    slot: RelatedAttributesFieldsEnum.ATTR_MAPPING,
  },
];