/**
*
* EditFormRelations
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { get, map, size } from 'lodash';
// Components.
import SelectOne from 'components/SelectOne';
import SelectMany from 'components/SelectMany';
// Utils.
import getQueryParameters from 'utils/getQueryParameters';
// Style.
import styles from './styles.scss';
class EditFormRelations extends React.Component { // eslint-disable-line react/prefer-stateless-function
componentDidMount() {
if (size(get(this.props.schema, [this.props.currentModelName, 'relations'])) === 0 && !this.props.isNull) {
this.props.toggleNull();
}
}
render() {
const source = getQueryParameters(this.props.location.search, 'source');
const currentSchema = get(this.props.schema, [this.props.currentModelName]) || get(this.props.schema, ['plugins', source, this.props.currentModelName]);
const relations = map(currentSchema.relations, (relation, i) => {
switch (relation.nature) {
case 'oneToOne':
case 'manyToOne':
if (relation.dominant) {
return (