@konfuzio/document-validation-ui 0.1.44-dev.0 → 0.1.44-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/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/AnnotationDetails.vue +3 -7
- package/src/components/DocumentAnnotations/AnnotationRow.vue +19 -23
- package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +8 -22
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +6 -3
- package/src/components/DocumentAnnotations/DocumentLabel.vue +19 -5
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +8 -8
- package/src/components/DocumentPage/NewAnnotation.vue +10 -1
- package/src/store/document.js +58 -31
- package/src/store/project.js +12 -36
- package/src/components/DocumentTopBar/DocumentNameEditModal.vue +0 -186
package/package.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
<div>
|
|
3
3
|
<b-tooltip
|
|
4
4
|
:animated="false"
|
|
5
|
-
:position="
|
|
6
|
-
:class="[
|
|
5
|
+
:position="'is-bottom'"
|
|
6
|
+
:class="['left-aligned', 'annotation-details']"
|
|
7
7
|
>
|
|
8
|
-
<div :class="['label-icon'
|
|
8
|
+
<div :class="['label-icon']">
|
|
9
9
|
<div
|
|
10
10
|
v-if="
|
|
11
11
|
(created(annotation) || edited(annotation)) &&
|
|
@@ -180,10 +180,6 @@ export default {
|
|
|
180
180
|
type: Object,
|
|
181
181
|
default: null,
|
|
182
182
|
},
|
|
183
|
-
fromTable: {
|
|
184
|
-
type: Boolean,
|
|
185
|
-
default: false,
|
|
186
|
-
},
|
|
187
183
|
},
|
|
188
184
|
data() {
|
|
189
185
|
return {
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
:annotation="annotation"
|
|
25
25
|
:annotation-set="annotationSet"
|
|
26
26
|
:label="label"
|
|
27
|
-
:from-table="fromTable"
|
|
28
27
|
/>
|
|
29
28
|
</div>
|
|
30
29
|
|
|
@@ -129,6 +128,7 @@
|
|
|
129
128
|
:span-index="index"
|
|
130
129
|
:label="label"
|
|
131
130
|
:annotation-set="annotationSet"
|
|
131
|
+
:label-set="labelSet"
|
|
132
132
|
:is-hovered="hoveredAnnotation"
|
|
133
133
|
:is-missing-annotation="
|
|
134
134
|
annotationIsNotFound(annotationSet, label)
|
|
@@ -137,9 +137,10 @@
|
|
|
137
137
|
/>
|
|
138
138
|
</div>
|
|
139
139
|
<EmptyAnnotation
|
|
140
|
-
v-else
|
|
140
|
+
v-else
|
|
141
141
|
:label="label"
|
|
142
142
|
:annotation-set="annotationSet"
|
|
143
|
+
:label-set="labelSet"
|
|
143
144
|
:is-hovered="hoveredAnnotation"
|
|
144
145
|
:is-missing-annotation="annotationIsNotFound(annotationSet, label)"
|
|
145
146
|
@save-empty-annotation-changes="saveEmptyAnnotationChanges"
|
|
@@ -191,6 +192,10 @@ export default {
|
|
|
191
192
|
},
|
|
192
193
|
props: {
|
|
193
194
|
annotationSet: {
|
|
195
|
+
type: Object,
|
|
196
|
+
default: null,
|
|
197
|
+
},
|
|
198
|
+
labelSet: {
|
|
194
199
|
type: Object,
|
|
195
200
|
required: true,
|
|
196
201
|
},
|
|
@@ -206,10 +211,6 @@ export default {
|
|
|
206
211
|
type: Boolean,
|
|
207
212
|
default: true,
|
|
208
213
|
},
|
|
209
|
-
fromTable: {
|
|
210
|
-
type: Boolean,
|
|
211
|
-
default: false,
|
|
212
|
-
},
|
|
213
214
|
},
|
|
214
215
|
data() {
|
|
215
216
|
const checkboxValue =
|
|
@@ -284,6 +285,7 @@ export default {
|
|
|
284
285
|
return (
|
|
285
286
|
this.hoveredAnnotationSet &&
|
|
286
287
|
this.hoveredAnnotationSet.type == "missing" &&
|
|
288
|
+
this.annotationSet &&
|
|
287
289
|
!this.annotationIsNotFound(this.annotationSet, this.label) &&
|
|
288
290
|
this.annotationSet.id === this.hoveredAnnotationSet.annotationSet.id &&
|
|
289
291
|
this.annotationSet.label_set.id ===
|
|
@@ -417,7 +419,7 @@ export default {
|
|
|
417
419
|
}
|
|
418
420
|
},
|
|
419
421
|
currentAnnotationId() {
|
|
420
|
-
if (!this.annotationSet || !this.label) return;
|
|
422
|
+
if ((!this.annotationSet && !this.labelSet) || !this.label) return;
|
|
421
423
|
|
|
422
424
|
if (
|
|
423
425
|
this.annotation &&
|
|
@@ -426,20 +428,17 @@ export default {
|
|
|
426
428
|
)
|
|
427
429
|
return this.annotation.id;
|
|
428
430
|
|
|
429
|
-
|
|
431
|
+
const setId = this.annotationSet
|
|
432
|
+
? this.annotationSet.id
|
|
433
|
+
: this.labelSet.id;
|
|
430
434
|
|
|
431
|
-
|
|
432
|
-
emptyAnnotationId = `${this.annotationSet.id}_${this.label.id}`;
|
|
433
|
-
} else {
|
|
434
|
-
emptyAnnotationId = `${this.annotationSet.label_set.id}_${this.label.id}`;
|
|
435
|
-
}
|
|
436
|
-
return emptyAnnotationId;
|
|
435
|
+
return `${setId}_${this.label.id}`;
|
|
437
436
|
},
|
|
438
437
|
onAnnotationHoverEnter(span) {
|
|
439
438
|
if (span) {
|
|
440
439
|
this.$store.dispatch("document/setDocumentAnnotationSelected", {
|
|
441
440
|
annotation: this.annotation,
|
|
442
|
-
label: this.
|
|
441
|
+
label: this.label,
|
|
443
442
|
span,
|
|
444
443
|
scrollTo: false,
|
|
445
444
|
});
|
|
@@ -449,9 +448,6 @@ export default {
|
|
|
449
448
|
this.$store.dispatch("document/disableDocumentAnnotationSelected");
|
|
450
449
|
},
|
|
451
450
|
onAnnotationClick() {
|
|
452
|
-
if (!this.fromTable) {
|
|
453
|
-
this.$store.dispatch("display/showAnnSetTable", null);
|
|
454
|
-
}
|
|
455
451
|
this.$store.dispatch("document/scrollToDocumentAnnotationSelected");
|
|
456
452
|
},
|
|
457
453
|
hoveredEmptyLabels() {
|
|
@@ -571,7 +567,7 @@ export default {
|
|
|
571
567
|
this.$parent.$emit(
|
|
572
568
|
"handle-missing-annotation",
|
|
573
569
|
this.label.id,
|
|
574
|
-
this.
|
|
570
|
+
this.labelSet.id,
|
|
575
571
|
this.annotationSet.id,
|
|
576
572
|
false
|
|
577
573
|
);
|
|
@@ -636,7 +632,7 @@ export default {
|
|
|
636
632
|
(item) =>
|
|
637
633
|
item.annotation_set === this.annotationSet.id &&
|
|
638
634
|
item.label === this.label.id &&
|
|
639
|
-
item.label_set === this.annotationSet.
|
|
635
|
+
item.label_set === this.annotationSet.labelSet.id
|
|
640
636
|
);
|
|
641
637
|
|
|
642
638
|
this.$store
|
|
@@ -699,7 +695,7 @@ export default {
|
|
|
699
695
|
saveEmptyAnnotationChanges() {
|
|
700
696
|
let annotationToCreate;
|
|
701
697
|
|
|
702
|
-
if (this.annotationSet.id) {
|
|
698
|
+
if (this.annotationSet && this.annotationSet.id) {
|
|
703
699
|
annotationToCreate = {
|
|
704
700
|
document: this.documentId,
|
|
705
701
|
span: this.spanSelection,
|
|
@@ -714,7 +710,7 @@ export default {
|
|
|
714
710
|
document: this.documentId,
|
|
715
711
|
span: this.spanSelection,
|
|
716
712
|
label: this.label.id,
|
|
717
|
-
label_set: this.
|
|
713
|
+
label_set: this.labelSet.id,
|
|
718
714
|
is_correct: true,
|
|
719
715
|
revised: true,
|
|
720
716
|
};
|
|
@@ -778,7 +774,7 @@ export default {
|
|
|
778
774
|
this.annotationsMarkedAsMissing.map((annotation) => {
|
|
779
775
|
// Check if the annotation set and label are marked as missing
|
|
780
776
|
if (
|
|
781
|
-
annotation.label_set === this.
|
|
777
|
+
annotation.label_set === this.labelSet.id &&
|
|
782
778
|
annotation.annotation_set === this.annotationSet.id &&
|
|
783
779
|
annotation.label === this.label.id
|
|
784
780
|
) {
|
|
@@ -9,15 +9,12 @@
|
|
|
9
9
|
:on-cancel="close"
|
|
10
10
|
>
|
|
11
11
|
<section class="modal-card-body">
|
|
12
|
-
<
|
|
13
|
-
<b-icon icon="spinner" class="fa-spin loading-icon-size spinner" />
|
|
14
|
-
</b-loading>
|
|
15
|
-
<div v-if="!loading" class="content">
|
|
12
|
+
<div class="content">
|
|
16
13
|
<h3>
|
|
17
14
|
{{ $t("new_ann_set_title") }}
|
|
18
15
|
</h3>
|
|
19
16
|
<div>
|
|
20
|
-
<div v-if="
|
|
17
|
+
<div v-if="labelSetsFilteredForAnnotationSetCreation.length === 0">
|
|
21
18
|
<p v-html="$t('no_multi_ann_labelset_model')" />
|
|
22
19
|
</div>
|
|
23
20
|
<div v-else>
|
|
@@ -27,7 +24,7 @@
|
|
|
27
24
|
|
|
28
25
|
<div class="label-set-list">
|
|
29
26
|
<div
|
|
30
|
-
v-for="labelSetItem in
|
|
27
|
+
v-for="labelSetItem in labelSetsFilteredForAnnotationSetCreation"
|
|
31
28
|
:key="labelSetItem.id"
|
|
32
29
|
class="label-set-list-row"
|
|
33
30
|
>
|
|
@@ -71,31 +68,20 @@
|
|
|
71
68
|
* This component shows a modal to choose a label set from the project
|
|
72
69
|
*/
|
|
73
70
|
|
|
74
|
-
import { mapGetters
|
|
71
|
+
import { mapGetters } from "vuex";
|
|
75
72
|
|
|
76
73
|
export default {
|
|
77
74
|
name: "CreateAnnotationSetModal",
|
|
78
75
|
data() {
|
|
79
76
|
return {
|
|
80
|
-
labelSets: [],
|
|
81
77
|
show: true,
|
|
82
|
-
labels: [],
|
|
83
|
-
loading: true,
|
|
84
78
|
};
|
|
85
79
|
},
|
|
86
80
|
computed: {
|
|
87
|
-
...
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
mounted() {
|
|
92
|
-
this.$store.dispatch("project/fetchLabelSets").then((data) => {
|
|
93
|
-
this.labelSets = this.labelSetsFilteredForAnnotationSetCreation(
|
|
94
|
-
data,
|
|
95
|
-
this.annotationSets
|
|
96
|
-
);
|
|
97
|
-
this.loading = false;
|
|
98
|
-
});
|
|
81
|
+
...mapGetters("document", [
|
|
82
|
+
"numberOfLabelSetGroup",
|
|
83
|
+
"labelSetsFilteredForAnnotationSetCreation",
|
|
84
|
+
]),
|
|
99
85
|
},
|
|
100
86
|
methods: {
|
|
101
87
|
submit(labelSet) {
|
|
@@ -18,8 +18,6 @@
|
|
|
18
18
|
<LoadingAnnotations />
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
21
|
-
|
|
22
|
-
<!-- When there's no annotation sets -->
|
|
23
21
|
<div
|
|
24
22
|
v-else-if="
|
|
25
23
|
getAnnotationsFiltered.annotationSets.length === 0 &&
|
|
@@ -119,6 +117,7 @@
|
|
|
119
117
|
<DocumentLabel
|
|
120
118
|
:label="label"
|
|
121
119
|
:annotation-set="annotationSet"
|
|
120
|
+
:label-set="annotationSet.label_set"
|
|
122
121
|
:index-group="indexGroup"
|
|
123
122
|
@handle-missing-annotation="markAnnotationsAsMissing"
|
|
124
123
|
/>
|
|
@@ -570,7 +569,11 @@ export default {
|
|
|
570
569
|
annotation_set: annotationSet,
|
|
571
570
|
},
|
|
572
571
|
];
|
|
573
|
-
} else if (
|
|
572
|
+
} else if (
|
|
573
|
+
this.editAnnotation &&
|
|
574
|
+
this.editAnnotation.id !== null &&
|
|
575
|
+
this.editAnnotation.annotationSet
|
|
576
|
+
) {
|
|
574
577
|
// if annotation is marked as missing from "delete" key
|
|
575
578
|
|
|
576
579
|
missing = [
|
|
@@ -29,32 +29,41 @@
|
|
|
29
29
|
</div>
|
|
30
30
|
</div>
|
|
31
31
|
</div>
|
|
32
|
-
<div
|
|
32
|
+
<div
|
|
33
|
+
v-if="annotationSet && showAnnotationsGroup"
|
|
34
|
+
class="label-group-annotation-list"
|
|
35
|
+
>
|
|
33
36
|
<AnnotationRow
|
|
34
37
|
v-for="annotation in label.annotations"
|
|
35
38
|
:key="annotation.id"
|
|
36
39
|
:annotation="annotation"
|
|
37
40
|
:label="label"
|
|
38
41
|
:annotation-set="annotationSet"
|
|
42
|
+
:label-set="annotationSet.label_set"
|
|
39
43
|
/>
|
|
40
44
|
</div>
|
|
41
45
|
</div>
|
|
42
|
-
<div v-else-if="hasAnnotations">
|
|
46
|
+
<div v-else-if="annotationSet && hasAnnotations">
|
|
43
47
|
<AnnotationRow
|
|
44
48
|
v-for="annotation in label.annotations"
|
|
45
49
|
:key="annotation.id"
|
|
46
50
|
:annotation="annotation"
|
|
47
51
|
:label="label"
|
|
48
52
|
:annotation-set="annotationSet"
|
|
53
|
+
:label-set="annotationSet.label_set"
|
|
49
54
|
/>
|
|
50
55
|
</div>
|
|
51
|
-
<div v-else>
|
|
56
|
+
<div v-else-if="annotationSet">
|
|
52
57
|
<AnnotationRow
|
|
53
58
|
:annotation="singleAnnotation"
|
|
54
59
|
:label="label"
|
|
55
60
|
:annotation-set="annotationSet"
|
|
61
|
+
:label-set="annotationSet.label_set"
|
|
56
62
|
/>
|
|
57
63
|
</div>
|
|
64
|
+
<div v-else-if="labelSet">
|
|
65
|
+
<AnnotationRow :label="label" :label-set="labelSet" />
|
|
66
|
+
</div>
|
|
58
67
|
</div>
|
|
59
68
|
</template>
|
|
60
69
|
<script>
|
|
@@ -73,6 +82,10 @@ export default {
|
|
|
73
82
|
required: true,
|
|
74
83
|
},
|
|
75
84
|
annotationSet: {
|
|
85
|
+
type: Object,
|
|
86
|
+
default: null,
|
|
87
|
+
},
|
|
88
|
+
labelSet: {
|
|
76
89
|
type: Object,
|
|
77
90
|
required: true,
|
|
78
91
|
},
|
|
@@ -93,13 +106,13 @@ export default {
|
|
|
93
106
|
]),
|
|
94
107
|
...mapGetters("document", ["numberOfAcceptedAnnotationsInLabel"]),
|
|
95
108
|
singleAnnotation() {
|
|
96
|
-
if (this.label.annotations.length > 0) {
|
|
109
|
+
if (this.label.annotations && this.label.annotations.length > 0) {
|
|
97
110
|
return this.label.annotations[0];
|
|
98
111
|
}
|
|
99
112
|
return null;
|
|
100
113
|
},
|
|
101
114
|
hasAnnotations() {
|
|
102
|
-
return this.label.annotations.length > 0;
|
|
115
|
+
return this.label.annotations && this.label.annotations.length > 0;
|
|
103
116
|
},
|
|
104
117
|
},
|
|
105
118
|
watch: {
|
|
@@ -159,6 +172,7 @@ export default {
|
|
|
159
172
|
updateValues() {
|
|
160
173
|
// more than 1 Annotation extracted for a non multiple Label
|
|
161
174
|
this.nonMultipleAnnotationsExtracted =
|
|
175
|
+
this.label.annotations &&
|
|
162
176
|
this.label.annotations.length > 1 &&
|
|
163
177
|
!this.label.has_multiple_top_candidates;
|
|
164
178
|
|
|
@@ -55,6 +55,10 @@ export default {
|
|
|
55
55
|
required: true,
|
|
56
56
|
},
|
|
57
57
|
annotationSet: {
|
|
58
|
+
type: Object,
|
|
59
|
+
default: null,
|
|
60
|
+
},
|
|
61
|
+
labelSet: {
|
|
58
62
|
type: Object,
|
|
59
63
|
required: true,
|
|
60
64
|
},
|
|
@@ -118,13 +122,10 @@ export default {
|
|
|
118
122
|
|
|
119
123
|
methods: {
|
|
120
124
|
emptyAnnotationId() {
|
|
121
|
-
if (!this.annotationSet || !this.label) return;
|
|
125
|
+
if ((!this.annotationSet && !this.labelSet) || !this.label) return;
|
|
122
126
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
} else {
|
|
126
|
-
return `${this.annotationSet.label_set.id}_${this.label.id}`;
|
|
127
|
-
}
|
|
127
|
+
const id = this.annotationSet ? this.annotationSet.id : this.labelSet.id;
|
|
128
|
+
return `${id}_${this.label.id}`;
|
|
128
129
|
},
|
|
129
130
|
isAnnotationBeingEdited() {
|
|
130
131
|
return this.isAnnotationInEditMode(this.emptyAnnotationId());
|
|
@@ -148,12 +149,11 @@ export default {
|
|
|
148
149
|
"selection/selectElement",
|
|
149
150
|
this.emptyAnnotationId()
|
|
150
151
|
);
|
|
151
|
-
|
|
152
152
|
this.$store.dispatch("document/setEditAnnotation", {
|
|
153
153
|
id: this.emptyAnnotationId(),
|
|
154
154
|
index: this.spanIndex,
|
|
155
155
|
label: this.label,
|
|
156
|
-
labelSet: this.
|
|
156
|
+
labelSet: this.labelSet,
|
|
157
157
|
annotationSet: this.annotationSet,
|
|
158
158
|
});
|
|
159
159
|
}
|
|
@@ -329,12 +329,21 @@ export default {
|
|
|
329
329
|
});
|
|
330
330
|
},
|
|
331
331
|
chooseLabelSet(labelSet) {
|
|
332
|
+
// check if there's already a new entry for that label set to be created
|
|
333
|
+
const existsIndex = this.setsList.findIndex((set) => {
|
|
334
|
+
return set.id === null && set.label_set.id === labelSet.id;
|
|
335
|
+
});
|
|
336
|
+
|
|
332
337
|
const newSet = {
|
|
333
338
|
label_set: labelSet,
|
|
334
339
|
labels: labelSet.labels,
|
|
335
340
|
id: null,
|
|
336
341
|
};
|
|
337
|
-
|
|
342
|
+
if (existsIndex >= 0) {
|
|
343
|
+
this.setsList[existsIndex] = newSet;
|
|
344
|
+
} else {
|
|
345
|
+
this.setsList.push(newSet);
|
|
346
|
+
}
|
|
338
347
|
this.selectedSet = newSet;
|
|
339
348
|
},
|
|
340
349
|
openAnnotationSetCreation() {
|
package/src/store/document.js
CHANGED
|
@@ -301,13 +301,15 @@ const getters = {
|
|
|
301
301
|
let processedAnnotationSets = [];
|
|
302
302
|
let processedLabels = [];
|
|
303
303
|
|
|
304
|
+
const isSearching = state.annotationSearch.length > 0;
|
|
305
|
+
|
|
304
306
|
// search feature
|
|
305
307
|
const addAnnotation = (listToAdd, annotation, force) => {
|
|
306
308
|
if (force) {
|
|
307
309
|
listToAdd.push(annotation);
|
|
308
310
|
return true;
|
|
309
311
|
}
|
|
310
|
-
if (
|
|
312
|
+
if (isSearching) {
|
|
311
313
|
if (
|
|
312
314
|
annotation.offset_string &&
|
|
313
315
|
state.annotationSearch.find((search) =>
|
|
@@ -333,7 +335,7 @@ const getters = {
|
|
|
333
335
|
};
|
|
334
336
|
|
|
335
337
|
const labelHasSearchText = (label) => {
|
|
336
|
-
if (
|
|
338
|
+
if (isSearching) {
|
|
337
339
|
if (
|
|
338
340
|
label.name &&
|
|
339
341
|
state.annotationSearch.find((search) =>
|
|
@@ -356,7 +358,10 @@ const getters = {
|
|
|
356
358
|
let addLabel = false;
|
|
357
359
|
const labelHasSearch = labelHasSearchText(label);
|
|
358
360
|
if (!label.annotations || label.annotations.length === 0) {
|
|
359
|
-
if (
|
|
361
|
+
if (
|
|
362
|
+
state.annotationFilters.showEmpty &&
|
|
363
|
+
(!isSearching || labelHasSearch)
|
|
364
|
+
) {
|
|
360
365
|
addLabel = true;
|
|
361
366
|
}
|
|
362
367
|
} else if (
|
|
@@ -435,19 +440,17 @@ const getters = {
|
|
|
435
440
|
let processedLabels = [];
|
|
436
441
|
|
|
437
442
|
annotationSets.forEach((annotationSet) => {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
const labelAnnotations = [];
|
|
443
|
+
labels = [];
|
|
444
|
+
annotationSet.labels.forEach((label) => {
|
|
445
|
+
const labelAnnotations = [];
|
|
442
446
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
447
|
+
// add annotations to the document array
|
|
448
|
+
labelAnnotations.push(...label.annotations);
|
|
449
|
+
labels.push({ ...label, annotations: labelAnnotations });
|
|
450
|
+
processedLabels.push(label);
|
|
451
|
+
annotations.push(...labelAnnotations);
|
|
452
|
+
});
|
|
453
|
+
processedAnnotationSets.push({ ...annotationSet, labels });
|
|
451
454
|
});
|
|
452
455
|
return {
|
|
453
456
|
annotationSets: processedAnnotationSets,
|
|
@@ -518,20 +521,43 @@ const getters = {
|
|
|
518
521
|
orderedAnnotationSets.sort((a, b) => {
|
|
519
522
|
return a.id - b.id || a.label_set.name.localeCompare(b.label_set.name);
|
|
520
523
|
});
|
|
521
|
-
orderedAnnotationSets.
|
|
524
|
+
orderedAnnotationSets.forEach((annotationSetTemp) => {
|
|
522
525
|
if (
|
|
523
526
|
annotationSetTemp.label_set.id === labelSet.id &&
|
|
524
527
|
annotationSetTemp.label_set.name === labelSet.name
|
|
525
528
|
) {
|
|
526
529
|
found = true;
|
|
527
|
-
|
|
530
|
+
// check if annotation set exists, otherwise it will be new
|
|
531
|
+
if (annotationSetTemp.id) {
|
|
532
|
+
index++;
|
|
533
|
+
}
|
|
528
534
|
}
|
|
529
535
|
});
|
|
530
|
-
return found ? `${index + 1}` : "";
|
|
536
|
+
return found ? (index === 0 ? "" : `${index + 1}`) : "";
|
|
531
537
|
}
|
|
532
538
|
return "";
|
|
533
539
|
},
|
|
534
540
|
|
|
541
|
+
/**
|
|
542
|
+
* Gets label sets for an annotation set creation
|
|
543
|
+
*/
|
|
544
|
+
labelSetsFilteredForAnnotationSetCreation: (state) => {
|
|
545
|
+
let returnLabelSets = [];
|
|
546
|
+
if (state.annotationSets) {
|
|
547
|
+
state.annotationSets.forEach((annotationSet) => {
|
|
548
|
+
if (
|
|
549
|
+
annotationSet.id == null ||
|
|
550
|
+
annotationSet.label_set.has_multiple_annotation_sets
|
|
551
|
+
) {
|
|
552
|
+
const labelSet = { ...annotationSet.label_set };
|
|
553
|
+
labelSet.labels = [...annotationSet.labels];
|
|
554
|
+
returnLabelSets.push(labelSet);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
return returnLabelSets;
|
|
559
|
+
},
|
|
560
|
+
|
|
535
561
|
/**
|
|
536
562
|
* Get label with annotations filtered if the label supports multiple or not
|
|
537
563
|
*/
|
|
@@ -627,17 +653,20 @@ const getters = {
|
|
|
627
653
|
annotationIsNotFound: (state) => (annotationSet, label) => {
|
|
628
654
|
// Check if the combined label and label set have been marked as missing
|
|
629
655
|
// or if the document is in public mode
|
|
630
|
-
if (
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
(
|
|
635
|
-
el
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
656
|
+
if (annotationSet) {
|
|
657
|
+
if (state.missingAnnotations.length === 0) {
|
|
658
|
+
return false;
|
|
659
|
+
} else {
|
|
660
|
+
const found = state.missingAnnotations.filter(
|
|
661
|
+
(el) =>
|
|
662
|
+
el.label === label.id &&
|
|
663
|
+
el.annotation_set === annotationSet.id &&
|
|
664
|
+
el.label_set === annotationSet.label_set.id
|
|
665
|
+
);
|
|
666
|
+
return found.length !== 0;
|
|
667
|
+
}
|
|
640
668
|
}
|
|
669
|
+
return false;
|
|
641
670
|
},
|
|
642
671
|
|
|
643
672
|
isAnnotationInAnnotationSet: (state) => (annotationSet, annotationId) => {
|
|
@@ -1280,9 +1309,7 @@ const actions = {
|
|
|
1280
1309
|
|
|
1281
1310
|
fetchMissingAnnotations: ({ commit, state, getters }) => {
|
|
1282
1311
|
return new Promise((resolve, reject) => {
|
|
1283
|
-
return HTTP.get(
|
|
1284
|
-
`/missing-annotations/?document=${state.documentId}`
|
|
1285
|
-
)
|
|
1312
|
+
return HTTP.get(`/missing-annotations/?document=${state.documentId}`)
|
|
1286
1313
|
.then((response) => {
|
|
1287
1314
|
commit("SET_MISSING_ANNOTATIONS", response.data.results);
|
|
1288
1315
|
resolve(true);
|
package/src/store/project.js
CHANGED
|
@@ -3,36 +3,13 @@ const HTTP = myImports.HTTP;
|
|
|
3
3
|
|
|
4
4
|
const state = {
|
|
5
5
|
projectId: null,
|
|
6
|
+
labelSets: null,
|
|
6
7
|
currentUser: null,
|
|
7
8
|
documentsListPath: null,
|
|
8
9
|
documentsInProject: null,
|
|
9
10
|
showAnnotationTranslations: false,
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
const getters = {
|
|
13
|
-
/**
|
|
14
|
-
* Gets label sets for an annotation set creation
|
|
15
|
-
*/
|
|
16
|
-
labelSetsFilteredForAnnotationSetCreation:
|
|
17
|
-
(state) => (labelsSet, annotationSets) => {
|
|
18
|
-
let returnLabels = [];
|
|
19
|
-
if (labelsSet) {
|
|
20
|
-
returnLabels = labelsSet.filter((labelSet) => {
|
|
21
|
-
// check if label set has multiple and if not, if there's already an annotation set created
|
|
22
|
-
if (!labelSet.has_multiple_annotation_sets) {
|
|
23
|
-
const existingAnnotationSet = annotationSets.find((annSet) => {
|
|
24
|
-
return annSet.label_set.id === labelSet.id;
|
|
25
|
-
});
|
|
26
|
-
return !existingAnnotationSet;
|
|
27
|
-
} else {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return returnLabels;
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
13
|
const actions = {
|
|
37
14
|
setProjectId: ({ commit }, projectId) => {
|
|
38
15
|
commit("SET_PROJECT_ID", projectId);
|
|
@@ -52,17 +29,14 @@ const actions = {
|
|
|
52
29
|
},
|
|
53
30
|
|
|
54
31
|
// Get label sets from the project
|
|
55
|
-
fetchLabelSets: ({ state }) => {
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
console.log(error);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
32
|
+
fetchLabelSets: ({ commit, state }) => {
|
|
33
|
+
return HTTP.get(`label-sets/?project=${state.projectId}`)
|
|
34
|
+
.then((response) => {
|
|
35
|
+
commit("SET_LABEL_SETS", response.data.results);
|
|
36
|
+
})
|
|
37
|
+
.catch((error) => {
|
|
38
|
+
console.log(error);
|
|
39
|
+
});
|
|
66
40
|
},
|
|
67
41
|
|
|
68
42
|
fetchCurrentUser: ({ commit }) => {
|
|
@@ -113,6 +87,9 @@ const mutations = {
|
|
|
113
87
|
SET_CURRENT_USER: (state, currentUser) => {
|
|
114
88
|
state.currentUser = currentUser;
|
|
115
89
|
},
|
|
90
|
+
SET_LABEL_SETS: (state, labelSets) => {
|
|
91
|
+
state.labelSets = labelSets;
|
|
92
|
+
},
|
|
116
93
|
SET_DOCUMENTS_LIST_PATH: (state, path) => {
|
|
117
94
|
state.documentsListPath = path;
|
|
118
95
|
},
|
|
@@ -129,5 +106,4 @@ export default {
|
|
|
129
106
|
state,
|
|
130
107
|
actions,
|
|
131
108
|
mutations,
|
|
132
|
-
getters,
|
|
133
109
|
};
|