@konfuzio/document-validation-ui 0.1.8 → 0.1.9-pre-release-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/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/AnnotationDetails.vue +7 -5
- package/src/components/DocumentAnnotations/AnnotationRow.vue +82 -106
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +15 -8
- 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 +28 -22
- package/src/components/DocumentPage/DocumentToolbar.vue +14 -0
- 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/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 {
|