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.relationsLayer.addOrUpdateRelation(relation, previous);
|
||||||
this.closeRelationsEditor();
|
this.closeRelationsEditor();
|
||||||
|
|
||||||
if (previous)
|
// This method will always receive a 'previous' connection -
|
||||||
this.props.onAnnotationUpdated(relation.annotation, previous.annotation);
|
// if the previous is just an empty connection, fire 'create',
|
||||||
else
|
// otherwise, fire 'update'
|
||||||
|
const isNew = previous.annotation.bodies.length === 0;
|
||||||
|
|
||||||
|
if (isNew)
|
||||||
this.props.onAnnotationCreated(relation.annotation);
|
this.props.onAnnotationCreated(relation.annotation);
|
||||||
|
else
|
||||||
|
this.props.onAnnotationUpdated(relation.annotation, previous.annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 'Delete' on the relation editor popup **/
|
/** 'Delete' on the relation editor popup **/
|
||||||
|
|
|
@ -51,7 +51,6 @@ export default class Connection extends EventEmitter {
|
||||||
|
|
||||||
/** Initializes a fixed connection from an annotation **/
|
/** Initializes a fixed connection from an annotation **/
|
||||||
initFromAnnotation = function(contentEl, svgEl, annotation) {
|
initFromAnnotation = function(contentEl, svgEl, annotation) {
|
||||||
console.log('init', annotation);
|
|
||||||
const [ fromId, toId ] = annotation.target.map(t => t.id);
|
const [ fromId, toId ] = annotation.target.map(t => t.id);
|
||||||
const relation = annotation.bodies[0].value;
|
const relation = annotation.bodies[0].value;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ export default class RelationEditor extends Component {
|
||||||
|
|
||||||
onSubmit = () => {
|
onSubmit = () => {
|
||||||
const updatedAnnotation = this.props.relation.annotation.clone({
|
const updatedAnnotation = this.props.relation.annotation.clone({
|
||||||
|
motivation: 'linking',
|
||||||
body: [{
|
body: [{
|
||||||
type: 'TextualBody',
|
type: 'TextualBody',
|
||||||
value: this.state.content,
|
value: this.state.content,
|
||||||
|
|
Loading…
Reference in New Issue