@konfuzio/document-validation-ui 0.1.18-dev.2 → 0.1.18-dev.3
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/components/DocumentAnnotations/AnnotationRow.vue +1 -0
- package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +1 -0
- package/src/components/DocumentPage/AnnSetTableOptions.vue +1 -0
- package/src/store/document.js +82 -22
package/package.json
CHANGED
|
@@ -262,6 +262,7 @@ export default {
|
|
|
262
262
|
await this.$store
|
|
263
263
|
.dispatch("document/deleteAnnotation", {
|
|
264
264
|
annotationId: annotationToDelete.id,
|
|
265
|
+
annotationSet: null, // TODO: test if annotation set should be added if the feature is available again
|
|
265
266
|
})
|
|
266
267
|
.catch((error) => {
|
|
267
268
|
this.$store.dispatch("document/createErrorMessage", {
|
|
@@ -88,6 +88,7 @@ export default {
|
|
|
88
88
|
this.$store
|
|
89
89
|
.dispatch("document/deleteAnnotation", {
|
|
90
90
|
annotationId: annotationToDelete.id,
|
|
91
|
+
annotationSet: null, // TODO: test if annotation set should be added if the feature is available again
|
|
91
92
|
})
|
|
92
93
|
.catch((error) => {
|
|
93
94
|
this.$store.dispatch("document/createErrorMessage", {
|
package/src/store/document.js
CHANGED
|
@@ -333,7 +333,7 @@ const getters = {
|
|
|
333
333
|
// check which one has more confidence or if it's the same, then check if one is revised or not
|
|
334
334
|
if (
|
|
335
335
|
highestConfidenceAnnotation.confidence <
|
|
336
|
-
|
|
336
|
+
label.annotations[i].confidence ||
|
|
337
337
|
(highestConfidenceAnnotation.confidence ===
|
|
338
338
|
label.annotations[i].confidence &&
|
|
339
339
|
label.annotations[i].revised)
|
|
@@ -358,17 +358,17 @@ const getters = {
|
|
|
358
358
|
*/
|
|
359
359
|
isAnnotationInEditMode:
|
|
360
360
|
(state) =>
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
361
|
+
(annotationId, index = null) => {
|
|
362
|
+
if (state.editAnnotation && annotationId) {
|
|
363
|
+
if (index != null) {
|
|
364
|
+
return (
|
|
365
|
+
state.editAnnotation.id === annotationId &&
|
|
366
|
+
state.editAnnotation.index === index
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
return state.editAnnotation.id === annotationId;
|
|
368
370
|
}
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
},
|
|
371
|
+
},
|
|
372
372
|
|
|
373
373
|
/**
|
|
374
374
|
* Get number of empty labels per annotation set
|
|
@@ -514,14 +514,14 @@ const getters = {
|
|
|
514
514
|
*/
|
|
515
515
|
documentCannotBeEdited:
|
|
516
516
|
(state) =>
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
517
|
+
(document = state.selectedDocument) => {
|
|
518
|
+
return (
|
|
519
|
+
document.dataset_status === 1 ||
|
|
520
|
+
document.dataset_status === 2 ||
|
|
521
|
+
document.dataset_status === 3 ||
|
|
522
|
+
document.is_reviewed
|
|
523
|
+
);
|
|
524
|
+
},
|
|
525
525
|
|
|
526
526
|
/**
|
|
527
527
|
* If automatic splitting is enabled for the project
|
|
@@ -596,8 +596,8 @@ const getters = {
|
|
|
596
596
|
},
|
|
597
597
|
|
|
598
598
|
/**
|
|
599
|
-
|
|
600
|
-
|
|
599
|
+
* Check for user who created or revised the annotation
|
|
600
|
+
*/
|
|
601
601
|
getUser: () => (annotation) => {
|
|
602
602
|
if (annotation) {
|
|
603
603
|
if (annotation.created_by && !annotation.revised) {
|
|
@@ -614,6 +614,35 @@ const getters = {
|
|
|
614
614
|
return null;
|
|
615
615
|
}
|
|
616
616
|
},
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Check if there is just one annotation set from a label set
|
|
620
|
+
*/
|
|
621
|
+
isOnlyMultipleAnnotationSet: (state) => (annotationSet) => {
|
|
622
|
+
const sameSets = state.annotationSets.filter(set => set.label_set.id === annotationSet.label_set.id);
|
|
623
|
+
|
|
624
|
+
return sameSets.length === 1 ? true : false;
|
|
625
|
+
},
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Check if the annotation set can appear multiple times
|
|
629
|
+
*/
|
|
630
|
+
annotationSetCanBeMultiple: (_) => (annotationSet) => {
|
|
631
|
+
return annotationSet.label_set.has_multiple_annotation_sets;
|
|
632
|
+
},
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Check if the annotation set has only empty labels
|
|
636
|
+
*/
|
|
637
|
+
annotationSetHasNoFilledLabels: (_) => (annotationSet) => {
|
|
638
|
+
const annotations = annotationSet.labels.flatMap(label => {
|
|
639
|
+
return label.annotations;
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
console.log(annotations);
|
|
643
|
+
|
|
644
|
+
return annotations.length === 0 ? true : false;
|
|
645
|
+
},
|
|
617
646
|
};
|
|
618
647
|
|
|
619
648
|
const actions = {
|
|
@@ -907,13 +936,24 @@ const actions = {
|
|
|
907
936
|
});
|
|
908
937
|
},
|
|
909
938
|
|
|
910
|
-
deleteAnnotation: ({ commit, getters
|
|
939
|
+
deleteAnnotation: ({ commit, getters }, { annotationId, annotationSet }) => {
|
|
911
940
|
return new Promise((resolve, reject) => {
|
|
912
941
|
HTTP.delete(`/annotations/${annotationId}/`)
|
|
913
942
|
.then(async (response) => {
|
|
914
943
|
if (response.status === 204) {
|
|
915
944
|
commit("DELETE_ANNOTATION", annotationId);
|
|
916
945
|
|
|
946
|
+
// Check if the deleted annotation was the last one in a multiple annotation set
|
|
947
|
+
// and if the annotation set has no annotations
|
|
948
|
+
if (annotationSet && getters.annotationSetCanBeMultiple(annotationSet) && getters.annotationSetHasNoFilledLabels(annotationSet)) {
|
|
949
|
+
// Check if there is still 1 or more multiple annotation sets for the same label set
|
|
950
|
+
if (getters.isOnlyMultipleAnnotationSet(annotationSet)) {
|
|
951
|
+
commit("UPDATE_ANNOTATION_SET", annotationSet);
|
|
952
|
+
} else {
|
|
953
|
+
commit("DELETE_ANNOTATION_SET", annotationSet);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
917
957
|
resolve(true);
|
|
918
958
|
}
|
|
919
959
|
})
|
|
@@ -1245,6 +1285,26 @@ const mutations = {
|
|
|
1245
1285
|
SET_ANNOTATION_SETS: (state, annotationSets) => {
|
|
1246
1286
|
state.annotationSets = annotationSets;
|
|
1247
1287
|
},
|
|
1288
|
+
DELETE_ANNOTATION_SET: (state, annotationSet) => {
|
|
1289
|
+
const indexOfSetToDelete = state.annotationSets.findIndex(
|
|
1290
|
+
(existingAnnotationSet) => existingAnnotationSet.id === annotationSet.id
|
|
1291
|
+
);
|
|
1292
|
+
|
|
1293
|
+
if (indexOfSetToDelete === -1) return;
|
|
1294
|
+
|
|
1295
|
+
state.annotationSets.splice(indexOfSetToDelete, 1);
|
|
1296
|
+
},
|
|
1297
|
+
UPDATE_ANNOTATION_SET: (state, annotationSet) => {
|
|
1298
|
+
const indexOfExistingAnnotationSet = state.annotationSets.findIndex(
|
|
1299
|
+
(existingAnnotationSet) => existingAnnotationSet.id === annotationSet.id
|
|
1300
|
+
);
|
|
1301
|
+
|
|
1302
|
+
if (indexOfExistingAnnotationSet === -1) return;
|
|
1303
|
+
|
|
1304
|
+
const updatedSet = { ...annotationSet, id: null };
|
|
1305
|
+
|
|
1306
|
+
state.annotationSets.splice(indexOfExistingAnnotationSet, 1, updatedSet);
|
|
1307
|
+
},
|
|
1248
1308
|
SET_LABELS: (state, labels) => {
|
|
1249
1309
|
state.labels = labels;
|
|
1250
1310
|
},
|