Fixes to relation CRUD event behavior

This commit is contained in:
Rainer Simon 2020-04-28 11:26:58 +02:00
parent 11c1c224a0
commit d491c402af
2 changed files with 6 additions and 2 deletions

View File

@ -216,6 +216,7 @@ export default class TextAnnotator extends Component {
{ this.state.showRelationEditor && { this.state.showRelationEditor &&
<RelationEditor <RelationEditor
relation={this.state.selectedRelation} relation={this.state.selectedRelation}
onRelationCreated={this.onCreateOrUpdateRelation}
onRelationUpdated={this.onCreateOrUpdateRelation} onRelationUpdated={this.onCreateOrUpdateRelation}
onRelationDeleted={this.onDeleteRelation} onRelationDeleted={this.onDeleteRelation}
onCancel={this.closeRelationsEditor} onCancel={this.closeRelationsEditor}

View File

@ -81,8 +81,11 @@ export default class RelationEditor extends Component {
const updatedRelation = { ...this.props.relation, annotation: updatedAnnotation }; const updatedRelation = { ...this.props.relation, annotation: updatedAnnotation };
// Return updated/before // Fire create or update event
this.props.onRelationUpdated(updatedRelation, this.props.relation); if (this.props.relation.annotation.bodies.length === 0)
this.props.onRelationCreated(updatedRelation);
else
this.props.onRelationUpdated(updatedRelation, this.props.relation);
} }
onDelete = () => onDelete = () =>