2019-07-17 15:35:19 +02:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
|
|
import pluginId from '../../pluginId';
|
|
|
|
|
import IconRemove from '../../assets/images/icon_remove.svg';
|
|
|
|
|
|
2020-01-21 16:03:31 +01:00
|
|
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
|
|
|
|
2019-07-17 15:35:19 +02:00
|
|
|
const Relation = ({ data, mainField, onRemove, to }) => {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2019-07-29 17:11:53 +02:00
|
|
|
<div style={{ cursor: 'pointer' }}>
|
2019-07-17 15:35:19 +02:00
|
|
|
<div className="dragHandle">
|
|
|
|
|
<span />
|
|
|
|
|
</div>
|
|
|
|
|
<FormattedMessage id={`${pluginId}.containers.Edit.clickToJump`}>
|
|
|
|
|
{title => (
|
|
|
|
|
<Link to={to} title={title}>
|
|
|
|
|
<span>{data[mainField]}</span>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</FormattedMessage>
|
|
|
|
|
</div>
|
2019-07-29 17:11:53 +02:00
|
|
|
<div style={{ cursor: 'pointer' }}>
|
2019-07-17 15:35:19 +02:00
|
|
|
<img src={IconRemove} alt="Remove Icon" onClick={onRemove} />
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Relation.defaultProps = {
|
|
|
|
|
onRemove: () => {},
|
|
|
|
|
to: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Relation.propTypes = {
|
|
|
|
|
data: PropTypes.object.isRequired,
|
|
|
|
|
mainField: PropTypes.string.isRequired,
|
|
|
|
|
onRemove: PropTypes.func,
|
|
|
|
|
to: PropTypes.string,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default memo(Relation);
|