More relationship CRUD behavior cleanup
This commit is contained in:
parent
b162443053
commit
b5517e54d1
|
@ -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 **/
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue