More relationship CRUD behavior cleanup

This commit is contained in:
Rainer Simon 2020-04-28 12:10:25 +02:00
parent b162443053
commit b5517e54d1
3 changed files with 9 additions and 4 deletions

View File

@ -130,10 +130,15 @@ export default class TextAnnotator extends Component {
this.relationsLayer.addOrUpdateRelation(relation, previous);
this.closeRelationsEditor();
if (previous)
this.props.onAnnotationUpdated(relation.annotation, previous.annotation);
else
// This method will always receive a 'previous' connection -
// if the previous is just an empty connection, fire 'create',
// otherwise, fire 'update'
const isNew = previous.annotation.bodies.length === 0;
if (isNew)
this.props.onAnnotationCreated(relation.annotation);
else
this.props.onAnnotationUpdated(relation.annotation, previous.annotation);
}
/** 'Delete' on the relation editor popup **/

View File

@ -51,7 +51,6 @@ export default class Connection extends EventEmitter {
/** Initializes a fixed connection from an annotation **/
initFromAnnotation = function(contentEl, svgEl, annotation) {
console.log('init', annotation);
const [ fromId, toId ] = annotation.target.map(t => t.id);
const relation = annotation.bodies[0].value;

View File

@ -72,6 +72,7 @@ export default class RelationEditor extends Component {
onSubmit = () => {
const updatedAnnotation = this.props.relation.annotation.clone({
motivation: 'linking',
body: [{
type: 'TextualBody',
value: this.state.content,