@konfuzio/document-validation-ui 0.1.8 → 0.1.9-pre-release-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/app.css +1 -1
- package/dist/index.html +1 -1
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/DocumentAnnotations/AnnotationContent.vue +18 -47
- package/src/components/DocumentAnnotations/AnnotationRow.vue +59 -91
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +11 -7
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +41 -88
- package/src/components/DocumentDashboard.vue +5 -2
- package/src/components/DocumentEdit/DocumentEdit.vue +5 -5
- package/src/components/DocumentPage/BoxSelection.vue +4 -1
- package/src/components/DocumentPage/DocumentPage.vue +17 -17
- package/src/components/DocumentPage/NewAnnotation.vue +22 -11
- package/src/locales/de.json +15 -14
- package/src/locales/en.json +1 -2
- package/src/locales/es.json +4 -2
- package/src/store/category.js +1 -1
- package/src/store/document.js +24 -29
- package/src/store/edit.js +13 -1
- package/src/store/selection.js +32 -7
- package/src/utils/utils.js +4 -0
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
|
@@ -21,9 +21,6 @@
|
|
|
21
21
|
>
|
|
22
22
|
{{ span.offset_string }}
|
|
23
23
|
</span>
|
|
24
|
-
<span v-else class="annotation-value">
|
|
25
|
-
{{ span.offset_string }}
|
|
26
|
-
</span>
|
|
27
24
|
</div>
|
|
28
25
|
</template>
|
|
29
26
|
|
|
@@ -70,59 +67,34 @@ export default {
|
|
|
70
67
|
...mapGetters("document", [
|
|
71
68
|
"isAnnotationInEditMode",
|
|
72
69
|
"pageAtIndex",
|
|
73
|
-
"getTextFromEntities",
|
|
74
70
|
"isDocumentReviewed",
|
|
75
71
|
]),
|
|
76
72
|
...mapGetters("display", ["bboxToRect"]),
|
|
77
|
-
...mapGetters("selection", ["isValueArray"]),
|
|
78
73
|
...mapState("selection", ["spanSelection"]),
|
|
79
74
|
...mapState("document", [
|
|
80
75
|
"editAnnotation",
|
|
81
76
|
"publicView",
|
|
82
77
|
"annotations",
|
|
83
78
|
"newAcceptedAnnotations",
|
|
84
|
-
"selectedEntities",
|
|
85
79
|
"showActionError",
|
|
86
80
|
]),
|
|
81
|
+
|
|
82
|
+
isAnnotationDeleted() {
|
|
83
|
+
return this.annotation.revised && !this.annotation.is_correct;
|
|
84
|
+
},
|
|
85
|
+
isAnnotationBeingEdited() {
|
|
86
|
+
return this.isAnnotationInEditMode(this.annotation.id, this.spanIndex);
|
|
87
|
+
},
|
|
87
88
|
annotationText() {
|
|
88
89
|
if (this.isAnnotationBeingEdited) {
|
|
89
|
-
if (this.selectedEntities && this.selectedEntities.length > 0) {
|
|
90
|
-
return this.getTextFromEntities();
|
|
91
|
-
}
|
|
92
90
|
return this.$refs.contentEditable.textContent.trim();
|
|
93
91
|
} else {
|
|
94
92
|
return this.span.offset_string;
|
|
95
93
|
}
|
|
96
94
|
},
|
|
97
|
-
isAnnotationDeleted() {
|
|
98
|
-
return this.annotation.revised && !this.annotation.is_correct;
|
|
99
|
-
},
|
|
100
|
-
isAnnotationBeingEdited() {
|
|
101
|
-
return this.isAnnotationInEditMode(this.annotation.id, this.spanIndex);
|
|
102
|
-
},
|
|
103
95
|
},
|
|
96
|
+
|
|
104
97
|
watch: {
|
|
105
|
-
span(newValue) {
|
|
106
|
-
if (this.isAnnotationBeingEdited && newValue) {
|
|
107
|
-
if (this.isValueArray(newValue)) {
|
|
108
|
-
newValue.map((span) => {
|
|
109
|
-
if (
|
|
110
|
-
span.offset_string &&
|
|
111
|
-
span.offset_string !== this.span.offset_string
|
|
112
|
-
)
|
|
113
|
-
this.setText(span.offset_string);
|
|
114
|
-
});
|
|
115
|
-
} else {
|
|
116
|
-
if (
|
|
117
|
-
(newValue.offset_string &&
|
|
118
|
-
newValue.offset_string !== this.span.offset_string) ||
|
|
119
|
-
newValue.offset_string !==
|
|
120
|
-
this.$refs.contentEditable.textContent.trim()
|
|
121
|
-
)
|
|
122
|
-
this.setText(newValue.offset_string);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
98
|
editAnnotation(newAnnotation, oldAnnotation) {
|
|
127
99
|
// verify if new annotation in edit mode is not this one and if this
|
|
128
100
|
// one was selected before so we set the state to the previous one (like a cancel)
|
|
@@ -135,16 +107,7 @@ export default {
|
|
|
135
107
|
this.handleCancel(true);
|
|
136
108
|
}
|
|
137
109
|
},
|
|
138
|
-
selectedEntities(newValue) {
|
|
139
|
-
if (!newValue) return;
|
|
140
110
|
|
|
141
|
-
if (
|
|
142
|
-
this.editAnnotation &&
|
|
143
|
-
this.annotation.id === this.editAnnotation.id
|
|
144
|
-
) {
|
|
145
|
-
this.setText(this.getTextFromEntities());
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
111
|
saveChanges(newValue) {
|
|
149
112
|
if (newValue) {
|
|
150
113
|
this.saveAnnotationChanges();
|
|
@@ -169,6 +132,7 @@ export default {
|
|
|
169
132
|
!this.isLoading
|
|
170
133
|
) {
|
|
171
134
|
this.$store.dispatch("selection/selectElement", this.annotation.id);
|
|
135
|
+
|
|
172
136
|
this.$store
|
|
173
137
|
.dispatch("document/setEditAnnotation", {
|
|
174
138
|
id: this.annotation.id,
|
|
@@ -221,7 +185,7 @@ export default {
|
|
|
221
185
|
this.$refs.contentEditable.blur();
|
|
222
186
|
}
|
|
223
187
|
|
|
224
|
-
this.$store.dispatch("
|
|
188
|
+
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
225
189
|
},
|
|
226
190
|
handlePaste(event) {
|
|
227
191
|
// TODO: modify to only paste plain text
|
|
@@ -234,11 +198,18 @@ export default {
|
|
|
234
198
|
event.preventDefault();
|
|
235
199
|
}
|
|
236
200
|
|
|
201
|
+
let index;
|
|
202
|
+
if (this.editAnnotation && this.editAnnotation.index) {
|
|
203
|
+
index = this.editAnnotation.index;
|
|
204
|
+
} else {
|
|
205
|
+
index = this.spanIndex;
|
|
206
|
+
}
|
|
207
|
+
|
|
237
208
|
// API call handled in parent component - AnnotationRow
|
|
238
209
|
this.$emit(
|
|
239
210
|
"save-annotation-changes",
|
|
240
211
|
this.annotation,
|
|
241
|
-
|
|
212
|
+
index,
|
|
242
213
|
this.span,
|
|
243
214
|
this.annotationText
|
|
244
215
|
);
|
|
@@ -71,6 +71,9 @@
|
|
|
71
71
|
:annotation-set="annotationSet"
|
|
72
72
|
:is-hovered="hoveredAnnotation"
|
|
73
73
|
:save-changes="saveChanges"
|
|
74
|
+
:is-missing-annotation="
|
|
75
|
+
annotationIsNotFound(annotationSet, label)
|
|
76
|
+
"
|
|
74
77
|
@save-empty-annotation-changes="saveEmptyAnnotationChanges"
|
|
75
78
|
/>
|
|
76
79
|
</div>
|
|
@@ -80,6 +83,7 @@
|
|
|
80
83
|
:annotation-set="annotationSet"
|
|
81
84
|
:is-hovered="hoveredAnnotation"
|
|
82
85
|
:save-changes="saveChanges"
|
|
86
|
+
:is-missing-annotation="annotationIsNotFound(annotationSet, label)"
|
|
83
87
|
@save-empty-annotation-changes="saveEmptyAnnotationChanges"
|
|
84
88
|
/>
|
|
85
89
|
</div>
|
|
@@ -110,6 +114,7 @@ import AnnotationDetails from "./AnnotationDetails";
|
|
|
110
114
|
import AnnotationContent from "./AnnotationContent";
|
|
111
115
|
import EmptyAnnotation from "./EmptyAnnotation";
|
|
112
116
|
import AnnotationActionButtons from "./AnnotationActionButtons";
|
|
117
|
+
import { isElementArray } from "../../utils/utils";
|
|
113
118
|
|
|
114
119
|
export default {
|
|
115
120
|
name: "AnnotationRow",
|
|
@@ -162,20 +167,22 @@ export default {
|
|
|
162
167
|
"hoveredAnnotationSet",
|
|
163
168
|
"enableGroupingFeature",
|
|
164
169
|
"publicView",
|
|
165
|
-
"selectedEntities",
|
|
166
170
|
"newAcceptedAnnotations",
|
|
167
171
|
"annotationsMarkedAsMissing",
|
|
168
172
|
"documentId",
|
|
169
173
|
"showActionError",
|
|
170
174
|
"missingAnnotations",
|
|
171
175
|
]),
|
|
172
|
-
...mapState("selection", [
|
|
176
|
+
...mapState("selection", [
|
|
177
|
+
"spanSelection",
|
|
178
|
+
"elementSelected",
|
|
179
|
+
"selectedEntities",
|
|
180
|
+
]),
|
|
173
181
|
...mapGetters("document", [
|
|
174
182
|
"isAnnotationInEditMode",
|
|
175
183
|
"annotationIsNotFound",
|
|
176
184
|
"isDocumentReviewed",
|
|
177
185
|
]),
|
|
178
|
-
...mapGetters("selection", ["isValueArray"]),
|
|
179
186
|
defaultSpan() {
|
|
180
187
|
if (
|
|
181
188
|
this.annotation &&
|
|
@@ -189,15 +196,11 @@ export default {
|
|
|
189
196
|
spanForEditing() {
|
|
190
197
|
return (
|
|
191
198
|
this.spanSelection &&
|
|
192
|
-
|
|
199
|
+
isElementArray(this.spanSelection) &&
|
|
193
200
|
this.isAnnotationInEditMode(this.annotationId())
|
|
194
201
|
);
|
|
195
202
|
},
|
|
196
|
-
|
|
197
|
-
return this.selectedEntities.flatMap((ann) => {
|
|
198
|
-
return { ...ann.entity.original, offset_string: ann.content };
|
|
199
|
-
});
|
|
200
|
-
},
|
|
203
|
+
|
|
201
204
|
isAnnotation() {
|
|
202
205
|
return (
|
|
203
206
|
this.annotation &&
|
|
@@ -277,7 +280,22 @@ export default {
|
|
|
277
280
|
this.isLoading = false;
|
|
278
281
|
}
|
|
279
282
|
},
|
|
283
|
+
selectedEntities(newValue) {
|
|
284
|
+
if (!newValue) return;
|
|
285
|
+
|
|
286
|
+
if (this.isAnnotationInEditMode(this.annotationId())) {
|
|
287
|
+
this.isLoading = true;
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
spanSelection(newValue, oldValue) {
|
|
291
|
+
// check if spanSelection has new value from entity selection
|
|
292
|
+
// to stop loading after the text appears in the field
|
|
293
|
+
if (newValue) {
|
|
294
|
+
this.isLoading = false;
|
|
295
|
+
}
|
|
296
|
+
},
|
|
280
297
|
},
|
|
298
|
+
|
|
281
299
|
methods: {
|
|
282
300
|
annotationId() {
|
|
283
301
|
if (!this.annotationSet || !this.label) return;
|
|
@@ -391,7 +409,7 @@ export default {
|
|
|
391
409
|
}
|
|
392
410
|
},
|
|
393
411
|
showSaveButton() {
|
|
394
|
-
if (!this.editAnnotation || this.isLoading) return;
|
|
412
|
+
if (!this.editAnnotation || this.isLoading || !this.spanSelection) return;
|
|
395
413
|
|
|
396
414
|
// Check if it's an Annotation or Empty Annotation
|
|
397
415
|
if (this.isAnnotation) {
|
|
@@ -399,22 +417,18 @@ export default {
|
|
|
399
417
|
} else {
|
|
400
418
|
if (!this.isAnnotationInEditMode(this.annotationId())) return;
|
|
401
419
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
return (
|
|
408
|
-
this.elementSelected === this.annotationId() &&
|
|
409
|
-
this.spanSelection &&
|
|
410
|
-
Array.isArray(this.spanSelection)
|
|
411
|
-
);
|
|
412
|
-
}
|
|
420
|
+
return (
|
|
421
|
+
this.elementSelected === this.annotationId() &&
|
|
422
|
+
this.spanSelection &&
|
|
423
|
+
Array.isArray(this.spanSelection)
|
|
424
|
+
);
|
|
413
425
|
}
|
|
414
426
|
},
|
|
415
427
|
handleMissingAnnotation() {
|
|
416
428
|
if (!this.label || !this.annotationSet) return;
|
|
417
429
|
|
|
430
|
+
this.isLoading = true;
|
|
431
|
+
|
|
418
432
|
// will emit to the DocumentAnnotations component, where the method is handled
|
|
419
433
|
// & dispatched to the store
|
|
420
434
|
this.$parent.$emit(
|
|
@@ -475,77 +489,38 @@ export default {
|
|
|
475
489
|
},
|
|
476
490
|
handleSaveAnnotationChanges(
|
|
477
491
|
annotation,
|
|
478
|
-
|
|
492
|
+
index,
|
|
479
493
|
annotationSpan,
|
|
480
|
-
|
|
494
|
+
annotationContent
|
|
481
495
|
) {
|
|
482
|
-
|
|
483
|
-
|
|
496
|
+
// This function deals with declining Annotations
|
|
497
|
+
// or editing an Annotation or a part of it (if multi line)
|
|
484
498
|
this.isLoading = true;
|
|
485
499
|
|
|
486
|
-
|
|
487
|
-
let
|
|
488
|
-
annotationText.length === 0 &&
|
|
489
|
-
(!this.isValueArray(annotation.span) || annotation.span.length === 1);
|
|
500
|
+
let updatedString; // what will be sent to the API
|
|
501
|
+
let storeAction; // if it will be 'delete' or 'patch'
|
|
490
502
|
|
|
491
|
-
|
|
503
|
+
// Validate if we are deleting an Annotation that it's not multi-lined
|
|
504
|
+
let isToDelete =
|
|
505
|
+
annotationContent.length === 0 &&
|
|
506
|
+
(!isElementArray(annotation.span) || annotation.span.length === 1);
|
|
492
507
|
|
|
508
|
+
// Verify if we delete the entire Annotation or a part of the text
|
|
493
509
|
if (isToDelete || this.toDecline) {
|
|
494
510
|
storeAction = "document/deleteAnnotation";
|
|
495
511
|
} else {
|
|
512
|
+
// Editing the Annotation
|
|
513
|
+
// Deleting part of multi-line Annotation
|
|
496
514
|
storeAction = "document/updateAnnotation";
|
|
497
515
|
|
|
498
516
|
let spans = [...annotation.span];
|
|
499
517
|
|
|
500
|
-
|
|
501
|
-
if (annotationText.length === 0 && this.isValueArray(annotation.span)) {
|
|
502
|
-
// if the annotation content in one row was deleted
|
|
503
|
-
// check if it it part of an array
|
|
504
|
-
// to only remove that string
|
|
505
|
-
spans.splice(spanIndex, 1);
|
|
506
|
-
} else if (
|
|
507
|
-
this.spanSelection &&
|
|
508
|
-
this.isValueArray(this.spanSelection)
|
|
509
|
-
) {
|
|
510
|
-
let span;
|
|
511
|
-
|
|
512
|
-
// Check if editing was from selecting an entity
|
|
513
|
-
if (this.selectedEntities && this.selectedEntities.length > 0) {
|
|
514
|
-
span = this.spanFromSelectedEntities;
|
|
515
|
-
} else {
|
|
516
|
-
spans = [...this.spanSelection];
|
|
517
|
-
span = this.createSpan(
|
|
518
|
-
this.spanSelection[spanIndex],
|
|
519
|
-
annotationText
|
|
520
|
-
);
|
|
521
|
-
}
|
|
518
|
+
const span = this.createSpan(annotationSpan, annotationContent);
|
|
522
519
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
};
|
|
528
|
-
} else {
|
|
529
|
-
// if span is NOT an array, but an object
|
|
530
|
-
let span;
|
|
531
|
-
|
|
532
|
-
if (this.selectedEntities && this.selectedEntities.length > 0) {
|
|
533
|
-
spans = this.spanFromSelectedEntities;
|
|
534
|
-
} else if (this.spanSelection) {
|
|
535
|
-
span = this.createSpan(this.spanSelection, annotationText);
|
|
536
|
-
|
|
537
|
-
spans[spanIndex] = {
|
|
538
|
-
...spans[spanIndex],
|
|
539
|
-
...span,
|
|
540
|
-
};
|
|
541
|
-
} else {
|
|
542
|
-
span = this.createSpan(annotationSpan, annotationText);
|
|
543
|
-
|
|
544
|
-
spans[spanIndex] = {
|
|
545
|
-
...spans[spanIndex],
|
|
546
|
-
...span,
|
|
547
|
-
};
|
|
548
|
-
}
|
|
520
|
+
spans[index] = span;
|
|
521
|
+
|
|
522
|
+
if (annotationContent.length === 0) {
|
|
523
|
+
spans.splice(index, 1);
|
|
549
524
|
}
|
|
550
525
|
|
|
551
526
|
updatedString = {
|
|
@@ -571,13 +546,13 @@ export default {
|
|
|
571
546
|
.finally(() => {
|
|
572
547
|
this.$store.dispatch("document/resetEditAnnotation");
|
|
573
548
|
this.$store.dispatch("selection/disableSelection");
|
|
574
|
-
this.$store.dispatch("
|
|
549
|
+
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
575
550
|
this.toDecline = false;
|
|
576
551
|
});
|
|
577
552
|
},
|
|
578
|
-
createSpan(span,
|
|
553
|
+
createSpan(span, annotationContent) {
|
|
579
554
|
return {
|
|
580
|
-
offset_string:
|
|
555
|
+
offset_string: annotationContent,
|
|
581
556
|
page_index: span.page_index,
|
|
582
557
|
x0: span.x0,
|
|
583
558
|
x1: span.x1,
|
|
@@ -589,18 +564,11 @@ export default {
|
|
|
589
564
|
},
|
|
590
565
|
saveEmptyAnnotationChanges() {
|
|
591
566
|
let annotationToCreate;
|
|
592
|
-
let span;
|
|
593
|
-
|
|
594
|
-
if (this.selectedEntities && this.selectedEntities.length > 0) {
|
|
595
|
-
span = this.spanFromSelectedEntities;
|
|
596
|
-
} else {
|
|
597
|
-
span = this.spanSelection;
|
|
598
|
-
}
|
|
599
567
|
|
|
600
568
|
if (this.annotationSet.id) {
|
|
601
569
|
annotationToCreate = {
|
|
602
570
|
document: this.documentId,
|
|
603
|
-
span:
|
|
571
|
+
span: this.spanSelection,
|
|
604
572
|
label: this.label.id,
|
|
605
573
|
annotation_set: this.annotationSet.id,
|
|
606
574
|
is_correct: true,
|
|
@@ -610,7 +578,7 @@ export default {
|
|
|
610
578
|
// if annotation set id is null
|
|
611
579
|
annotationToCreate = {
|
|
612
580
|
document: this.documentId,
|
|
613
|
-
span:
|
|
581
|
+
span: this.spanSelection,
|
|
614
582
|
label: this.label.id,
|
|
615
583
|
label_set: this.annotationSet.label_set.id,
|
|
616
584
|
is_correct: true,
|
|
@@ -637,7 +605,7 @@ export default {
|
|
|
637
605
|
this.$store.dispatch("document/resetEditAnnotation");
|
|
638
606
|
if (this.elementSelected) {
|
|
639
607
|
this.$store.dispatch("selection/disableSelection");
|
|
640
|
-
this.$store.dispatch("
|
|
608
|
+
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
641
609
|
}
|
|
642
610
|
},
|
|
643
611
|
enableLoading(annotations) {
|
|
@@ -385,14 +385,16 @@ export default {
|
|
|
385
385
|
},
|
|
386
386
|
];
|
|
387
387
|
} else if (this.editAnnotation && this.editAnnotation.id !== null) {
|
|
388
|
-
//
|
|
388
|
+
// if annotation is marked as missing from "delete" key
|
|
389
389
|
|
|
390
|
-
missing =
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
390
|
+
missing = [
|
|
391
|
+
{
|
|
392
|
+
document: parseInt(this.documentId),
|
|
393
|
+
label: this.editAnnotation.label,
|
|
394
|
+
label_set: this.editAnnotation.labelSet,
|
|
395
|
+
annotation_set: this.editAnnotation.annotationSet,
|
|
396
|
+
},
|
|
397
|
+
];
|
|
396
398
|
} else if (annotationSet && markAllMissing) {
|
|
397
399
|
// mark all annotations as missing in annotation set
|
|
398
400
|
|
|
@@ -447,6 +449,8 @@ export default {
|
|
|
447
449
|
})
|
|
448
450
|
.finally(() => {
|
|
449
451
|
this.$store.dispatch("document/setAnnotationsMarkedAsMissing", null);
|
|
452
|
+
this.$store.dispatch("document/resetEditAnnotation");
|
|
453
|
+
this.$store.dispatch("selection/disableSelection");
|
|
450
454
|
});
|
|
451
455
|
},
|
|
452
456
|
|
|
@@ -10,32 +10,38 @@
|
|
|
10
10
|
editAnnotation &&
|
|
11
11
|
editAnnotation.id === emptyAnnotationId() &&
|
|
12
12
|
'error-editing',
|
|
13
|
-
isEmptyAnnotationEditable()
|
|
13
|
+
!isEmptyAnnotationEditable() && !isMissingAnnotation && 'label-empty',
|
|
14
14
|
isAnnotationBeingEdited() && 'clicked',
|
|
15
|
-
|
|
15
|
+
isMissingAnnotation && 'missing-annotation',
|
|
16
16
|
]"
|
|
17
17
|
:contenteditable="isEmptyAnnotationEditable()"
|
|
18
18
|
@keypress.enter="saveEmptyAnnotationChanges"
|
|
19
19
|
@click="handleEditEmptyAnnotation"
|
|
20
20
|
@focus="handleEditEmptyAnnotation"
|
|
21
|
-
|
|
22
|
-
<span v-if="span && span.offset_string && isEmptyAnnotationEditable()">
|
|
23
|
-
{{ span.offset_string }}
|
|
24
|
-
</span>
|
|
21
|
+
><!-- eslint-disable vue/no-v-html -->
|
|
25
22
|
<span
|
|
26
|
-
v-
|
|
27
|
-
|
|
23
|
+
v-if="isFindingAnnotation"
|
|
24
|
+
v-html="$t('draw_box_document', { label_name: label.name })"
|
|
28
25
|
>
|
|
26
|
+
</span>
|
|
27
|
+
<span v-else-if="isMissingAnnotation" class="not-found-text">
|
|
29
28
|
{{ $t("missing_from_document") }}
|
|
30
29
|
</span>
|
|
30
|
+
<span
|
|
31
|
+
v-else-if="span && span.offset_string && isEmptyAnnotationEditable()"
|
|
32
|
+
>
|
|
33
|
+
{{ span.offset_string }}
|
|
34
|
+
</span>
|
|
31
35
|
<span v-else>
|
|
32
36
|
{{ $t("no_data_found") }}
|
|
33
37
|
</span>
|
|
38
|
+
<!--eslint-enable-->
|
|
34
39
|
</span>
|
|
35
40
|
</div>
|
|
36
41
|
</template>
|
|
37
42
|
<script>
|
|
38
43
|
import { mapState, mapGetters } from "vuex";
|
|
44
|
+
import { isElementArray } from "../../utils/utils";
|
|
39
45
|
|
|
40
46
|
/**
|
|
41
47
|
* This component is responsible for managing empty annotations (labels with no annotations).
|
|
@@ -65,80 +71,50 @@ export default {
|
|
|
65
71
|
type: Boolean,
|
|
66
72
|
required: false,
|
|
67
73
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
74
|
+
isMissingAnnotation: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
required: true,
|
|
77
|
+
default: false,
|
|
78
|
+
},
|
|
73
79
|
},
|
|
74
80
|
computed: {
|
|
75
|
-
...mapGetters("document", [
|
|
76
|
-
"isAnnotationInEditMode",
|
|
77
|
-
"getTextFromEntities",
|
|
78
|
-
"annotationIsNotFound",
|
|
79
|
-
"isDocumentReviewed",
|
|
80
|
-
]),
|
|
81
|
-
...mapGetters("selection", ["isValueArray"]),
|
|
81
|
+
...mapGetters("document", ["isAnnotationInEditMode", "isDocumentReviewed"]),
|
|
82
82
|
...mapState("selection", ["spanSelection", "elementSelected"]),
|
|
83
83
|
...mapState("document", [
|
|
84
84
|
"editAnnotation",
|
|
85
85
|
"publicView",
|
|
86
|
-
"selectedEntities",
|
|
87
86
|
"showActionError",
|
|
88
87
|
]),
|
|
88
|
+
isFindingAnnotation() {
|
|
89
|
+
return (
|
|
90
|
+
this.editAnnotation &&
|
|
91
|
+
this.editAnnotation.id === this.emptyAnnotationId() &&
|
|
92
|
+
(!this.span || !this.span.offset_string)
|
|
93
|
+
);
|
|
94
|
+
},
|
|
89
95
|
},
|
|
96
|
+
|
|
90
97
|
watch: {
|
|
91
98
|
span(newValue) {
|
|
92
99
|
if (this.elementSelected === this.emptyAnnotationId() && newValue) {
|
|
93
|
-
if (
|
|
100
|
+
if (isElementArray(newValue))
|
|
94
101
|
newValue.map((span) => {
|
|
95
102
|
if (span.offset_string) {
|
|
96
103
|
span.offset_string =
|
|
97
104
|
this.$refs.emptyAnnotation.textContent.trim();
|
|
98
105
|
span.offset_string_original =
|
|
99
106
|
this.$refs.emptyAnnotation.textContent.trim();
|
|
100
|
-
|
|
101
|
-
this.setText(span.offset_string);
|
|
102
107
|
}
|
|
103
108
|
});
|
|
104
109
|
}
|
|
105
110
|
},
|
|
106
|
-
editAnnotation(newAnnotation, oldAnnotation) {
|
|
107
|
-
// verify if new annotation in edit mode is not this one and if this
|
|
108
|
-
// one was selected before so we set the state to the previous one (like a cancel)
|
|
109
|
-
if (oldAnnotation && oldAnnotation.id === this.emptyAnnotationId()) {
|
|
110
|
-
this.cancelEmptyAnnotation(true);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
selectedEntities(newValue) {
|
|
114
|
-
if (!newValue && this.isAnnotationBeingEdited(this.emptyAnnotationId())) {
|
|
115
|
-
this.setText(
|
|
116
|
-
this.$t("draw_box_document", { label_name: this.label.name })
|
|
117
|
-
);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
newValue &&
|
|
123
|
-
this.editAnnotation &&
|
|
124
|
-
this.emptyAnnotationId() === this.editAnnotation.id
|
|
125
|
-
) {
|
|
126
|
-
const text = this.getTextFromEntities();
|
|
127
|
-
this.setText(text);
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
111
|
spanSelection(newValue) {
|
|
131
|
-
if (
|
|
132
|
-
const isSpanArray = Array.isArray(newValue);
|
|
112
|
+
if (!newValue) return;
|
|
133
113
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
) {
|
|
139
|
-
this.$store.dispatch("document/resetEditAnnotation");
|
|
140
|
-
this.$store.dispatch("selection/disableSelection");
|
|
141
|
-
}
|
|
114
|
+
// // Check if the bbox has no string
|
|
115
|
+
if (newValue[0] && !newValue[0].offset_string) {
|
|
116
|
+
this.$store.dispatch("document/resetEditAnnotation");
|
|
117
|
+
this.$store.dispatch("selection/disableSelection");
|
|
142
118
|
}
|
|
143
119
|
},
|
|
144
120
|
},
|
|
@@ -160,23 +136,22 @@ export default {
|
|
|
160
136
|
if (
|
|
161
137
|
this.publicView ||
|
|
162
138
|
this.isDocumentReviewed ||
|
|
163
|
-
this.
|
|
139
|
+
this.isMissingAnnotation
|
|
164
140
|
)
|
|
165
141
|
return;
|
|
166
142
|
|
|
167
143
|
if (
|
|
168
144
|
!this.publicView &&
|
|
169
145
|
!this.isDocumentReviewed &&
|
|
170
|
-
!this.isLoading &&
|
|
171
146
|
this.elementSelected !== this.emptyAnnotationId()
|
|
172
147
|
) {
|
|
173
|
-
this.
|
|
174
|
-
|
|
175
|
-
);
|
|
148
|
+
this.$store.dispatch("selection/disableSelection");
|
|
149
|
+
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
176
150
|
this.$store.dispatch(
|
|
177
151
|
"selection/selectElement",
|
|
178
152
|
this.emptyAnnotationId()
|
|
179
153
|
);
|
|
154
|
+
|
|
180
155
|
this.$store.dispatch("document/setEditAnnotation", {
|
|
181
156
|
id: this.emptyAnnotationId(),
|
|
182
157
|
index: this.spanIndex,
|
|
@@ -186,28 +161,10 @@ export default {
|
|
|
186
161
|
});
|
|
187
162
|
}
|
|
188
163
|
},
|
|
189
|
-
cancelEmptyAnnotation(wasOutsideClick = false) {
|
|
190
|
-
if (wasOutsideClick) {
|
|
191
|
-
this.setText(this.$t("no_data_found"));
|
|
192
|
-
} else {
|
|
193
|
-
this.$store.dispatch("selection/disableSelection");
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
this.isLoading = false;
|
|
197
|
-
this.$store.dispatch("document/setSelectedEntities", null);
|
|
198
|
-
|
|
199
|
-
if (this.$refs.emptyAnnotation) {
|
|
200
|
-
this.$refs.emptyAnnotation.blur();
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
164
|
isEmptyAnnotationEditable() {
|
|
204
|
-
if (
|
|
205
|
-
return (
|
|
206
|
-
this.elementSelected === this.emptyAnnotationId() && !this.isLoading
|
|
207
|
-
);
|
|
208
|
-
} else if (
|
|
165
|
+
if (
|
|
209
166
|
(this.spanSelection && this.spanSelection[this.spanIndex] === 0) ||
|
|
210
|
-
this.
|
|
167
|
+
this.isMissingAnnotation
|
|
211
168
|
) {
|
|
212
169
|
return false;
|
|
213
170
|
} else {
|
|
@@ -215,8 +172,7 @@ export default {
|
|
|
215
172
|
this.elementSelected === this.emptyAnnotationId() &&
|
|
216
173
|
this.spanSelection &&
|
|
217
174
|
this.spanSelection[this.spanIndex] &&
|
|
218
|
-
this.spanSelection[this.spanIndex].offset_string != null
|
|
219
|
-
!this.isLoading
|
|
175
|
+
this.spanSelection[this.spanIndex].offset_string != null
|
|
220
176
|
);
|
|
221
177
|
}
|
|
222
178
|
},
|
|
@@ -230,9 +186,6 @@ export default {
|
|
|
230
186
|
// API call handled in parent component - AnnotationRow
|
|
231
187
|
this.$emit("save-empty-annotation-changes");
|
|
232
188
|
},
|
|
233
|
-
setText(text) {
|
|
234
|
-
this.$refs.emptyAnnotation.innerHTML = text;
|
|
235
|
-
},
|
|
236
189
|
},
|
|
237
190
|
};
|
|
238
191
|
</script>
|