@konfuzio/document-validation-ui 0.1.59 → 0.2.0-dev.2
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/cypress.config.js +6 -6
- 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/dist/js/chunk-vendors.js +66 -23
- package/dist/js/chunk-vendors.js.map +1 -1
- package/jest.config.js +22 -2
- package/package.json +32 -38
- package/src/assets/scss/ann_set_table_options.scss +4 -4
- package/src/assets/scss/annotation_action_buttons.scss +29 -7
- package/src/assets/scss/annotation_details.scss +9 -9
- package/src/assets/scss/choose_label_set_modal.scss +5 -5
- package/src/assets/scss/document_action_bar.scss +3 -3
- package/src/assets/scss/document_annotations.scss +45 -45
- package/src/assets/scss/document_category.scss +8 -8
- package/src/assets/scss/document_dashboard.scss +6 -1
- package/src/assets/scss/document_edit.scss +30 -30
- package/src/assets/scss/document_error.scss +6 -6
- package/src/assets/scss/document_name.scss +6 -6
- package/src/assets/scss/document_page.scss +3 -3
- package/src/assets/scss/document_search_bar.scss +7 -7
- package/src/assets/scss/document_set_chooser.scss +3 -3
- package/src/assets/scss/document_thumbnails.scss +7 -7
- package/src/assets/scss/document_toolbar.scss +10 -10
- package/src/assets/scss/document_top_bar.scss +11 -11
- package/src/assets/scss/document_viewport_modal.scss +3 -3
- package/src/assets/scss/documents_list.scss +11 -12
- package/src/assets/scss/edit_page_thumbnail.scss +6 -6
- package/src/assets/scss/empty_state.scss +4 -4
- package/src/assets/scss/error_page.scss +2 -2
- package/src/assets/scss/extracting_data.scss +3 -3
- package/src/assets/scss/multi_ann_table_overlay.scss +3 -3
- package/src/assets/scss/multi_ann_table_popup.scss +1 -1
- package/src/assets/scss/new_annotation.scss +25 -19
- package/src/assets/scss/scrolling_document.scss +1 -1
- package/src/assets/scss/theme.scss +64 -52
- package/src/assets/scss/variables.scss +2 -0
- package/src/components/App.vue +9 -14
- package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +31 -7
- package/src/components/DocumentAnnotations/AnnotationContent.vue +25 -52
- package/src/components/DocumentAnnotations/AnnotationRow.vue +108 -51
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +12 -6
- package/src/components/DocumentAnnotations/DocumentLabel.vue +12 -122
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +31 -70
- package/src/components/DocumentDashboard.vue +12 -17
- package/src/components/DocumentEdit/EditPages.vue +51 -46
- package/src/components/DocumentEdit/EditSidebar.vue +0 -9
- package/src/components/DocumentPage/{NewAnnotation.vue → AnnotationPopup.vue} +123 -94
- package/src/components/DocumentPage/BoxSelection.vue +16 -49
- package/src/components/DocumentPage/DocumentPage.vue +56 -153
- package/src/components/DocumentPage/DocumentToolbar.vue +0 -1
- package/src/components/DocumentPage/PlaceholderSelection.vue +51 -0
- package/src/components/DocumentPage/SpanSelection.vue +259 -0
- package/src/components/DocumentThumbnails/LoadingThumbnail.vue +3 -6
- package/src/components/DocumentTopBar/DocumentTopBar.vue +4 -2
- package/src/constants.js +1 -7
- package/src/i18n.js +2 -5
- package/src/locales/de.json +2 -1
- package/src/locales/en.json +2 -1
- package/src/locales/es.json +2 -1
- package/src/main.js +14 -16
- package/src/store/display.js +33 -22
- package/src/store/document.js +131 -10
- package/src/store/index.js +5 -8
- package/src/store/selection.js +152 -76
- package/src/assets/scss/imports.scss +0 -1
- package/src/components/DocumentPage/EditAnnotation.vue +0 -372
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="action-buttons">
|
|
3
|
+
<!-- label multi false nav buttons -->
|
|
4
|
+
<b-tooltip
|
|
5
|
+
v-if="isLabelMultiFalseAndGroupOfAnns(label) && !showSave"
|
|
6
|
+
:delay="tooltipDelay"
|
|
7
|
+
position="is-left"
|
|
8
|
+
:label="$t('nav_label_anns')"
|
|
9
|
+
>
|
|
10
|
+
<div class="ann-nav-btns">
|
|
11
|
+
<span>{{ label.annotations.length }}</span>
|
|
12
|
+
<b-icon
|
|
13
|
+
icon="angle-down"
|
|
14
|
+
class="angle-icon center-icon button-icon is-link"
|
|
15
|
+
@click.stop="nextAnn"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
</b-tooltip>
|
|
19
|
+
|
|
3
20
|
<!-- link button -->
|
|
4
21
|
<b-button
|
|
5
22
|
v-if="showLink"
|
|
@@ -106,6 +123,7 @@
|
|
|
106
123
|
<!-- save button -->
|
|
107
124
|
<b-button
|
|
108
125
|
v-if="showSave"
|
|
126
|
+
id="save-ann"
|
|
109
127
|
:class="`button-action ${showText ? 'is-button-text' : 'is-button-icon'}`"
|
|
110
128
|
:type="showText ? 'is-primary' : 'is-ghost'"
|
|
111
129
|
@click.stop="save"
|
|
@@ -205,14 +223,15 @@ export default {
|
|
|
205
223
|
data() {
|
|
206
224
|
return {
|
|
207
225
|
tooltipDelay: 700,
|
|
208
|
-
showText:
|
|
209
|
-
window.innerWidth >
|
|
210
|
-
TEXT_BREAKPOINT_WIDTH(this.$i18n ? this.$i18n.locale : "en"),
|
|
226
|
+
showText: window.innerWidth > TEXT_BREAKPOINT_WIDTH,
|
|
211
227
|
};
|
|
212
228
|
},
|
|
213
229
|
computed: {
|
|
214
230
|
...mapState("document", ["publicView"]),
|
|
215
|
-
...mapGetters("document", [
|
|
231
|
+
...mapGetters("document", [
|
|
232
|
+
"isDocumentReviewed",
|
|
233
|
+
"isLabelMultiFalseAndGroupOfAnns",
|
|
234
|
+
]),
|
|
216
235
|
showHoverButton() {
|
|
217
236
|
return (
|
|
218
237
|
!this.isLoading &&
|
|
@@ -227,13 +246,12 @@ export default {
|
|
|
227
246
|
window.addEventListener("resize", this.resize);
|
|
228
247
|
},
|
|
229
248
|
|
|
230
|
-
|
|
249
|
+
unmounted() {
|
|
231
250
|
window.removeEventListener("resize", this.resize);
|
|
232
251
|
},
|
|
233
252
|
methods: {
|
|
234
253
|
resize() {
|
|
235
|
-
this.showText =
|
|
236
|
-
window.innerWidth > TEXT_BREAKPOINT_WIDTH(this.$i18n.locale);
|
|
254
|
+
this.showText = window.innerWidth > TEXT_BREAKPOINT_WIDTH;
|
|
237
255
|
},
|
|
238
256
|
search() {
|
|
239
257
|
this.$emit("search");
|
|
@@ -259,6 +277,12 @@ export default {
|
|
|
259
277
|
link() {
|
|
260
278
|
this.$emit("link");
|
|
261
279
|
},
|
|
280
|
+
nextAnn() {
|
|
281
|
+
this.$store.dispatch(
|
|
282
|
+
"document/putNextAnnotationInLabelFirst",
|
|
283
|
+
this.label
|
|
284
|
+
);
|
|
285
|
+
},
|
|
262
286
|
},
|
|
263
287
|
};
|
|
264
288
|
</script>
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
editAnnotation &&
|
|
12
12
|
editAnnotation.id === annotation.id &&
|
|
13
13
|
'error-editing',
|
|
14
|
-
|
|
14
|
+
isSpanBeingEdited && 'clicked-ann',
|
|
15
15
|
]"
|
|
16
16
|
role="textbox"
|
|
17
|
-
:contenteditable="
|
|
17
|
+
:contenteditable="isSpanBeingEdited"
|
|
18
18
|
@click="handleEditAnnotation"
|
|
19
19
|
@paste="handlePaste"
|
|
20
20
|
@keypress.enter="saveAnnotationChanges"
|
|
@@ -61,11 +61,7 @@ export default {
|
|
|
61
61
|
};
|
|
62
62
|
},
|
|
63
63
|
computed: {
|
|
64
|
-
...mapGetters("document", [
|
|
65
|
-
"isAnnotationInEditMode",
|
|
66
|
-
"pageAtIndex",
|
|
67
|
-
"isDocumentReviewed",
|
|
68
|
-
]),
|
|
64
|
+
...mapGetters("document", ["isAnnotationInEditMode", "isDocumentReviewed"]),
|
|
69
65
|
...mapGetters("display", ["bboxToRect"]),
|
|
70
66
|
...mapState("document", [
|
|
71
67
|
"editAnnotation",
|
|
@@ -74,19 +70,17 @@ export default {
|
|
|
74
70
|
"newAcceptedAnnotations",
|
|
75
71
|
"showActionError",
|
|
76
72
|
]),
|
|
77
|
-
|
|
73
|
+
isSpanBeingEdited() {
|
|
78
74
|
return this.isAnnotationInEditMode(this.annotation.id, this.spanIndex);
|
|
79
75
|
},
|
|
76
|
+
isAnnotationBeingEdited() {
|
|
77
|
+
return (
|
|
78
|
+
this.editAnnotation && this.annotation.id === this.editAnnotation.id
|
|
79
|
+
);
|
|
80
|
+
},
|
|
80
81
|
},
|
|
81
82
|
|
|
82
83
|
watch: {
|
|
83
|
-
isAnnotationBeingEdited(newState, oldState) {
|
|
84
|
-
// verify if new annotation in edit mode is not this one and if this
|
|
85
|
-
// one was selected before so we set the state to the previous one (like a cancel)
|
|
86
|
-
if (!newState && oldState) {
|
|
87
|
-
this.handleCancel();
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
84
|
span() {
|
|
91
85
|
// span content changed, ex. from click on entity
|
|
92
86
|
this.setText(this.span.offset_string);
|
|
@@ -110,10 +104,15 @@ export default {
|
|
|
110
104
|
if (
|
|
111
105
|
!this.publicView &&
|
|
112
106
|
!this.isDocumentReviewed &&
|
|
113
|
-
!this.
|
|
107
|
+
!this.isSpanBeingEdited &&
|
|
114
108
|
!this.isLoading
|
|
115
109
|
) {
|
|
116
|
-
|
|
110
|
+
if (!this.isAnnotationBeingEdited) {
|
|
111
|
+
this.$store.dispatch(
|
|
112
|
+
"selection/setSpanSelection",
|
|
113
|
+
this.annotation.span
|
|
114
|
+
);
|
|
115
|
+
}
|
|
117
116
|
|
|
118
117
|
this.$store
|
|
119
118
|
.dispatch("document/setEditAnnotation", {
|
|
@@ -125,44 +124,18 @@ export default {
|
|
|
125
124
|
pageNumber: this.span.page_index + 1,
|
|
126
125
|
})
|
|
127
126
|
.then(() => {
|
|
128
|
-
this.$refs.contentEditable
|
|
127
|
+
if (this.$refs.contentEditable) {
|
|
128
|
+
this.$refs.contentEditable.focus();
|
|
129
|
+
}
|
|
129
130
|
})
|
|
130
131
|
.catch((error) => {
|
|
131
132
|
console.log(error);
|
|
132
133
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const selection = {
|
|
139
|
-
start: {
|
|
140
|
-
x,
|
|
141
|
-
y,
|
|
142
|
-
},
|
|
143
|
-
end: {
|
|
144
|
-
x: x + width,
|
|
145
|
-
y: y + height,
|
|
146
|
-
},
|
|
147
|
-
pageNumber: page.number,
|
|
148
|
-
custom: false,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// check if this is part of a group of spans to show the whole bounding box as a placeholder
|
|
152
|
-
if (
|
|
153
|
-
this.annotation.selection_bbox &&
|
|
154
|
-
this.annotation.span.length > 1
|
|
155
|
-
) {
|
|
156
|
-
selection.placeholderBox = this.bboxToRect(
|
|
157
|
-
page,
|
|
158
|
-
this.annotation.selection_bbox
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
this.$store.dispatch("selection/setSelection", {
|
|
163
|
-
selection,
|
|
164
|
-
span: this.span,
|
|
165
|
-
});
|
|
134
|
+
// check if this is part of a group of spans to show the whole bounding box as a placeholder
|
|
135
|
+
if (this.annotation.selection_bbox && this.annotation.span.length > 1) {
|
|
136
|
+
this.$store.dispatch("selection/setPlaceholderSelection", [
|
|
137
|
+
this.annotation.selection_bbox,
|
|
138
|
+
]);
|
|
166
139
|
}
|
|
167
140
|
}
|
|
168
141
|
},
|
|
@@ -173,7 +146,7 @@ export default {
|
|
|
173
146
|
this.$refs.contentEditable.blur();
|
|
174
147
|
}
|
|
175
148
|
|
|
176
|
-
this.$store.dispatch("selection/
|
|
149
|
+
this.$store.dispatch("selection/setSpanSelection", null);
|
|
177
150
|
},
|
|
178
151
|
handlePaste(event) {
|
|
179
152
|
// TODO: modify to only paste plain text
|
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
>
|
|
16
16
|
<div class="annotations-width-slider">
|
|
17
17
|
<b-slider
|
|
18
|
-
|
|
18
|
+
v-model="labelContainerWidth"
|
|
19
19
|
type="is-move"
|
|
20
20
|
:min="20"
|
|
21
21
|
:max="80"
|
|
22
22
|
:custom-formatter="(val) => `${$t('label_size')} ${val}%`"
|
|
23
23
|
class="is-full-height show-hover show-line"
|
|
24
24
|
:disabled="isAnnotationInEditMode()"
|
|
25
|
-
@input="setLabelWidth"
|
|
26
25
|
/>
|
|
27
26
|
</div>
|
|
28
27
|
<div
|
|
@@ -98,7 +97,12 @@
|
|
|
98
97
|
|
|
99
98
|
<div class="annotation-row-right" :style="`width:${annotationWidth}%`">
|
|
100
99
|
<div class="annotation-content">
|
|
101
|
-
<div
|
|
100
|
+
<div
|
|
101
|
+
v-if="isAnnotationInEditMode(currentAnnotationId()) && spanLoading"
|
|
102
|
+
>
|
|
103
|
+
<b-icon style="width: 16px" icon="spinner" class="fa-spin" />
|
|
104
|
+
</div>
|
|
105
|
+
<div v-else-if="annotation" class="annotation-items">
|
|
102
106
|
<b-checkbox
|
|
103
107
|
v-if="annotation.metadata && annotation.metadata.checkbox"
|
|
104
108
|
v-model="isChecked"
|
|
@@ -129,7 +133,8 @@
|
|
|
129
133
|
<div v-else>
|
|
130
134
|
<div
|
|
131
135
|
v-if="
|
|
132
|
-
spanSelection &&
|
|
136
|
+
spanSelection.length > 0 &&
|
|
137
|
+
isAnnotationInEditMode(currentAnnotationId())
|
|
133
138
|
"
|
|
134
139
|
>
|
|
135
140
|
<EmptyAnnotation
|
|
@@ -166,6 +171,7 @@
|
|
|
166
171
|
>
|
|
167
172
|
<AnnotationActionButtons
|
|
168
173
|
:annotation="annotation"
|
|
174
|
+
:label="label"
|
|
169
175
|
:show-cancel="showCancelButton()"
|
|
170
176
|
:show-accept="showAcceptButton()"
|
|
171
177
|
:show-decline="showDeclineButton()"
|
|
@@ -244,6 +250,7 @@ export default {
|
|
|
244
250
|
checkboxDefaultValue: checkboxValue,
|
|
245
251
|
isCheckboxAvailable: false,
|
|
246
252
|
isChecked: checkboxValue,
|
|
253
|
+
labelContainerWidth: 0,
|
|
247
254
|
};
|
|
248
255
|
},
|
|
249
256
|
computed: {
|
|
@@ -251,7 +258,6 @@ export default {
|
|
|
251
258
|
"editAnnotation",
|
|
252
259
|
"annotationId",
|
|
253
260
|
"hoveredAnnotationSet",
|
|
254
|
-
"enableGroupingFeature",
|
|
255
261
|
"publicView",
|
|
256
262
|
"newAcceptedAnnotations",
|
|
257
263
|
"annotationsMarkedAsMissing",
|
|
@@ -261,8 +267,8 @@ export default {
|
|
|
261
267
|
]),
|
|
262
268
|
...mapState("selection", [
|
|
263
269
|
"spanSelection",
|
|
264
|
-
"elementSelected",
|
|
265
270
|
"selectedEntities",
|
|
271
|
+
"spanLoading",
|
|
266
272
|
]),
|
|
267
273
|
...mapState("display", ["labelWidth", "annotationWidth"]),
|
|
268
274
|
...mapState("project", ["showAnnotationTranslations"]),
|
|
@@ -319,6 +325,12 @@ export default {
|
|
|
319
325
|
},
|
|
320
326
|
},
|
|
321
327
|
watch: {
|
|
328
|
+
labelWidth(width) {
|
|
329
|
+
this.labelContainerWidth = width;
|
|
330
|
+
},
|
|
331
|
+
labelContainerWidth(width) {
|
|
332
|
+
this.setLabelWidth(width);
|
|
333
|
+
},
|
|
322
334
|
annotationId(newAnnotationId) {
|
|
323
335
|
this.checkAnnotationSelection(newAnnotationId);
|
|
324
336
|
},
|
|
@@ -383,6 +395,7 @@ export default {
|
|
|
383
395
|
},
|
|
384
396
|
mounted() {
|
|
385
397
|
this.checkAnnotationSelection(this.annotationId);
|
|
398
|
+
this.labelContainerWidth = this.labelWidth;
|
|
386
399
|
},
|
|
387
400
|
methods: {
|
|
388
401
|
...mapActions("display", ["setLabelWidth"]),
|
|
@@ -438,9 +451,10 @@ export default {
|
|
|
438
451
|
|
|
439
452
|
if (this.annotation && this.annotation.id) return this.annotation.id;
|
|
440
453
|
|
|
441
|
-
const setId =
|
|
442
|
-
|
|
443
|
-
|
|
454
|
+
const setId =
|
|
455
|
+
this.annotationSet && this.annotationSet.id
|
|
456
|
+
? this.annotationSet.id
|
|
457
|
+
: this.labelSet.id;
|
|
444
458
|
|
|
445
459
|
return `${setId}_${this.label.id}`;
|
|
446
460
|
},
|
|
@@ -573,11 +587,8 @@ export default {
|
|
|
573
587
|
} else {
|
|
574
588
|
if (!this.isAnnotationInEditMode(this.currentAnnotationId())) return;
|
|
575
589
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
this.spanSelection &&
|
|
579
|
-
Array.isArray(this.spanSelection)
|
|
580
|
-
);
|
|
590
|
+
// check if spans are selected
|
|
591
|
+
return this.spanSelection && this.spanSelection.length > 0;
|
|
581
592
|
}
|
|
582
593
|
},
|
|
583
594
|
handleMissingAnnotation() {
|
|
@@ -678,44 +689,93 @@ export default {
|
|
|
678
689
|
this.isLoading = true;
|
|
679
690
|
}, 100);
|
|
680
691
|
|
|
681
|
-
|
|
682
|
-
|
|
692
|
+
// check if annotation set was changed
|
|
693
|
+
if (
|
|
694
|
+
!isToDecline &&
|
|
695
|
+
((this.editAnnotation.annotationSet &&
|
|
696
|
+
(this.editAnnotation.annotationSet.id !== this.annotationSet.id ||
|
|
697
|
+
(this.editAnnotation.annotationSet.id == null &&
|
|
698
|
+
this.labelSet.id !== this.editAnnotation.labelSet.id))) ||
|
|
699
|
+
(this.editAnnotation.label &&
|
|
700
|
+
this.editAnnotation.label.id !== this.label.id))
|
|
701
|
+
) {
|
|
702
|
+
// first delete annotation, then create new one
|
|
703
|
+
this.$store
|
|
704
|
+
.dispatch("document/deleteAnnotation", {
|
|
705
|
+
annotationId: this.annotation.id,
|
|
706
|
+
})
|
|
707
|
+
.then(() => {
|
|
708
|
+
const annotationToCreate = {
|
|
709
|
+
document: this.documentId,
|
|
710
|
+
span: spans,
|
|
711
|
+
label: this.editAnnotation.label.id,
|
|
712
|
+
is_correct: true,
|
|
713
|
+
revised: false,
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
if (this.editAnnotation.annotationSet.id) {
|
|
717
|
+
annotationToCreate.annotation_set =
|
|
718
|
+
this.editAnnotation.annotationSet.id;
|
|
719
|
+
} else {
|
|
720
|
+
annotationToCreate.label_set = this.editAnnotation.labelSet.id;
|
|
721
|
+
}
|
|
683
722
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
723
|
+
this.$store
|
|
724
|
+
.dispatch("document/createAnnotation", {
|
|
725
|
+
annotation: annotationToCreate,
|
|
726
|
+
})
|
|
727
|
+
.catch((error) => {
|
|
728
|
+
this.$store.dispatch("document/createErrorMessage", {
|
|
729
|
+
error,
|
|
730
|
+
serverErrorMessage: this.$t("server_error"),
|
|
731
|
+
defaultErrorMessage: this.$t("error_creating_annotation"),
|
|
732
|
+
});
|
|
733
|
+
})
|
|
734
|
+
.finally(() => {
|
|
735
|
+
this.$store.dispatch("document/resetEditAnnotation");
|
|
736
|
+
this.$store.dispatch("selection/disableSelection");
|
|
737
|
+
this.loading = false;
|
|
738
|
+
});
|
|
739
|
+
});
|
|
687
740
|
} else {
|
|
688
|
-
//
|
|
689
|
-
//
|
|
690
|
-
storeAction = "document/updateAnnotation";
|
|
741
|
+
let updatedString; // what will be sent to the API
|
|
742
|
+
let storeAction; // if it will be 'delete' or 'patch'
|
|
691
743
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
744
|
+
// Verify if we delete the entire Annotation or a part of the text
|
|
745
|
+
if (isToDecline || spans.length === 0) {
|
|
746
|
+
storeAction = "document/deleteAnnotation";
|
|
747
|
+
} else {
|
|
748
|
+
// Editing the Annotation
|
|
749
|
+
// Deleting part of multi-line Annotation
|
|
750
|
+
storeAction = "document/updateAnnotation";
|
|
751
|
+
|
|
752
|
+
updatedString = {
|
|
753
|
+
is_correct: true,
|
|
754
|
+
revised: true,
|
|
755
|
+
span: spans,
|
|
756
|
+
};
|
|
757
|
+
}
|
|
698
758
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
759
|
+
// Send to the store for the http patch/delete request
|
|
760
|
+
this.$store
|
|
761
|
+
.dispatch(storeAction, {
|
|
762
|
+
updatedValues: updatedString,
|
|
763
|
+
annotationId: this.annotation.id,
|
|
764
|
+
annotationSet: this.annotationSet,
|
|
765
|
+
})
|
|
766
|
+
.catch((error) => {
|
|
767
|
+
this.$store.dispatch("document/createErrorMessage", {
|
|
768
|
+
error,
|
|
769
|
+
serverErrorMessage: this.$t("server_error"),
|
|
770
|
+
defaultErrorMessage: this.$t("edit_error"),
|
|
771
|
+
});
|
|
772
|
+
})
|
|
773
|
+
.finally(() => {
|
|
774
|
+
this.$store.dispatch("document/resetEditAnnotation");
|
|
775
|
+
this.$store.dispatch("selection/disableSelection");
|
|
776
|
+
this.isLoading = false;
|
|
711
777
|
});
|
|
712
|
-
|
|
713
|
-
.finally(() => {
|
|
714
|
-
this.$store.dispatch("document/resetEditAnnotation");
|
|
715
|
-
this.$store.dispatch("selection/disableSelection");
|
|
716
|
-
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
717
|
-
this.isLoading = false;
|
|
718
|
-
});
|
|
778
|
+
}
|
|
719
779
|
},
|
|
720
780
|
saveEmptyAnnotationChanges() {
|
|
721
781
|
let annotationToCreate;
|
|
@@ -760,10 +820,7 @@ export default {
|
|
|
760
820
|
},
|
|
761
821
|
handleCancelButton() {
|
|
762
822
|
this.$store.dispatch("document/resetEditAnnotation");
|
|
763
|
-
|
|
764
|
-
this.$store.dispatch("selection/disableSelection");
|
|
765
|
-
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
766
|
-
}
|
|
823
|
+
this.$store.dispatch("selection/disableSelection");
|
|
767
824
|
this.isLoading = false;
|
|
768
825
|
},
|
|
769
826
|
enableLoading(annotations) {
|
|
@@ -105,7 +105,10 @@
|
|
|
105
105
|
</div>
|
|
106
106
|
</div>
|
|
107
107
|
|
|
108
|
-
<b-collapse
|
|
108
|
+
<b-collapse
|
|
109
|
+
:model-value="isAccordionOpen(annotationSet)"
|
|
110
|
+
animation="slide"
|
|
111
|
+
>
|
|
109
112
|
<div
|
|
110
113
|
v-if="annotationSet.labels.length > 0"
|
|
111
114
|
class="annotation-sets-list"
|
|
@@ -194,6 +197,7 @@ export default {
|
|
|
194
197
|
|
|
195
198
|
computed: {
|
|
196
199
|
...mapState("display", ["showAnnSetTable", "showBranding"]),
|
|
200
|
+
...mapState("edit", ["editMode"]),
|
|
197
201
|
...mapState("document", [
|
|
198
202
|
"annotationSets",
|
|
199
203
|
"documentId",
|
|
@@ -221,7 +225,7 @@ export default {
|
|
|
221
225
|
return this.editAnnotation && this.editAnnotation.id;
|
|
222
226
|
},
|
|
223
227
|
isDocumentEditable() {
|
|
224
|
-
return !this.publicView && !this.isDocumentReviewed;
|
|
228
|
+
return !this.publicView && !this.isDocumentReviewed && !this.editMode;
|
|
225
229
|
},
|
|
226
230
|
},
|
|
227
231
|
watch: {
|
|
@@ -273,7 +277,7 @@ export default {
|
|
|
273
277
|
this.loadAccordions(this.getAnnotationsFiltered.annotationSets);
|
|
274
278
|
}
|
|
275
279
|
},
|
|
276
|
-
|
|
280
|
+
unmounted() {
|
|
277
281
|
window.removeEventListener("keydown", this.keyDownHandler);
|
|
278
282
|
},
|
|
279
283
|
methods: {
|
|
@@ -404,9 +408,11 @@ export default {
|
|
|
404
408
|
},
|
|
405
409
|
|
|
406
410
|
createArray(className) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
411
|
+
if (this.$refs.annotationList) {
|
|
412
|
+
return Array.from(
|
|
413
|
+
this.$refs.annotationList.getElementsByClassName(className)
|
|
414
|
+
);
|
|
415
|
+
}
|
|
410
416
|
},
|
|
411
417
|
|
|
412
418
|
keyDownHandler(event) {
|
|
@@ -1,43 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="label">
|
|
3
|
-
<div
|
|
4
|
-
v-if="isGroup"
|
|
5
|
-
:class="['label-group', !showAnnotationsGroup && 'keyboard-nav']"
|
|
6
|
-
@click.stop="toggleGroup"
|
|
7
|
-
>
|
|
8
|
-
<div class="label-group-left">
|
|
9
|
-
<b-icon
|
|
10
|
-
:icon="showAnnotationsGroup ? 'angle-up' : 'angle-down'"
|
|
11
|
-
size="is-16"
|
|
12
|
-
class="caret"
|
|
13
|
-
/>
|
|
14
|
-
<div class="label-name">
|
|
15
|
-
<span>{{ `${label.name} (${label.annotations.length})` }}</span>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
<div class="label-group-right">
|
|
19
|
-
<div v-if="!publicView" class="label-annotations-pending">
|
|
20
|
-
{{
|
|
21
|
-
`${label.annotations.length - acceptedAnnotationsGroupCounter} ${$t(
|
|
22
|
-
"annotations_pending"
|
|
23
|
-
)}`
|
|
24
|
-
}}
|
|
25
|
-
</div>
|
|
26
|
-
<div v-if="!publicView" class="label-annotations-accepted">
|
|
27
|
-
{{
|
|
28
|
-
`${acceptedAnnotationsGroupCounter} ${$t("annotations_accepted")}`
|
|
29
|
-
}}
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
<div
|
|
34
|
-
v-if="showAnnotationsGroup && annotationSet"
|
|
35
|
-
:class="isGroup && 'label-group-annotation-list'"
|
|
36
|
-
>
|
|
3
|
+
<div v-if="annotationSet">
|
|
37
4
|
<AnnotationRow
|
|
38
|
-
v-for="(annotation, index) in
|
|
39
|
-
? label.annotations
|
|
40
|
-
: [singleAnnotation]"
|
|
5
|
+
v-for="(annotation, index) in annotationsToShow()"
|
|
41
6
|
:key="index"
|
|
42
7
|
:annotation="annotation"
|
|
43
8
|
:label="label"
|
|
@@ -45,7 +10,7 @@
|
|
|
45
10
|
:label-set="annotationSet.label_set"
|
|
46
11
|
/>
|
|
47
12
|
</div>
|
|
48
|
-
<div v-else-if="
|
|
13
|
+
<div v-else-if="labelSet">
|
|
49
14
|
<AnnotationRow :label="label" :label-set="labelSet" />
|
|
50
15
|
</div>
|
|
51
16
|
</div>
|
|
@@ -74,94 +39,19 @@ export default {
|
|
|
74
39
|
required: true,
|
|
75
40
|
},
|
|
76
41
|
},
|
|
77
|
-
data() {
|
|
78
|
-
return {
|
|
79
|
-
nonMultipleAnnotationsExtracted: false,
|
|
80
|
-
acceptedAnnotationsGroupCounter: 0,
|
|
81
|
-
showAnnotationsGroup: false,
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
42
|
computed: {
|
|
85
|
-
...mapState("document", [
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"publicView",
|
|
43
|
+
...mapState("document", ["annotationId", "publicView"]),
|
|
44
|
+
...mapGetters("document", [
|
|
45
|
+
"numberOfAcceptedAnnotationsInLabel",
|
|
46
|
+
"isLabelMultiFalseAndGroupOfAnns",
|
|
90
47
|
]),
|
|
91
|
-
...mapGetters("document", ["numberOfAcceptedAnnotationsInLabel"]),
|
|
92
|
-
singleAnnotation() {
|
|
93
|
-
if (this.label.annotations && this.label.annotations.length > 0) {
|
|
94
|
-
return this.label.annotations[0];
|
|
95
|
-
}
|
|
96
|
-
return null;
|
|
97
|
-
},
|
|
98
|
-
hasAnnotations() {
|
|
99
|
-
return this.label.annotations && this.label.annotations.length > 0;
|
|
100
|
-
},
|
|
101
|
-
isGroup() {
|
|
102
|
-
return this.enableGroupingFeature && this.nonMultipleAnnotationsExtracted;
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
watch: {
|
|
106
|
-
annotationId(newAnnotationId) {
|
|
107
|
-
this.checkAnnotationSelected(newAnnotationId);
|
|
108
|
-
},
|
|
109
|
-
hoveredAnnotationSet(newValue) {
|
|
110
|
-
// Check if there are some unrevised Annotations within the group
|
|
111
|
-
if (
|
|
112
|
-
newValue &&
|
|
113
|
-
newValue.type === "accept" &&
|
|
114
|
-
this.labelHasPendingAnnotations(newValue)
|
|
115
|
-
) {
|
|
116
|
-
this.showAnnotationsGroup = true;
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
mounted() {
|
|
121
|
-
this.updateValues();
|
|
122
|
-
this.checkAnnotationSelected(this.annotationId);
|
|
123
|
-
|
|
124
|
-
if (this.publicView) {
|
|
125
|
-
this.showAnnotationsGroup = true;
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
updated() {
|
|
129
|
-
this.updateValues();
|
|
130
48
|
},
|
|
131
49
|
methods: {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
newAnnotationId
|
|
138
|
-
) {
|
|
139
|
-
const annotation = this.label.annotations.find(
|
|
140
|
-
(ann) => ann.id == newAnnotationId
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
if (annotation) {
|
|
144
|
-
this.showAnnotationsGroup = true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
toggleGroup() {
|
|
149
|
-
this.showAnnotationsGroup = !this.showAnnotationsGroup;
|
|
150
|
-
},
|
|
151
|
-
updateValues() {
|
|
152
|
-
// more than 1 Annotation extracted for a non multiple Label
|
|
153
|
-
this.nonMultipleAnnotationsExtracted =
|
|
154
|
-
this.label.annotations &&
|
|
155
|
-
this.label.annotations.length > 1 &&
|
|
156
|
-
!this.label.has_multiple_top_candidates;
|
|
157
|
-
|
|
158
|
-
if (this.nonMultipleAnnotationsExtracted) {
|
|
159
|
-
this.acceptedAnnotationsGroupCounter =
|
|
160
|
-
this.numberOfAcceptedAnnotationsInLabel(this.label);
|
|
161
|
-
}
|
|
162
|
-
if (!this.isGroup) {
|
|
163
|
-
// if not a group then show by default
|
|
164
|
-
this.showAnnotationsGroup = true;
|
|
50
|
+
annotationsToShow() {
|
|
51
|
+
if (this.isLabelMultiFalseAndGroupOfAnns(this.label)) {
|
|
52
|
+
return [this.label.annotations[0]];
|
|
53
|
+
} else {
|
|
54
|
+
return this.label.annotations;
|
|
165
55
|
}
|
|
166
56
|
},
|
|
167
57
|
labelHasPendingAnnotations(hoveredSet) {
|