@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
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
</div>
|
|
37
37
|
<div
|
|
38
38
|
v-if="
|
|
39
|
-
selectedDocument &&
|
|
39
|
+
selectedDocument &&
|
|
40
|
+
waitingForSplittingConfirmation(selectedDocument) &&
|
|
41
|
+
!documentBeingSplit
|
|
40
42
|
"
|
|
41
43
|
>
|
|
42
44
|
<SplittingSuggestionsModal />
|
|
@@ -101,10 +103,11 @@ export default {
|
|
|
101
103
|
"selectedDocument",
|
|
102
104
|
"splittingSuggestions",
|
|
103
105
|
]),
|
|
104
|
-
...mapState("edit", ["editMode", "splitOverview"]),
|
|
106
|
+
...mapState("edit", ["editMode", "splitOverview", "documentBeingSplit"]),
|
|
105
107
|
...mapGetters("display", ["isMinimumWidth"]),
|
|
106
108
|
...mapGetters("document", ["waitingForSplittingConfirmation"]),
|
|
107
109
|
},
|
|
110
|
+
|
|
108
111
|
watch: {
|
|
109
112
|
selectedDocument(newDocument, oldDocument) {
|
|
110
113
|
if (newDocument && !oldDocument) {
|
|
@@ -231,7 +231,11 @@ export default {
|
|
|
231
231
|
const newPage = { page: page, origin: origin };
|
|
232
232
|
const removedPage = { page: 0, origin: origin };
|
|
233
233
|
|
|
234
|
-
if (
|
|
234
|
+
if (this.splitSuggestionsEnabled && origin === "AI") {
|
|
235
|
+
// if manual suggestions were added but we enable automatic splitting,
|
|
236
|
+
// this last one takes over
|
|
237
|
+
this.splittingLines.splice(page - 1, 1, newPage);
|
|
238
|
+
} else if (
|
|
235
239
|
page === this.splittingLines.length ||
|
|
236
240
|
(!this.splitSuggestionsEnabled && !found && origin === "AI")
|
|
237
241
|
) {
|
|
@@ -239,10 +243,6 @@ export default {
|
|
|
239
243
|
// Or if splitting is switched off, but some of the suggestion lines
|
|
240
244
|
// were removed manually
|
|
241
245
|
return;
|
|
242
|
-
} else if (this.splitSuggestionsEnabled && origin === "AI") {
|
|
243
|
-
// if manual suggestions were added but we enable automatic splitting,
|
|
244
|
-
// this last one takes over
|
|
245
|
-
this.splittingLines.splice(page - 1, 1, newPage);
|
|
246
246
|
} else if (found) {
|
|
247
247
|
// If splitting is switched off and we have manual splits,
|
|
248
248
|
// those should stay unchanged
|
|
@@ -102,7 +102,10 @@ export default {
|
|
|
102
102
|
this.selection.start,
|
|
103
103
|
this.selection.end
|
|
104
104
|
);
|
|
105
|
-
this.$store.dispatch("selection/getTextFromBboxes",
|
|
105
|
+
this.$store.dispatch("selection/getTextFromBboxes", {
|
|
106
|
+
box,
|
|
107
|
+
entities: false,
|
|
108
|
+
});
|
|
106
109
|
},
|
|
107
110
|
|
|
108
111
|
/**
|
|
@@ -221,7 +221,6 @@ export default {
|
|
|
221
221
|
scaled: {
|
|
222
222
|
...box,
|
|
223
223
|
},
|
|
224
|
-
clickSelected: false,
|
|
225
224
|
};
|
|
226
225
|
});
|
|
227
226
|
},
|
|
@@ -258,6 +257,7 @@ export default {
|
|
|
258
257
|
"isSelecting",
|
|
259
258
|
"selectionFromBbox",
|
|
260
259
|
"spanSelection",
|
|
260
|
+
"selectedEntities",
|
|
261
261
|
]),
|
|
262
262
|
...mapState("display", [
|
|
263
263
|
"scale",
|
|
@@ -271,7 +271,6 @@ export default {
|
|
|
271
271
|
"editAnnotation",
|
|
272
272
|
"selectedDocument",
|
|
273
273
|
"publicView",
|
|
274
|
-
"selectedEntities",
|
|
275
274
|
]),
|
|
276
275
|
...mapState("edit", ["editMode"]),
|
|
277
276
|
...mapGetters("display", ["visiblePageRange", "bboxToRect"]),
|
|
@@ -292,10 +291,13 @@ export default {
|
|
|
292
291
|
scale() {
|
|
293
292
|
this.closePopups(true);
|
|
294
293
|
},
|
|
295
|
-
selectedEntities(newValue) {
|
|
294
|
+
async selectedEntities(newValue) {
|
|
296
295
|
if (!newValue) {
|
|
296
|
+
this.$store.dispatch("selection/setSpanSelection", null);
|
|
297
297
|
this.closePopups(true);
|
|
298
298
|
}
|
|
299
|
+
|
|
300
|
+
await this.$store.dispatch("selection/getTextFromEntities", newValue);
|
|
299
301
|
},
|
|
300
302
|
page(newValue, oldValue) {
|
|
301
303
|
if (newValue.image_url !== oldValue.image_url) {
|
|
@@ -406,24 +408,22 @@ export default {
|
|
|
406
408
|
return;
|
|
407
409
|
|
|
408
410
|
// Check if we are creating a new Annotation
|
|
409
|
-
// or if we are
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
content: entity.original.offset_string,
|
|
413
|
-
};
|
|
411
|
+
// or if we are removing a previously selected entity
|
|
412
|
+
// or editing empty one
|
|
413
|
+
const entityToAdd = entity;
|
|
414
414
|
|
|
415
415
|
const found = this.newAnnotation.find(
|
|
416
416
|
(ann) =>
|
|
417
|
-
ann.
|
|
418
|
-
ann.
|
|
417
|
+
ann.scaled.width === entityToAdd.scaled.width &&
|
|
418
|
+
ann.original.offset_string === entityToAdd.original.offset_string
|
|
419
419
|
);
|
|
420
420
|
|
|
421
421
|
if (found) {
|
|
422
422
|
this.newAnnotation = [
|
|
423
423
|
...this.newAnnotation.filter(
|
|
424
424
|
(ann) =>
|
|
425
|
-
ann.
|
|
426
|
-
ann.
|
|
425
|
+
ann.scaled.width !== entityToAdd.scaled.width &&
|
|
426
|
+
ann.original.offset_string !== entityToAdd.original.offset_string
|
|
427
427
|
),
|
|
428
428
|
];
|
|
429
429
|
} else {
|
|
@@ -432,11 +432,11 @@ export default {
|
|
|
432
432
|
|
|
433
433
|
if (this.newAnnotation.length > 0) {
|
|
434
434
|
this.$store.dispatch(
|
|
435
|
-
"
|
|
435
|
+
"selection/setSelectedEntities",
|
|
436
436
|
this.newAnnotation
|
|
437
437
|
);
|
|
438
438
|
} else {
|
|
439
|
-
this.$store.dispatch("
|
|
439
|
+
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
440
440
|
}
|
|
441
441
|
},
|
|
442
442
|
|
|
@@ -492,10 +492,10 @@ export default {
|
|
|
492
492
|
if (this.newAnnotation && this.newAnnotation.length > 0) {
|
|
493
493
|
entityIsSelected = this.newAnnotation.find((selectedEntity) => {
|
|
494
494
|
return (
|
|
495
|
-
selectedEntity.
|
|
495
|
+
selectedEntity.original.offset_string ===
|
|
496
496
|
entity.original.offset_string &&
|
|
497
|
-
selectedEntity.
|
|
498
|
-
selectedEntity.
|
|
497
|
+
selectedEntity.original.x0 === entity.original.x0 &&
|
|
498
|
+
selectedEntity.original.y0 === entity.original.y0
|
|
499
499
|
);
|
|
500
500
|
});
|
|
501
501
|
}
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
type="is-primary"
|
|
111
111
|
class="popup-button primary-button"
|
|
112
112
|
:label="$t('save')"
|
|
113
|
-
:disabled="loading || !
|
|
113
|
+
:disabled="loading || !spanSelection || !selectedLabel"
|
|
114
114
|
@click.prevent="save"
|
|
115
115
|
/>
|
|
116
116
|
</div>
|
|
@@ -158,22 +158,22 @@ export default {
|
|
|
158
158
|
...mapGetters("document", [
|
|
159
159
|
"numberOfAnnotationSetGroup",
|
|
160
160
|
"labelsFilteredForAnnotationCreation",
|
|
161
|
-
"getTextFromEntities",
|
|
162
161
|
]),
|
|
162
|
+
...mapState("selection", ["spanSelection"]),
|
|
163
163
|
top() {
|
|
164
|
-
const top = this.newAnnotation[0].
|
|
164
|
+
const top = this.newAnnotation[0].scaled.y - heightOfPopup; // subtract the height of the popup plus some margin
|
|
165
165
|
|
|
166
166
|
//check if the popup will not go off the container on the top
|
|
167
|
-
return this.newAnnotation[0].
|
|
167
|
+
return this.newAnnotation[0].scaled.y > heightOfPopup
|
|
168
168
|
? top
|
|
169
|
-
: this.newAnnotation[0].
|
|
170
|
-
this.newAnnotation[0].
|
|
169
|
+
: this.newAnnotation[0].scaled.y +
|
|
170
|
+
this.newAnnotation[0].scaled.height +
|
|
171
171
|
margin;
|
|
172
172
|
},
|
|
173
173
|
left() {
|
|
174
174
|
const left =
|
|
175
|
-
this.newAnnotation[0].
|
|
176
|
-
this.newAnnotation[0].
|
|
175
|
+
this.newAnnotation[0].scaled.x +
|
|
176
|
+
this.newAnnotation[0].scaled.width / 2 -
|
|
177
177
|
widthOfPopup / 2; // add the entity half width to be centered and then subtract half the width of the popup
|
|
178
178
|
|
|
179
179
|
//check if the popup will not go off the container
|
|
@@ -186,7 +186,15 @@ export default {
|
|
|
186
186
|
}
|
|
187
187
|
},
|
|
188
188
|
textFromEntities() {
|
|
189
|
-
|
|
189
|
+
if (!this.spanSelection) return;
|
|
190
|
+
|
|
191
|
+
// get array of all offset strings
|
|
192
|
+
let text = this.spanSelection.map((span) => {
|
|
193
|
+
return span.offset_string;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// join all the strings to become a single string of text
|
|
197
|
+
return text.join().split(",").join(" ");
|
|
190
198
|
},
|
|
191
199
|
},
|
|
192
200
|
watch: {
|
|
@@ -210,13 +218,16 @@ export default {
|
|
|
210
218
|
},
|
|
211
219
|
methods: {
|
|
212
220
|
close() {
|
|
213
|
-
this.$store.dispatch("
|
|
221
|
+
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
214
222
|
this.$emit("close");
|
|
215
223
|
},
|
|
216
224
|
save() {
|
|
217
225
|
this.loading = true;
|
|
218
226
|
const span = this.newAnnotation.flatMap((ann) => {
|
|
219
|
-
return {
|
|
227
|
+
return {
|
|
228
|
+
...ann.original,
|
|
229
|
+
offset_string: ann.original.offset_string,
|
|
230
|
+
};
|
|
220
231
|
});
|
|
221
232
|
|
|
222
233
|
const annotationToCreate = {
|
package/src/locales/de.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"no_label_sets_found_description": "In diesem Dokument sind keine Label Sets vorhanden.",
|
|
4
4
|
"no_labels_found": "Keine Labels vorhanden",
|
|
5
5
|
"no_labels_description": "In diesem Label Set sind keine Labels vorhanden.",
|
|
6
|
-
"resolution_not_supported": "Die
|
|
6
|
+
"resolution_not_supported": "Die aktuelle Auflösung wird nicht unterstützt",
|
|
7
7
|
"upload_documents": "Laden Sie Ihre Dokumente hoch",
|
|
8
8
|
"request_trial": "Fordern Sie Ihren Probezugang an",
|
|
9
9
|
"warning_message": "Die KI kann nicht trainiert werden, wenn Sie den Text manuell ändern.",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"invalid_email": "Bitte geben Sie eine gültige E-Mail-Adresse ein.",
|
|
27
27
|
"members": "Mitglieder",
|
|
28
28
|
"select": "Auswählen",
|
|
29
|
-
"document_successfully_handed": "Dokument erfolgreich
|
|
30
|
-
"handover_not_possible": "Eine
|
|
31
|
-
"small_viewport_title": "Kleine
|
|
32
|
-
"small_viewport_info": "Es tut uns leid, aber Konfuzio ist nicht für diese
|
|
33
|
-
"ok": "Ok
|
|
29
|
+
"document_successfully_handed": "Dokument erfolgreich zugewiesen an",
|
|
30
|
+
"handover_not_possible": "Eine Zuweisung war nicht möglich. Bitte versuchen Sie es später erneut.",
|
|
31
|
+
"small_viewport_title": "Kleine Fenstergröße",
|
|
32
|
+
"small_viewport_info": "Es tut uns leid, aber Konfuzio ist nicht für diese Fenstergröße optimiert. Für eine bessere Bedienbarkeit öffnen Sie es bitte in einem größeren Ansichtsfenster.",
|
|
33
|
+
"ok": "Ok",
|
|
34
34
|
"no_data_found": "Zum Bearbeiten anklicken...",
|
|
35
35
|
"draw_box_document": "Find <i>{label_name}</i> in the document",
|
|
36
36
|
"confidence": "Konfidenz",
|
|
@@ -52,9 +52,10 @@
|
|
|
52
52
|
"missing_annotation": "Als fehlend markieren",
|
|
53
53
|
"ann_exists": "Eine Annotation für dieses Label und Label-Set existiert bereits.",
|
|
54
54
|
"lite_mode": "Schreibgeschützt",
|
|
55
|
-
"limited_functionalities": "Sie verwenden die schreibgeschützte Version mit
|
|
55
|
+
"limited_functionalities": "Sie verwenden die schreibgeschützte Version mit begrenzte Funktionalität.",
|
|
56
56
|
"split": "Aufteilen",
|
|
57
|
-
"reorder": "
|
|
57
|
+
"reorder": "Sortieren",
|
|
58
|
+
"rotate": "Rotieren",
|
|
58
59
|
"edit_error": "Die Änderungen konnten nicht gespeichert werden. Bitte versuchen Sie es später erneut.",
|
|
59
60
|
"overview": "Übersicht",
|
|
60
61
|
"select_pages": "Sie können nun Seiten drehen, neu sortieren und Dokumente splitten.",
|
|
@@ -116,7 +117,7 @@
|
|
|
116
117
|
"split_modal_title": "Dokument aufteilen",
|
|
117
118
|
"split_modal_body": "Wir haben Ihre Datei gescannt und <strong>{number_of_split_documents}</strong> verschiedene Dokumente gefunde. <strong>Wir empfehlen dringend,</strong> sie zu diesem Zeitpunkt aufzuteilen, da sonst alle Fortschritte, die Sie gemacht haben, aufgrund der erneuten Extraktion der Dokumentdaten verloren gehen.",
|
|
118
119
|
"do_it_later": "Ich werde es später machen",
|
|
119
|
-
"review_now": "Jetzt
|
|
120
|
+
"review_now": "Jetzt überprüfen",
|
|
120
121
|
"recommended": "Empfohlen",
|
|
121
122
|
"smart_split": "Smart Split",
|
|
122
123
|
"smart_split_suggestions": "Unsere Smart Split-Vorschläge sind grün hervorgehoben",
|
|
@@ -125,10 +126,10 @@
|
|
|
125
126
|
"splitting_warning": "Beachten Sie bitte, dass alle Annotationen, die Sie in diesem Dokument gemacht haben, nicht gespeichert werden, wenn Sie fortfahren.",
|
|
126
127
|
"no": "Nein",
|
|
127
128
|
"yes": "Ja",
|
|
128
|
-
"split_modal_no_suggestions": "
|
|
129
|
+
"split_modal_no_suggestions": "Soll das Dokument geteilt werden? Wir <strong>empfehlen</strong> das Dokument jetzt zuteilen, da sonst alle Fortschritte, die in der Zwischenzeit gemacht werden,verloren gehen.",
|
|
129
130
|
"missing_from_document": "Fehlt im Dokument",
|
|
130
|
-
"edit_label": "
|
|
131
|
-
"delete_label": "
|
|
132
|
-
"table": "
|
|
133
|
-
"
|
|
131
|
+
"edit_label": "Label editieren",
|
|
132
|
+
"delete_label": "Label löschen",
|
|
133
|
+
"table": "Tabelle",
|
|
134
|
+
"prepare_document": "Dokument vorbereiten"
|
|
134
135
|
}
|
package/src/locales/en.json
CHANGED
package/src/locales/es.json
CHANGED
|
@@ -124,10 +124,12 @@
|
|
|
124
124
|
"splitting_warning": "Ten en cuenta que se perderán las anotaciones que hayas confirmado en el documento.",
|
|
125
125
|
"no": "No",
|
|
126
126
|
"yes": "Sí",
|
|
127
|
-
"split_modal_no_suggestions": "
|
|
127
|
+
"split_modal_no_suggestions": "¿Necesitas dividir el documento? <strong>Te recomendamos</strong> hacerlo en este momento, o de lo contrario se perderán los cambios realizados.",
|
|
128
128
|
"missing_from_document": "Falta en el documento",
|
|
129
129
|
"edit_label": "Edit label",
|
|
130
130
|
"delete_label": "Delete label",
|
|
131
131
|
"table": "Table",
|
|
132
|
-
"
|
|
132
|
+
"new_multi_ann_description": "Selecciona un modelo de datos de los existentes, luego deselecciona las etiquetas que no existen en este documento.",
|
|
133
|
+
"new_multi_ann_title": "Crear múltiples anotaciones",
|
|
134
|
+
"prepare_document": "Prepara el documento"
|
|
133
135
|
}
|
package/src/store/category.js
CHANGED
package/src/store/document.js
CHANGED
|
@@ -26,7 +26,6 @@ const state = {
|
|
|
26
26
|
errorMessageWidth: null,
|
|
27
27
|
hoveredAnnotationSet: null,
|
|
28
28
|
newAcceptedAnnotations: null,
|
|
29
|
-
selectedEntities: null,
|
|
30
29
|
serverError: false,
|
|
31
30
|
splittingSuggestions: null,
|
|
32
31
|
};
|
|
@@ -394,12 +393,7 @@ const getters = {
|
|
|
394
393
|
el.annotation_set === annotationSet.id &&
|
|
395
394
|
el.label_set === annotationSet.label_set.id
|
|
396
395
|
);
|
|
397
|
-
|
|
398
|
-
if (found.length !== 0) {
|
|
399
|
-
return true;
|
|
400
|
-
} else {
|
|
401
|
-
return false;
|
|
402
|
-
}
|
|
396
|
+
return found.length !== 0;
|
|
403
397
|
}
|
|
404
398
|
},
|
|
405
399
|
|
|
@@ -533,18 +527,6 @@ const getters = {
|
|
|
533
527
|
return document.proposed_split && document.proposed_split.length > 0;
|
|
534
528
|
},
|
|
535
529
|
|
|
536
|
-
/**
|
|
537
|
-
* Joins all strings in a multi-entity Annotation array
|
|
538
|
-
* to look like a single string
|
|
539
|
-
*/
|
|
540
|
-
getTextFromEntities: (state) => () => {
|
|
541
|
-
return state.selectedEntities
|
|
542
|
-
.map((entity) => {
|
|
543
|
-
return entity.content;
|
|
544
|
-
})
|
|
545
|
-
.join(" ");
|
|
546
|
-
},
|
|
547
|
-
|
|
548
530
|
/**
|
|
549
531
|
* Check the level of confidence of an annotation
|
|
550
532
|
*/
|
|
@@ -700,9 +682,6 @@ const actions = {
|
|
|
700
682
|
setNewAcceptedAnnotations: ({ commit }, annotations) => {
|
|
701
683
|
commit("SET_NEW_ACCEPTED_ANNOTATIONS", annotations);
|
|
702
684
|
},
|
|
703
|
-
setSelectedEntities: ({ commit }, entities) => {
|
|
704
|
-
commit("SET_SELECTED_ENTITIES", entities);
|
|
705
|
-
},
|
|
706
685
|
setSplittingSuggestions: ({ commit }, value) => {
|
|
707
686
|
commit("SET_SPLITTING_SUGGESTIONS", value);
|
|
708
687
|
},
|
|
@@ -1255,10 +1234,29 @@ const mutations = {
|
|
|
1255
1234
|
SET_MISSING_ANNOTATIONS: (state, missingAnnotations) => {
|
|
1256
1235
|
state.missingAnnotations = missingAnnotations;
|
|
1257
1236
|
},
|
|
1258
|
-
ADD_MISSING_ANNOTATIONS: (state,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1237
|
+
ADD_MISSING_ANNOTATIONS: (state, annotations) => {
|
|
1238
|
+
if (annotations && annotations.length > 0) {
|
|
1239
|
+
annotations.map((annotation) => {
|
|
1240
|
+
// check if already in missingAnnotations
|
|
1241
|
+
const found = state.missingAnnotations.find(
|
|
1242
|
+
(missingAnnotation) => missingAnnotation.id === annotation.id
|
|
1243
|
+
);
|
|
1244
|
+
|
|
1245
|
+
if (found) {
|
|
1246
|
+
const indexOfAnnotation = state.missingAnnotations.findIndex(
|
|
1247
|
+
(missingAnnotation) => missingAnnotation.id === annotation.id
|
|
1248
|
+
);
|
|
1249
|
+
|
|
1250
|
+
if (indexOfAnnotation > -1) {
|
|
1251
|
+
state.missingAnnotations.splice(indexOfAnnotation, 1, annotation);
|
|
1252
|
+
}
|
|
1253
|
+
} else {
|
|
1254
|
+
state.missingAnnotations.push(annotation);
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
} else {
|
|
1258
|
+
state.missingAnnotations.push(annotations);
|
|
1259
|
+
}
|
|
1262
1260
|
},
|
|
1263
1261
|
DELETE_MISSING_ANNOTATION: (state, id) => {
|
|
1264
1262
|
const indexOfAnnotationToDelete = state.missingAnnotations.findIndex(
|
|
@@ -1299,9 +1297,6 @@ const mutations = {
|
|
|
1299
1297
|
SET_NEW_ACCEPTED_ANNOTATIONS: (state, annotations) => {
|
|
1300
1298
|
state.newAcceptedAnnotations = annotations;
|
|
1301
1299
|
},
|
|
1302
|
-
SET_SELECTED_ENTITIES: (state, entities) => {
|
|
1303
|
-
state.selectedEntities = entities;
|
|
1304
|
-
},
|
|
1305
1300
|
SET_SERVER_ERROR: (state, value) => {
|
|
1306
1301
|
state.serverError = value;
|
|
1307
1302
|
},
|
package/src/store/edit.js
CHANGED
|
@@ -15,6 +15,7 @@ const state = {
|
|
|
15
15
|
selectedPages: [],
|
|
16
16
|
updatedDocument: [],
|
|
17
17
|
showEditConfirmationModal: false,
|
|
18
|
+
documentBeingSplit: false,
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
const getters = {
|
|
@@ -45,6 +46,10 @@ const actions = {
|
|
|
45
46
|
commit("SET_UPDATED_DOCUMENT", updatedDocument);
|
|
46
47
|
},
|
|
47
48
|
|
|
49
|
+
setDocumentBeingSplit: ({ commit }, value) => {
|
|
50
|
+
commit("SET_DOCUMENT_BEING_SPLIT", value);
|
|
51
|
+
},
|
|
52
|
+
|
|
48
53
|
selectPage: ({ state, commit }, page) => {
|
|
49
54
|
if (state.isMultipleSelection) {
|
|
50
55
|
commit("ADD_SELECTED_PAGE", page);
|
|
@@ -177,11 +182,13 @@ const actions = {
|
|
|
177
182
|
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
178
183
|
},
|
|
179
184
|
|
|
180
|
-
editDocument: ({ rootState, dispatch }, editedDocument) => {
|
|
185
|
+
editDocument: ({ rootState, commit, dispatch }, editedDocument) => {
|
|
181
186
|
dispatch("document/startRecalculatingAnnotations", null, {
|
|
182
187
|
root: true,
|
|
183
188
|
});
|
|
184
189
|
|
|
190
|
+
commit("SET_DOCUMENT_BEING_SPLIT", true);
|
|
191
|
+
|
|
185
192
|
const oldId = rootState.document.documentId;
|
|
186
193
|
|
|
187
194
|
return new Promise((resolve, reject) => {
|
|
@@ -194,6 +201,8 @@ const actions = {
|
|
|
194
201
|
const newId = response.data[0].id;
|
|
195
202
|
dispatch("document/setSplittingSuggestions", null, { root: true });
|
|
196
203
|
|
|
204
|
+
commit("SET_DOCUMENT_BEING_SPLIT", false);
|
|
205
|
+
|
|
197
206
|
if (newId !== oldId) {
|
|
198
207
|
if (getURLQueryParam("document") || getURLPath("docs")) {
|
|
199
208
|
navigateToNewDocumentURL(oldId, newId);
|
|
@@ -250,6 +259,9 @@ const mutations = {
|
|
|
250
259
|
SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
|
|
251
260
|
state.showEditConfirmationModal = value;
|
|
252
261
|
},
|
|
262
|
+
SET_DOCUMENT_BEING_SPLIT: (state, value) => {
|
|
263
|
+
state.documentBeingSplit = value;
|
|
264
|
+
},
|
|
253
265
|
};
|
|
254
266
|
|
|
255
267
|
export default {
|
package/src/store/selection.js
CHANGED
|
@@ -14,6 +14,7 @@ const state = {
|
|
|
14
14
|
isSelecting: false,
|
|
15
15
|
spanSelection: null,
|
|
16
16
|
elementSelected: null, // selected element id
|
|
17
|
+
selectedEntities: null,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
const getters = {
|
|
@@ -37,9 +38,6 @@ const getters = {
|
|
|
37
38
|
}
|
|
38
39
|
return null;
|
|
39
40
|
},
|
|
40
|
-
isValueArray: () => (value) => {
|
|
41
|
-
return Array.isArray(value);
|
|
42
|
-
},
|
|
43
41
|
};
|
|
44
42
|
|
|
45
43
|
const actions = {
|
|
@@ -70,7 +68,7 @@ const actions = {
|
|
|
70
68
|
commit("MOVE_SELECTION", points);
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
commit("SET_SELECTED_ENTITIES", null);
|
|
74
72
|
},
|
|
75
73
|
|
|
76
74
|
endSelection: ({ commit, state }, end) => {
|
|
@@ -99,9 +97,23 @@ const actions = {
|
|
|
99
97
|
commit("SET_SPAN_SELECTION", span);
|
|
100
98
|
},
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
setSelectedEntities: ({ commit }, entities) => {
|
|
101
|
+
commit("SET_SELECTED_ENTITIES", entities);
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
getTextFromBboxes: ({ commit, rootState }, { box, entities }) => {
|
|
105
|
+
let span;
|
|
106
|
+
|
|
107
|
+
if (entities) {
|
|
108
|
+
span = box.flatMap((s) => {
|
|
109
|
+
return s.original;
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
span = [box];
|
|
113
|
+
}
|
|
114
|
+
|
|
103
115
|
return HTTP.post(`documents/${rootState.document.documentId}/bbox/`, {
|
|
104
|
-
span
|
|
116
|
+
span,
|
|
105
117
|
})
|
|
106
118
|
.then((response) => {
|
|
107
119
|
if (response.data.span.length && response.data.span.length > 0) {
|
|
@@ -119,13 +131,23 @@ const actions = {
|
|
|
119
131
|
* an annotation on this empty area, adding the offset_string
|
|
120
132
|
* attribute, ready to be filled.
|
|
121
133
|
*/
|
|
122
|
-
commit("SET_SPAN_SELECTION",
|
|
134
|
+
commit("SET_SPAN_SELECTION", span);
|
|
123
135
|
}
|
|
124
136
|
})
|
|
125
137
|
.catch((error) => {
|
|
126
138
|
alert("Could not fetch the selected text from the backend");
|
|
127
139
|
});
|
|
128
140
|
},
|
|
141
|
+
|
|
142
|
+
getTextFromEntities: ({ commit, dispatch }, selectedEntities) => {
|
|
143
|
+
if (!selectedEntities) return;
|
|
144
|
+
|
|
145
|
+
return dispatch("getTextFromBboxes", {
|
|
146
|
+
box: selectedEntities,
|
|
147
|
+
entities: true,
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
|
|
129
151
|
setSpanSelection: ({ commit }, span) => {
|
|
130
152
|
commit("SET_SPAN_SELECTION", span);
|
|
131
153
|
},
|
|
@@ -167,6 +189,9 @@ const mutations = {
|
|
|
167
189
|
SET_SELECTION: (state, selection) => {
|
|
168
190
|
state.selection = selection;
|
|
169
191
|
},
|
|
192
|
+
SET_SELECTED_ENTITIES: (state, entities) => {
|
|
193
|
+
state.selectedEntities = entities;
|
|
194
|
+
},
|
|
170
195
|
};
|
|
171
196
|
|
|
172
197
|
export default {
|