Skip to content

Commit

Permalink
feat: Message in relationship editor if there are no possible relatio…
Browse files Browse the repository at this point in the history
…nships for this entity type

Also fix entity type display for Edition Groups in relationship editor
  • Loading branch information
MonkeyDo committed May 13, 2019
1 parent 073cfb8 commit 8452660
Showing 1 changed file with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ class RelationshipModal
renderEntitySelect() {
const {baseEntity, relationshipTypes} = this.props;
const types = getValidOtherEntityTypes(relationshipTypes, baseEntity);
if (!types.length) {
return null;
}
const typesForDisplay = types.map(_.startCase);
const lastType = _.last(typesForDisplay);
const otherTypes = _.join(typesForDisplay.slice(0, -1), ', ');
Expand Down Expand Up @@ -302,8 +305,31 @@ class RelationshipModal

render() {
const {onCancel, onClose, baseEntity} = this.props;

const baseEntityTypeForDisplay = _.startCase(baseEntity.type);
const submitDisabled = this.calculateProgressAmount() < 100;
const entitySelect = this.renderEntitySelect();

// If there are no possible relationships for this entity type,
// display a helpful message instead of empty selects
if (entitySelect === null) {
return (
<Modal show bsSize="large" onHide={onClose}>
<Modal.Header>
<Modal.Title>Add a relationship</Modal.Title>
</Modal.Header>
<Modal.Body>
<p>
<strong>
{baseEntityTypeForDisplay}s have no possible relationships with other entities at the moment.
</strong>
</p>
</Modal.Body>
<Modal.Footer>
<Button bsStyle="danger" onClick={onCancel}>Cancel</Button>
</Modal.Footer>
</Modal>
);
}

return (
<Modal show bsSize="large" onHide={onClose} onKeyUp={this.handleKeyPress}>
Expand All @@ -314,7 +340,7 @@ class RelationshipModal
<p>
<strong>
Use this form to add links between this{' '}
{baseEntity.type}
{baseEntityTypeForDisplay}
{' '}and other entities.
</strong>
{' '}For example, you can link an author
Expand All @@ -326,7 +352,7 @@ class RelationshipModal
<Col md={10} mdOffset={1}>
<form>
<div>
{this.renderEntitySelect()}
{entitySelect}
</div>
<div>
{this.renderRelationshipSelect()}
Expand Down

0 comments on commit 8452660

Please sign in to comment.