@konfuzio/document-validation-ui 0.1.17-dev.1 → 0.1.17-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/api.js +4 -1
- package/src/assets/images/TranslateArrows.vue +24 -0
- package/src/assets/scss/document_annotations.scss +37 -0
- package/src/components/App.vue +0 -15
- package/src/components/DocumentAnnotations/AnnotationContent.vue +2 -7
- package/src/components/DocumentAnnotations/AnnotationDetails.vue +5 -28
- package/src/components/DocumentAnnotations/AnnotationRow.vue +102 -19
- package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +3 -3
- package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +42 -2
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +7 -24
- package/src/components/DocumentAnnotations/DocumentLabel.vue +3 -3
- package/src/components/DocumentEdit/DocumentEdit.cy.js +20 -18
- package/src/components/DocumentPage/DocumentPage.vue +2 -1
- package/src/components/DocumentPage/NewAnnotation.vue +18 -1
- package/src/components/DocumentTopBar/DocumentTopBar.cy.js +23 -23
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +4 -1
- package/src/locales/de.json +4 -1
- package/src/locales/en.json +4 -1
- package/src/locales/es.json +4 -1
- package/src/store/document.js +87 -61
- package/src/store/project.js +19 -1
- package/src/assets/images/UserIcon.vue +0 -8
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
17
|
<div class="label-group-right">
|
|
18
|
-
<div v-if="!publicView" class="label-annotations-pending"
|
|
18
|
+
<div v-if="!publicView" class="label-annotations-pending">
|
|
19
19
|
{{
|
|
20
20
|
`${
|
|
21
21
|
label.annotations.length - acceptedAnnotationsGroupCounter
|
|
@@ -149,7 +149,7 @@ export default {
|
|
|
149
149
|
mounted() {
|
|
150
150
|
this.updateValues();
|
|
151
151
|
|
|
152
|
-
if(this.publicView) {
|
|
152
|
+
if (this.publicView) {
|
|
153
153
|
this.showAnnotationsGroup = true;
|
|
154
154
|
}
|
|
155
155
|
},
|
|
@@ -174,7 +174,7 @@ export default {
|
|
|
174
174
|
labelHasPendingAnnotations(hoveredSet) {
|
|
175
175
|
if (!hoveredSet) return;
|
|
176
176
|
|
|
177
|
-
const found = this.label.annotations.find((ann) => !ann.
|
|
177
|
+
const found = this.label.annotations.find((ann) => !ann.is_correct);
|
|
178
178
|
|
|
179
179
|
return this.annotationSet.id === hoveredSet.annotationSet.id && found;
|
|
180
180
|
},
|
|
@@ -137,7 +137,7 @@ describe("Document Edit", () => {
|
|
|
137
137
|
const pages = $document.selectedDocument.pages;
|
|
138
138
|
const pagesLength = pages.length;
|
|
139
139
|
|
|
140
|
-
if (!$document.selectedDocument.proposed_split) {
|
|
140
|
+
if (!$document.selectedDocument.proposed_split && $document.pages.length > 1) {
|
|
141
141
|
cy.get("#document-edit")
|
|
142
142
|
.find(".pages-section")
|
|
143
143
|
.find(".image-section")
|
|
@@ -154,27 +154,29 @@ describe("Document Edit", () => {
|
|
|
154
154
|
|
|
155
155
|
it("Clicking splitting lines creates new documents", () => {
|
|
156
156
|
cy.getStore("document").then(($document) => {
|
|
157
|
-
if ($document.
|
|
157
|
+
if ($document.pages.length > 1) {
|
|
158
|
+
if ($document.selectedDocument.proposed_split) {
|
|
159
|
+
cy.get("#document-edit")
|
|
160
|
+
.find(".sidebar")
|
|
161
|
+
.find(".smart-split")
|
|
162
|
+
.find(".split-switch")
|
|
163
|
+
.click();
|
|
164
|
+
|
|
165
|
+
cy.wait(1000);
|
|
166
|
+
}
|
|
167
|
+
|
|
158
168
|
cy.get("#document-edit")
|
|
159
|
-
.find(".
|
|
160
|
-
.find(".
|
|
161
|
-
.find(".
|
|
169
|
+
.find(".pages-section")
|
|
170
|
+
.find(".image-section")
|
|
171
|
+
.find(".splitting-lines")
|
|
172
|
+
.find(".lines")
|
|
173
|
+
.first()
|
|
162
174
|
.click();
|
|
163
175
|
|
|
164
|
-
cy.
|
|
176
|
+
cy.getStore("edit").then(($edit) => {
|
|
177
|
+
expect($edit.updatedDocument).to.have.lengthOf(2);
|
|
178
|
+
});
|
|
165
179
|
}
|
|
166
|
-
|
|
167
|
-
cy.get("#document-edit")
|
|
168
|
-
.find(".pages-section")
|
|
169
|
-
.find(".image-section")
|
|
170
|
-
.find(".splitting-lines")
|
|
171
|
-
.find(".lines")
|
|
172
|
-
.first()
|
|
173
|
-
.click();
|
|
174
|
-
|
|
175
|
-
cy.getStore("edit").then(($edit) => {
|
|
176
|
-
expect($edit.updatedDocument).to.have.lengthOf(2);
|
|
177
|
-
});
|
|
178
180
|
});
|
|
179
181
|
});
|
|
180
182
|
|
|
@@ -154,6 +154,7 @@ export default {
|
|
|
154
154
|
|
|
155
155
|
computed: {
|
|
156
156
|
...mapState("display", ["currentPage", "showAnnSetTable"]),
|
|
157
|
+
...mapGetters("document", ["isNegative"]),
|
|
157
158
|
|
|
158
159
|
isBoxSelection() {
|
|
159
160
|
return this.selection && !this.isSelecting && this.isElementSelected;
|
|
@@ -231,7 +232,7 @@ export default {
|
|
|
231
232
|
if (
|
|
232
233
|
annotation.span.find(
|
|
233
234
|
(span) => span.page_index + 1 === this.page.number
|
|
234
|
-
)
|
|
235
|
+
) && !this.isNegative(annotation)
|
|
235
236
|
) {
|
|
236
237
|
annotations.push(annotation);
|
|
237
238
|
}
|
|
@@ -161,6 +161,7 @@ export default {
|
|
|
161
161
|
...mapGetters("document", [
|
|
162
162
|
"numberOfAnnotationSetGroup",
|
|
163
163
|
"labelsFilteredForAnnotationCreation",
|
|
164
|
+
"isNegative",
|
|
164
165
|
]),
|
|
165
166
|
...mapState("selection", ["spanSelection"]),
|
|
166
167
|
top() {
|
|
@@ -247,8 +248,24 @@ export default {
|
|
|
247
248
|
annotationToCreate.label_set = this.selectedSet.label_set.id;
|
|
248
249
|
}
|
|
249
250
|
|
|
251
|
+
// check if the selected label already has a negative annotation
|
|
252
|
+
let negativeAnnotationId;
|
|
253
|
+
|
|
254
|
+
if (this.selectedLabel.annotations.length > 0) {
|
|
255
|
+
const negativeAnnotation = this.selectedLabel.annotations.find(
|
|
256
|
+
(annotation) => this.isNegative(annotation)
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
if (negativeAnnotation) {
|
|
260
|
+
negativeAnnotationId = negativeAnnotation.id;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
250
264
|
this.$store
|
|
251
|
-
.dispatch("document/createAnnotation",
|
|
265
|
+
.dispatch("document/createAnnotation", {
|
|
266
|
+
annotation: annotationToCreate,
|
|
267
|
+
negativeAnnotationId: negativeAnnotationId,
|
|
268
|
+
})
|
|
252
269
|
.catch((error) => {
|
|
253
270
|
this.$store.dispatch("document/createErrorMessage", {
|
|
254
271
|
error,
|
|
@@ -4,16 +4,16 @@ describe("Document Top Bar", () => {
|
|
|
4
4
|
let currentDocument;
|
|
5
5
|
|
|
6
6
|
beforeEach(() => {
|
|
7
|
-
cy.fetchDocument().then(() => {
|
|
7
|
+
cy.fetchDocument().then(() => {
|
|
8
8
|
cy.getStore("document")
|
|
9
9
|
.then($document => {
|
|
10
10
|
currentDocument = $document.selectedDocument;
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
cy.getStore("project")
|
|
14
14
|
.then($project => {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
cy.fetchCategories($project.projectId);
|
|
16
|
+
});
|
|
17
17
|
});
|
|
18
18
|
cy.dispatchAction("document", "setPublicView", false);
|
|
19
19
|
cy.dispatchAction("edit", "disableEditMode");
|
|
@@ -30,7 +30,7 @@ describe("Document Top Bar", () => {
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it("Shows correct file name", () => {
|
|
33
|
-
const fileName = currentDocument.data_file_name
|
|
33
|
+
const fileName = currentDocument.data_file_name;
|
|
34
34
|
|
|
35
35
|
cy.get("#document-top-bar-component")
|
|
36
36
|
.find(".center-bar-components")
|
|
@@ -44,27 +44,27 @@ describe("Document Top Bar", () => {
|
|
|
44
44
|
.contains(fileName);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it("Shows arrows if available documents to navigate to", () => {
|
|
47
|
+
it("Shows arrows if available documents to navigate to", () => {
|
|
48
48
|
cy.fetchDocumentList();
|
|
49
49
|
const assignee = currentDocument.assignee;
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
cy.getStore("project")
|
|
52
|
-
|
|
52
|
+
.then($project => {
|
|
53
53
|
cy.gettersStore().then(($getters) => {
|
|
54
54
|
const filtered = $project.documentsInProject.filter(
|
|
55
55
|
(document) =>
|
|
56
56
|
($getters["document/waitingForSplittingConfirmation"](document) || $getters["document/isDocumentReadyToBeReviewed"](document)
|
|
57
|
-
) && document.assignee === assignee
|
|
57
|
+
) && document.assignee === assignee
|
|
58
58
|
);
|
|
59
59
|
|
|
60
|
-
if(filtered.length > 0) {
|
|
60
|
+
if (filtered.length > 0) {
|
|
61
61
|
cy.get("#document-top-bar-component")
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
.find(".center-bar-components")
|
|
63
|
+
.find(".navigation-arrow")
|
|
64
|
+
.should("be.visible");
|
|
65
65
|
}
|
|
66
|
+
});
|
|
66
67
|
});
|
|
67
|
-
});
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
it("Shows keyboard icon", () => {
|
|
@@ -74,7 +74,7 @@ describe("Document Top Bar", () => {
|
|
|
74
74
|
.should("be.visible");
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
it("Shows disabled finish review button", () => {
|
|
77
|
+
it("Shows disabled finish review button", () => {
|
|
78
78
|
cy.get("#document-top-bar-component")
|
|
79
79
|
.find(".right-bar-components")
|
|
80
80
|
.find(".top-bar-buttons")
|
|
@@ -106,7 +106,7 @@ describe("Document Top Bar", () => {
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it("Edits file name", () => {
|
|
109
|
-
const
|
|
109
|
+
const newName = "test-name";
|
|
110
110
|
|
|
111
111
|
cy.get("#document-top-bar-component")
|
|
112
112
|
.find(".center-bar-components")
|
|
@@ -119,15 +119,15 @@ describe("Document Top Bar", () => {
|
|
|
119
119
|
.find(".document-name-component")
|
|
120
120
|
.find(".document-name")
|
|
121
121
|
.should("have.class", "is-editable");
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
cy.get("#document-top-bar-component")
|
|
124
124
|
.find(".center-bar-components")
|
|
125
125
|
.find(".document-name-component")
|
|
126
126
|
.find(".document-name")
|
|
127
127
|
.type('{selectAll}')
|
|
128
128
|
.type('{backspace}')
|
|
129
|
-
.type(
|
|
130
|
-
|
|
129
|
+
.type(newName);
|
|
130
|
+
|
|
131
131
|
cy.get("#document-top-bar-component")
|
|
132
132
|
.find(".center-bar-components")
|
|
133
133
|
.find(".document-name-component")
|
|
@@ -141,7 +141,7 @@ describe("Document Top Bar", () => {
|
|
|
141
141
|
.click();
|
|
142
142
|
|
|
143
143
|
cy.wait(1000);
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
cy.get("#document-top-bar-component")
|
|
146
146
|
.find(".center-bar-components")
|
|
147
147
|
.find(".document-name-component")
|
|
@@ -153,7 +153,7 @@ describe("Document Top Bar", () => {
|
|
|
153
153
|
cy.get("#document-top-bar-component")
|
|
154
154
|
.find(".center-bar-components")
|
|
155
155
|
.find(".document-name-component")
|
|
156
|
-
.contains(
|
|
156
|
+
.contains(newName);
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
it("Shows tooltip when hovering over keyboard info", () => {
|
|
@@ -167,14 +167,14 @@ describe("Document Top Bar", () => {
|
|
|
167
167
|
.find(".keyboard-actions-info")
|
|
168
168
|
.find(".keyboard-actions-description")
|
|
169
169
|
.should("be.visible");
|
|
170
|
-
|
|
170
|
+
|
|
171
171
|
cy.get("#document-top-bar-component")
|
|
172
172
|
.find(".right-bar-components")
|
|
173
173
|
.find(".keyboard-actions-info")
|
|
174
174
|
.trigger("mouseleave");
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
it("Closes edit mode when clicking 'back to annotaiton view' button", () => {
|
|
177
|
+
it("Closes edit mode when clicking 'back to annotaiton view' button", () => {
|
|
178
178
|
cy.dispatchAction("edit", "enableEditMode");
|
|
179
179
|
|
|
180
180
|
cy.get("#document-top-bar-component")
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
<b-button
|
|
22
22
|
:label="editMode && !renameAndCategorize ? $t('next') : $t('submit')"
|
|
23
23
|
type="is-primary"
|
|
24
|
-
:class="[
|
|
24
|
+
:class="[
|
|
25
|
+
'button-next primary-button edit-mode-btn',
|
|
26
|
+
renameAndCategorize && 'submit-btn',
|
|
27
|
+
]"
|
|
25
28
|
:disabled="renameAndCategorize && !enableSubmit"
|
|
26
29
|
@click="handleButton"
|
|
27
30
|
/>
|
package/src/locales/de.json
CHANGED
|
@@ -140,5 +140,8 @@
|
|
|
140
140
|
"link_to_add_labels": "Sehen Sie <a href='https://help.konfuzio.com/modules/labels/index.html#add-a-label' target='_blank'>hier</a>, wie Sie sie hinzufügen.",
|
|
141
141
|
"no_annotations_in_annotation_set": "Dieser Annotationssatz enthält keine extrahierten Annotationen für die jeweiligen Beschriftungen.",
|
|
142
142
|
"wait_title": "Bitte warten...",
|
|
143
|
-
"redirecting_to_documents_list": "Wir führen Sie zur Dokumentenliste, sodass Sie Ihre Dokumente weiter überprüfen können, während wir die vorgenommenen Änderungen verarbeiten."
|
|
143
|
+
"redirecting_to_documents_list": "Wir führen Sie zur Dokumentenliste, sodass Sie Ihre Dokumente weiter überprüfen können, während wir die vorgenommenen Änderungen verarbeiten.",
|
|
144
|
+
"translated_string_title": "Übersetzter Text",
|
|
145
|
+
"no_translated_string": "Es existiert noch keine Übersetzung.",
|
|
146
|
+
"add_translation": "Eins hinzufügen"
|
|
144
147
|
}
|
package/src/locales/en.json
CHANGED
|
@@ -140,5 +140,8 @@
|
|
|
140
140
|
"link_to_add_labels": "See how to add them <a href='https://help.konfuzio.com/modules/labels/index.html#add-a-label' target='_blank'>here</a>.",
|
|
141
141
|
"no_annotations_in_annotation_set": "This annotation set has no annotations extracted for its respective labels.",
|
|
142
142
|
"wait_title": "Please wait...",
|
|
143
|
-
"redirecting_to_documents_list": "We are taking you to the documents list, so you can continue reviewing your documents while we process the changes made."
|
|
143
|
+
"redirecting_to_documents_list": "We are taking you to the documents list, so you can continue reviewing your documents while we process the changes made.",
|
|
144
|
+
"translated_string_title": "Translated text",
|
|
145
|
+
"no_translated_string": "No translation exists yet.",
|
|
146
|
+
"add_translation": "Add one"
|
|
144
147
|
}
|
package/src/locales/es.json
CHANGED
|
@@ -140,5 +140,8 @@
|
|
|
140
140
|
"link_to_add_labels": "Para ver cómo agregarlas haga clic <a href='https://help.konfuzio.com/modules/labels/index.html#add-a-label' target='_blank'>aquí</a>.",
|
|
141
141
|
"no_annotations_in_annotation_set": "Este grupo de anotaciones no tiene anotaciones encontradas para sus respectivas etiquetas.",
|
|
142
142
|
"wait_title": "Por favor espere...",
|
|
143
|
-
"redirecting_to_documents_list": "Lo estamos redirigiendo a la lista de documentos, para que pueda continuar la revisión de sus documentos mientras procesamos los cambios realizados."
|
|
143
|
+
"redirecting_to_documents_list": "Lo estamos redirigiendo a la lista de documentos, para que pueda continuar la revisión de sus documentos mientras procesamos los cambios realizados.",
|
|
144
|
+
"translated_string_title": "Texto traducido",
|
|
145
|
+
"no_translated_string": "Aún no existe traducción.",
|
|
146
|
+
"add_translation": "Agregar"
|
|
144
147
|
}
|
package/src/store/document.js
CHANGED
|
@@ -117,30 +117,37 @@ const getters = {
|
|
|
117
117
|
/**
|
|
118
118
|
* Gets labels for an annotation creation from a label/annotation set
|
|
119
119
|
*/
|
|
120
|
-
labelsFilteredForAnnotationCreation: (
|
|
121
|
-
let
|
|
120
|
+
labelsFilteredForAnnotationCreation: (_, getters) => (set) => {
|
|
121
|
+
let availableLabels = [];
|
|
122
122
|
if (set.id && set.labels) {
|
|
123
|
-
// if
|
|
124
|
-
|
|
125
|
-
// check if
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
existingLabel.annotations &&
|
|
133
|
-
existingLabel.annotations.length === 0
|
|
134
|
-
);
|
|
123
|
+
// check if label can be multiple, if there's already an annotation created & if it's a negative annotation
|
|
124
|
+
set.labels.map(label => {
|
|
125
|
+
// check if we already added the same label to the array
|
|
126
|
+
const found = availableLabels.find(l => l.id === label.id);
|
|
127
|
+
|
|
128
|
+
if (found) return;
|
|
129
|
+
|
|
130
|
+
if (label.annotations.length === 0) {
|
|
131
|
+
availableLabels.push(label);
|
|
135
132
|
} else {
|
|
136
|
-
|
|
133
|
+
if (label.has_multiple_top_candidates) {
|
|
134
|
+
availableLabels.push(label);
|
|
135
|
+
} else {
|
|
136
|
+
// if the label has negative annotations, we show the label
|
|
137
|
+
label.annotations.map(annotation => {
|
|
138
|
+
if (getters.isNegative(annotation)) {
|
|
139
|
+
availableLabels.push(label);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
137
144
|
}
|
|
138
145
|
});
|
|
139
146
|
} else if (set.labels) {
|
|
140
147
|
// if not existing ann set, then return all labels
|
|
141
|
-
|
|
148
|
+
availableLabels = set.labels;
|
|
142
149
|
}
|
|
143
|
-
return
|
|
150
|
+
return availableLabels;
|
|
144
151
|
},
|
|
145
152
|
|
|
146
153
|
/* Checks if annotation is in deleted state */
|
|
@@ -248,6 +255,7 @@ const getters = {
|
|
|
248
255
|
const labels = [];
|
|
249
256
|
const processedAnnotationSets = annotationSets.map((annotationSet) => {
|
|
250
257
|
const annotationSetLabels = annotationSet.labels.map((label) => {
|
|
258
|
+
|
|
251
259
|
// add annotations to the document array
|
|
252
260
|
annotations.push(...label.annotations);
|
|
253
261
|
labels.push(label);
|
|
@@ -327,7 +335,7 @@ const getters = {
|
|
|
327
335
|
// check which one has more confidence or if it's the same, then check if one is revised or not
|
|
328
336
|
if (
|
|
329
337
|
highestConfidenceAnnotation.confidence <
|
|
330
|
-
|
|
338
|
+
label.annotations[i].confidence ||
|
|
331
339
|
(highestConfidenceAnnotation.confidence ===
|
|
332
340
|
label.annotations[i].confidence &&
|
|
333
341
|
label.annotations[i].revised)
|
|
@@ -352,42 +360,43 @@ const getters = {
|
|
|
352
360
|
*/
|
|
353
361
|
isAnnotationInEditMode:
|
|
354
362
|
(state) =>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
363
|
+
(annotationId, index = null) => {
|
|
364
|
+
if (state.editAnnotation && annotationId) {
|
|
365
|
+
if (index != null) {
|
|
366
|
+
return (
|
|
367
|
+
state.editAnnotation.id === annotationId &&
|
|
368
|
+
state.editAnnotation.index === index
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
return state.editAnnotation.id === annotationId;
|
|
362
372
|
}
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
},
|
|
373
|
+
},
|
|
366
374
|
|
|
367
375
|
/**
|
|
368
376
|
* Get number of empty labels per annotation set
|
|
369
377
|
*/
|
|
370
|
-
|
|
371
|
-
const labels = annotationSet.labels.filter(
|
|
372
|
-
(label) => label.annotations.length === 0
|
|
373
|
-
);
|
|
374
|
-
|
|
378
|
+
emptyLabels: (state, getters) => (annotationSet) => {
|
|
375
379
|
const pendingEmpty = [];
|
|
376
380
|
|
|
377
|
-
labels.map((label) => {
|
|
378
|
-
const
|
|
381
|
+
annotationSet.labels.map((label) => {
|
|
382
|
+
const foundMissing = state.missingAnnotations.find(
|
|
379
383
|
(l) =>
|
|
380
384
|
l.label === label.id &&
|
|
381
385
|
annotationSet.id === l.annotation_set &&
|
|
382
386
|
annotationSet.label_set.id === l.label_set
|
|
383
387
|
);
|
|
384
388
|
|
|
385
|
-
|
|
389
|
+
const foundNegative = label.annotations.find(annotation =>
|
|
390
|
+
getters.isNegative(annotation)
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
if (!foundMissing && (label.annotations.length === 0 || foundNegative)) {
|
|
386
394
|
pendingEmpty.push(label);
|
|
387
395
|
}
|
|
396
|
+
|
|
388
397
|
});
|
|
389
398
|
|
|
390
|
-
return pendingEmpty
|
|
399
|
+
return pendingEmpty;
|
|
391
400
|
},
|
|
392
401
|
|
|
393
402
|
annotationIsNotFound: (state) => (annotationSet, label) => {
|
|
@@ -408,8 +417,8 @@ const getters = {
|
|
|
408
417
|
|
|
409
418
|
// Check if document is ready to be finished
|
|
410
419
|
isDocumentReadyToFinishReview: (state) => {
|
|
411
|
-
// check if all annotations
|
|
412
|
-
let
|
|
420
|
+
// check if all annotations are correct
|
|
421
|
+
let notCorrect;
|
|
413
422
|
|
|
414
423
|
const emptyAnnotations = [];
|
|
415
424
|
|
|
@@ -430,19 +439,23 @@ const getters = {
|
|
|
430
439
|
}
|
|
431
440
|
|
|
432
441
|
if (state.annotations) {
|
|
433
|
-
|
|
442
|
+
notCorrect = state.annotations.filter((a) => !a.is_correct);
|
|
443
|
+
|
|
444
|
+
if (notCorrect) {
|
|
445
|
+
notCorrect.map(annotation => {
|
|
446
|
+
emptyAnnotations.push(annotation);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
434
449
|
}
|
|
435
450
|
|
|
436
|
-
// if all annotations
|
|
451
|
+
// if all annotations are correct
|
|
437
452
|
// and if there are no empty annotations or
|
|
438
|
-
// all empty annotations were marked as missing,
|
|
453
|
+
// all empty annotations or negative annotations were marked as missing,
|
|
439
454
|
// we can finish the review
|
|
440
455
|
if (
|
|
441
456
|
!emptyAnnotations ||
|
|
442
457
|
!state.missingAnnotations ||
|
|
443
|
-
|
|
444
|
-
(notRevised.length === 0 &&
|
|
445
|
-
state.missingAnnotations.length === emptyAnnotations.length)
|
|
458
|
+
state.missingAnnotations.length === emptyAnnotations.length
|
|
446
459
|
) {
|
|
447
460
|
return true;
|
|
448
461
|
}
|
|
@@ -456,7 +469,7 @@ const getters = {
|
|
|
456
469
|
/**
|
|
457
470
|
* Get number of annotations pending review per annotation set
|
|
458
471
|
*/
|
|
459
|
-
|
|
472
|
+
notCorrectAnnotations: () => (annotationSet) => {
|
|
460
473
|
const labels = annotationSet.labels.filter(
|
|
461
474
|
(label) => label.annotations.length > 0
|
|
462
475
|
);
|
|
@@ -465,7 +478,7 @@ const getters = {
|
|
|
465
478
|
|
|
466
479
|
labels.map((label) => {
|
|
467
480
|
const foundPendingAnnotations = label.annotations.filter(
|
|
468
|
-
(ann) => !ann.revised
|
|
481
|
+
(ann) => !ann.is_correct && !ann.revised
|
|
469
482
|
);
|
|
470
483
|
|
|
471
484
|
if (foundPendingAnnotations && foundPendingAnnotations.length > 0) {
|
|
@@ -480,7 +493,7 @@ const getters = {
|
|
|
480
493
|
}
|
|
481
494
|
});
|
|
482
495
|
|
|
483
|
-
return annotationsWithPendingReview
|
|
496
|
+
return annotationsWithPendingReview;
|
|
484
497
|
},
|
|
485
498
|
|
|
486
499
|
/**
|
|
@@ -504,14 +517,14 @@ const getters = {
|
|
|
504
517
|
*/
|
|
505
518
|
documentCannotBeEdited:
|
|
506
519
|
(state) =>
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
520
|
+
(document = state.selectedDocument) => {
|
|
521
|
+
return (
|
|
522
|
+
document.dataset_status === 1 ||
|
|
523
|
+
document.dataset_status === 2 ||
|
|
524
|
+
document.dataset_status === 3 ||
|
|
525
|
+
document.is_reviewed
|
|
526
|
+
);
|
|
527
|
+
},
|
|
515
528
|
|
|
516
529
|
/**
|
|
517
530
|
* If automatic splitting is enabled for the project
|
|
@@ -577,6 +590,13 @@ const getters = {
|
|
|
577
590
|
return null;
|
|
578
591
|
}
|
|
579
592
|
},
|
|
593
|
+
isNegative: () => (annotation) => {
|
|
594
|
+
if (annotation) {
|
|
595
|
+
return !annotation.is_correct && annotation.revised;
|
|
596
|
+
} else {
|
|
597
|
+
return null;
|
|
598
|
+
}
|
|
599
|
+
},
|
|
580
600
|
|
|
581
601
|
/**
|
|
582
602
|
* Check for user who created or revised the annotation
|
|
@@ -722,11 +742,13 @@ const actions = {
|
|
|
722
742
|
commit("SET_LABELS", labels);
|
|
723
743
|
commit("SET_SELECTED_DOCUMENT", response.data);
|
|
724
744
|
|
|
725
|
-
if (
|
|
726
|
-
projectId = rootState.project.projectId;
|
|
727
|
-
} else {
|
|
745
|
+
if (response.data.project) {
|
|
728
746
|
projectId = response.data.project;
|
|
729
|
-
|
|
747
|
+
|
|
748
|
+
dispatch("project/setProjectId", projectId, {
|
|
749
|
+
root: true,
|
|
750
|
+
});
|
|
751
|
+
dispatch("project/fetchProjectDetails", projectId, {
|
|
730
752
|
root: true,
|
|
731
753
|
});
|
|
732
754
|
}
|
|
@@ -829,7 +851,7 @@ const actions = {
|
|
|
829
851
|
commit("SET_DOCUMENT_ANNOTATION_SELECTED", null);
|
|
830
852
|
},
|
|
831
853
|
|
|
832
|
-
createAnnotation: ({ commit, getters, dispatch }, annotation) => {
|
|
854
|
+
createAnnotation: ({ commit, getters, dispatch }, { annotation, negativeAnnotationId }) => {
|
|
833
855
|
return new Promise((resolve, reject) => {
|
|
834
856
|
HTTP.post(`/annotations/`, annotation)
|
|
835
857
|
.then(async (response) => {
|
|
@@ -847,6 +869,9 @@ const actions = {
|
|
|
847
869
|
}
|
|
848
870
|
} else {
|
|
849
871
|
commit("ADD_ANNOTATION", response.data);
|
|
872
|
+
if (negativeAnnotationId) {
|
|
873
|
+
commit("DELETE_ANNOTATION", negativeAnnotationId);
|
|
874
|
+
}
|
|
850
875
|
}
|
|
851
876
|
|
|
852
877
|
resolve(response);
|
|
@@ -1142,6 +1167,7 @@ const mutations = {
|
|
|
1142
1167
|
const exists = label.annotations.find(
|
|
1143
1168
|
(existingAnnotation) => existingAnnotation.id === annotation.id
|
|
1144
1169
|
);
|
|
1170
|
+
|
|
1145
1171
|
if (!exists) {
|
|
1146
1172
|
label.annotations.push(annotation);
|
|
1147
1173
|
return;
|
package/src/store/project.js
CHANGED
|
@@ -2,10 +2,11 @@ import myImports from "../api";
|
|
|
2
2
|
const HTTP = myImports.HTTP;
|
|
3
3
|
|
|
4
4
|
const state = {
|
|
5
|
-
projectId:
|
|
5
|
+
projectId: null,
|
|
6
6
|
currentUser: null,
|
|
7
7
|
documentsListPath: null,
|
|
8
8
|
documentsInProject: null,
|
|
9
|
+
translationsEnabled: false,
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
const getters = {
|
|
@@ -99,6 +100,20 @@ const actions = {
|
|
|
99
100
|
console.log(error, "Could not fetch document list from the backend");
|
|
100
101
|
});
|
|
101
102
|
},
|
|
103
|
+
|
|
104
|
+
fetchProjectDetails: ({commit}, projectId) => {
|
|
105
|
+
return HTTP.get(
|
|
106
|
+
`projects/${projectId}/`
|
|
107
|
+
)
|
|
108
|
+
.then((response) => {
|
|
109
|
+
if (response.data.enable_translated_strings) {
|
|
110
|
+
commit("SET_TRANSLATIONS_ENABLED", true);
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
.catch((error) => {
|
|
114
|
+
console.log(error, "Could not fetch project details from the backend");
|
|
115
|
+
});
|
|
116
|
+
}
|
|
102
117
|
};
|
|
103
118
|
|
|
104
119
|
const mutations = {
|
|
@@ -114,6 +129,9 @@ const mutations = {
|
|
|
114
129
|
SET_DOCUMENTS_IN_PROJECT: (state, documents) => {
|
|
115
130
|
state.documentsInProject = documents;
|
|
116
131
|
},
|
|
132
|
+
SET_TRANSLATIONS_ENABLED: (state, value) => {
|
|
133
|
+
state.translationsEnabled = value;
|
|
134
|
+
}
|
|
117
135
|
};
|
|
118
136
|
|
|
119
137
|
export default {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
3
|
-
<path
|
|
4
|
-
fill="#E1E1E1"
|
|
5
|
-
d="M15.71,12.71a6,6,0,1,0-7.42,0,10,10,0,0,0-6.22,8.18,1,1,0,0,0,2,.22,8,8,0,0,1,15.9,0,1,1,0,0,0,1,.89h.11a1,1,0,0,0,.88-1.1A10,10,0,0,0,15.71,12.71ZM12,12a4,4,0,1,1,4-4A4,4,0,0,1,12,12Z"
|
|
6
|
-
/>
|
|
7
|
-
</svg>
|
|
8
|
-
</template>
|