@konfuzio/document-validation-ui 0.1.4 → 0.1.5-automatic-document-splitting
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/assets/images/MagicWandIcon.vue +16 -0
- package/src/assets/images/ServerImage.vue +3 -0
- package/src/assets/images/SplitZigZag.vue +47 -14
- package/src/assets/images/StarIcon.vue +16 -0
- package/src/assets/scss/document_category.scss +0 -1
- package/src/assets/scss/document_dashboard.scss +6 -0
- package/src/assets/scss/document_edit.scss +135 -46
- package/src/assets/scss/splitting_confirmation_modal.scss +41 -0
- package/src/assets/scss/variables.scss +63 -1
- package/src/components/App.vue +11 -1
- package/src/components/DocumentAnnotations/ActionButtons.vue +7 -0
- package/src/components/DocumentAnnotations/AnnotationContent.vue +3 -0
- package/src/components/DocumentAnnotations/AnnotationRow.vue +3 -0
- package/src/components/DocumentAnnotations/CategorizeModal.vue +24 -4
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +11 -3
- package/src/components/DocumentAnnotations/DocumentLabel.vue +2 -0
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +6 -1
- package/src/components/DocumentCategory.vue +39 -33
- package/src/components/DocumentDashboard.vue +39 -49
- package/src/components/DocumentEdit/DocumentEdit.vue +207 -69
- package/src/components/DocumentEdit/EditConfirmationModal.vue +54 -0
- package/src/components/DocumentEdit/EditPages.vue +30 -18
- package/src/components/DocumentEdit/EditSidebar.vue +95 -45
- package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
- package/src/components/DocumentEdit/SplitInfoBar.vue +19 -0
- package/src/components/DocumentEdit/SplitOverview.vue +6 -5
- package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +3 -4
- package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
- package/src/components/DocumentModals/SplittingSuggestionsModal.vue +121 -0
- package/src/components/DocumentPage/DocumentPage.vue +9 -3
- package/src/components/DocumentPage/DummyPage.vue +9 -7
- package/src/components/DocumentPage/ScrollingDocument.vue +8 -3
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +45 -8
- package/src/components/DocumentTopBar/DocumentName.vue +1 -0
- package/src/components/DocumentTopBar/DocumentTopBar.vue +2 -6
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +6 -20
- package/src/components/index.js +1 -0
- package/src/locales/de.json +15 -2
- package/src/locales/en.json +15 -1
- package/src/locales/es.json +14 -1
- package/src/store/display.js +8 -0
- package/src/store/document.js +83 -37
- package/src/store/edit.js +66 -48
- package/src/store/project.js +14 -14
|
@@ -4,12 +4,8 @@
|
|
|
4
4
|
v-if="selectedDocument && selectedDocument.pages.length > 0 && !loading"
|
|
5
5
|
class="document-top-bar"
|
|
6
6
|
>
|
|
7
|
-
<div class="left-bar-components">
|
|
8
|
-
<DocumentCategory
|
|
9
|
-
v-if="
|
|
10
|
-
categories && !editMode && !recalculatingAnnotations && !publicView
|
|
11
|
-
"
|
|
12
|
-
/>
|
|
7
|
+
<div v-if="!recalculatingAnnotations" class="left-bar-components">
|
|
8
|
+
<DocumentCategory v-if="categories && !editMode && !publicView" />
|
|
13
9
|
</div>
|
|
14
10
|
|
|
15
11
|
<DocumentName :data-file-name="selectedDocument.data_file_name" />
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
</template>
|
|
39
39
|
|
|
40
40
|
<script>
|
|
41
|
-
import { mapState } from "vuex";
|
|
41
|
+
import { mapState, mapGetters } from "vuex";
|
|
42
42
|
import ActionButtons from "../DocumentAnnotations/ActionButtons";
|
|
43
43
|
|
|
44
44
|
export default {
|
|
@@ -83,7 +83,6 @@ export default {
|
|
|
83
83
|
this.finishDisabled = !this.finishedReview;
|
|
84
84
|
},
|
|
85
85
|
methods: {
|
|
86
|
-
/** EDIT MODE */
|
|
87
86
|
closeEditMode() {
|
|
88
87
|
this.$store.dispatch("edit/disableEditMode");
|
|
89
88
|
this.$store.dispatch("edit/setSplitOverview", false);
|
|
@@ -105,24 +104,11 @@ export default {
|
|
|
105
104
|
// Enable the "next" button to go to the overview
|
|
106
105
|
this.$store.dispatch("edit/setSplitOverview", true);
|
|
107
106
|
this.$store.dispatch("edit/setSelectedPages", null);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// Send update request to the backend
|
|
114
|
-
this.$store
|
|
115
|
-
.dispatch("edit/editDocument", this.updatedDocument)
|
|
116
|
-
.catch((error) => {
|
|
117
|
-
this.$store.dispatch("document/createErrorMessage", {
|
|
118
|
-
error,
|
|
119
|
-
serverErrorMessage: this.$t("server_error"),
|
|
120
|
-
defaultErrorMessage: this.$t("edit_error"),
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// Close edit mode
|
|
125
|
-
this.closeEditMode();
|
|
107
|
+
} else {
|
|
108
|
+
// If we are in the overview (so more than 1 doc)
|
|
109
|
+
// or in the edit mode (only 1 doc)
|
|
110
|
+
// Show confirmation modal to user
|
|
111
|
+
this.$store.dispatch("edit/setShowEditConfirmationModal", true);
|
|
126
112
|
}
|
|
127
113
|
},
|
|
128
114
|
handleFinishReview() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DocumentCategory } from "./DocumentCategory";
|
package/src/locales/de.json
CHANGED
|
@@ -110,8 +110,21 @@
|
|
|
110
110
|
"new_multi_ann_description": "Wählen Sie ein Datenmodell aus den vorhandenen aus und deaktivieren Sie dann die Labels, die in diesem Dokument nicht vorhanden sind.",
|
|
111
111
|
"drag_drop_columns_multi_ann": "Drag and Drop, um die Reihenfolge der Labels zu ändern",
|
|
112
112
|
"error_creating_multi_ann": "Nicht alle Annotationen wurden erfolgreich erstellt.",
|
|
113
|
-
"disabled_finish_review": "Der Abschluss der Dokumentenprüfung ist erst möglich, nachdem alle Annotationen überarbeitet wurden, unabhängig davon, ob sie akzeptiert oder abgelehnt wurden.",
|
|
114
113
|
"no_multi_ann_labelset_model": "Es gibt keine verfügbaren Label Sets, die mehrfach in diesem Dokument zu finden sind. Weitere Informationen finden Sie unter <a href='https://help.konfuzio.com/tutorials/advanced-document-extraction/index.html#multiple-annotation-sets' target='_blank'>diesem Link</a>.",
|
|
115
114
|
"single_category_in_project": "Das aktuelle Projekt hat nur eine Kategorie. Um sie ändern zu können, sollte die neue zuerst dem Projekt hinzugefügt werden. Einzelheiten dazu finden Sie unter <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>diesem Link</a>.",
|
|
116
|
-
"approved_annotations": "Die Kategorie kann nicht geändert werden, da bereits akzeptierte Annotationen oder manuell erstellte Annotationen zu diesem Dokument vorhanden sind."
|
|
115
|
+
"approved_annotations": "Die Kategorie kann nicht geändert werden, da bereits akzeptierte Annotationen oder manuell erstellte Annotationen zu diesem Dokument vorhanden sind.",
|
|
116
|
+
"disabled_finish_review": "Der Abschluss der Dokumentenprüfung ist erst möglich, nachdem alle Annotationen überarbeitet wurden, unabhängig davon, ob sie akzeptiert oder abgelehnt wurden.",
|
|
117
|
+
"split_modal_title": "Dokument aufteilen",
|
|
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.",
|
|
119
|
+
"do_it_later": "Ich werde es später machen",
|
|
120
|
+
"review_now": "Jetzt reviewen",
|
|
121
|
+
"recommended": "Empfohlen",
|
|
122
|
+
"smart_split": "Smart Split",
|
|
123
|
+
"smart_split_suggestions": "Unsere Smart Split-Vorschläge sind grün hervorgehoben",
|
|
124
|
+
"no_splitting_suggestions": "Dieses Dokument enthält keine Split-Vorschläge",
|
|
125
|
+
"confirm_splitting": "Sind Sie sicher, dass Sie die Änderungen bestätigen möchten?",
|
|
126
|
+
"splitting_warning": "Beachten Sie bitte, dass alle Annotationen, die Sie in diesem Dokument gemacht haben, nicht gespeichert werden, wenn Sie fortfahren.",
|
|
127
|
+
"no": "Nein",
|
|
128
|
+
"yes": "Ja",
|
|
129
|
+
"split_modal_no_suggestions": "Do you need to split the document? <strong>We strongly recommend</strong> splitting it at this stage, otherwise all the progress you’ve made will be lost in the future."
|
|
117
130
|
}
|
package/src/locales/en.json
CHANGED
|
@@ -114,5 +114,19 @@
|
|
|
114
114
|
"disabled_finish_review": "Finishing the document review is only possible after all annotations have been revised, whether they are accepted or rejected.",
|
|
115
115
|
"no_multi_ann_labelset_model": "There are no available label sets that can be found multiple times in this document. For more details, you can visit <a href='https://help.konfuzio.com/tutorials/advanced-document-extraction/index.html#multiple-annotation-sets' target='_blank'>this link</a>.",
|
|
116
116
|
"single_category_in_project": "The current project has only one category. To be able to change it, the new one should be first added to the project. For details on how to do this, visit <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>this link</a>.",
|
|
117
|
-
"approved_annotations": "It is not possible to change the current category since the document has approved or manually created annotations."
|
|
117
|
+
"approved_annotations": "It is not possible to change the current category since the document has approved or manually created annotations.",
|
|
118
|
+
"split_modal_title": "Split the document",
|
|
119
|
+
"split_modal_body": "We've scanned your file and found <strong>{number_of_split_documents}</strong> different documents. <strong>We strongly recommend</strong> splitting it at this stage, otherwise all the progress you’ve made will be lost due to document data re-extraction.",
|
|
120
|
+
"do_it_later": "I'll do it later",
|
|
121
|
+
"review_now": "Review now",
|
|
122
|
+
"recommended": "Recommended",
|
|
123
|
+
"smart_split": "Smart Split",
|
|
124
|
+
"smart_split_suggestions": "Our Smart Split suggestions are highlighted in green",
|
|
125
|
+
"no_splitting_suggestions": "This document does not have splitting suggestions",
|
|
126
|
+
"confirm_splitting": "Are you sure you want to confirm the changes?",
|
|
127
|
+
"splitting_warning": "Be aware that any annotations you have made in this document will not be saved if you proceed.",
|
|
128
|
+
"no": "No",
|
|
129
|
+
"yes": "Yes",
|
|
130
|
+
"prepare_document": "Prepare the document",
|
|
131
|
+
"split_modal_no_suggestions": "Do you need to split the document? <strong>We strongly recommend</strong> splitting it at this stage, otherwise all the progress you’ve made will be lost in the future."
|
|
118
132
|
}
|
package/src/locales/es.json
CHANGED
|
@@ -112,5 +112,18 @@
|
|
|
112
112
|
"disabled_finish_review": "Solo es posible finalizar la revisión del documento si todas las anotaciones han sido revisadas, ya sea aceptadas o rechazadas.",
|
|
113
113
|
"no_multi_ann_labelset_model": "En este documento no hay grupos de etiquetas múltiples disponibles. Para más información, haz clic en <a href='https://help.konfuzio.com/tutorials/advanced-document-extraction/index.html#multiple-annotation-sets' target='_blank'>este enlace</a>.",
|
|
114
114
|
"single_category_in_project": "Este proyecto solo tiene una categoría. Para poder modificarla, es necesario agregar esta nueva categoría al proyecto. Para más información, visita <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>este enlace</a>.",
|
|
115
|
-
"approved_annotations": "No es posible cambiar la categoría, ya que existen anotaciones aceptadas o creadas manualmente en este documento."
|
|
115
|
+
"approved_annotations": "No es posible cambiar la categoría, ya que existen anotaciones aceptadas o creadas manualmente en este documento.",
|
|
116
|
+
"split_modal_title": "Dividir el documento",
|
|
117
|
+
"split_modal_body": "Hemos escaneado tu documento y hemos encontrado <strong>{number_of_split_documents}</strong> documentos diferentes. <strong>Te recomendamos</strong> dividir el documento en esta etapa, ya que de lo contrario se perderá el progreso logrado debido a una nueva extracción de los datos del documento.",
|
|
118
|
+
"do_it_later": "Lo haré luego",
|
|
119
|
+
"review_now": "Revisar ahora",
|
|
120
|
+
"recommended": "Recomendado",
|
|
121
|
+
"smart_split": "División Inteligente",
|
|
122
|
+
"smart_split_suggestions": "Nuestras sugerencias de División Inteligente están marcadas en color verde",
|
|
123
|
+
"no_splitting_suggestions": "Este documento no tiene sugerencias de división",
|
|
124
|
+
"confirm_splitting": "¿Seguro que quieres confirmar los cambios?",
|
|
125
|
+
"splitting_warning": "Ten en cuenta que se perderán las anotaciones que hayas confirmado en el documento.",
|
|
126
|
+
"no": "No",
|
|
127
|
+
"yes": "Sí",
|
|
128
|
+
"split_modal_no_suggestions": "Do you need to split the document? <strong>We strongly recommend</strong> splitting it at this stage, otherwise all the progress you’ve made will be lost in the future."
|
|
116
129
|
}
|
package/src/store/display.js
CHANGED
|
@@ -28,6 +28,7 @@ const state = {
|
|
|
28
28
|
optimalResolution: true,
|
|
29
29
|
interactionBlocked: false,
|
|
30
30
|
documentActionBar: null, // document action bar properties
|
|
31
|
+
categorizeModalIsActive: false,
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
const getters = {
|
|
@@ -205,6 +206,9 @@ const actions = {
|
|
|
205
206
|
show ? { icon, text, action, loading } : null
|
|
206
207
|
);
|
|
207
208
|
},
|
|
209
|
+
setCategorizeModalIsActive: ({ commit }, value) => {
|
|
210
|
+
commit("SET_CATEGORIZE_MODAL_IS_ACTIVE", value);
|
|
211
|
+
},
|
|
208
212
|
};
|
|
209
213
|
|
|
210
214
|
const mutations = {
|
|
@@ -227,6 +231,10 @@ const mutations = {
|
|
|
227
231
|
SET_DOCUMENT_ACTION_BAR: (state, actionBar) => {
|
|
228
232
|
state.documentActionBar = actionBar;
|
|
229
233
|
},
|
|
234
|
+
|
|
235
|
+
SET_CATEGORIZE_MODAL_IS_ACTIVE: (state, value) => {
|
|
236
|
+
state.categorizeModalIsActive = value;
|
|
237
|
+
},
|
|
230
238
|
};
|
|
231
239
|
|
|
232
240
|
export default {
|
package/src/store/document.js
CHANGED
|
@@ -28,7 +28,7 @@ const state = {
|
|
|
28
28
|
newAcceptedAnnotations: null,
|
|
29
29
|
selectedEntities: null,
|
|
30
30
|
serverError: false,
|
|
31
|
-
|
|
31
|
+
splittingSuggestions: false,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
const getters = {
|
|
@@ -185,6 +185,18 @@ const getters = {
|
|
|
185
185
|
};
|
|
186
186
|
},
|
|
187
187
|
|
|
188
|
+
/* Checks if there are annotations correct in the document */
|
|
189
|
+
documentHasCorrectAnnotations: (state) => () => {
|
|
190
|
+
if (
|
|
191
|
+
!state.annotations ||
|
|
192
|
+
(state.annotations &&
|
|
193
|
+
state.annotations.filter((ann) => ann.is_correct).length > 0)
|
|
194
|
+
) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
},
|
|
199
|
+
|
|
188
200
|
/* Returns the number of accepted annotations in a label */
|
|
189
201
|
numberOfAcceptedAnnotationsInLabel: (_) => (label) => {
|
|
190
202
|
const annotations = label.annotations.filter((annotation) => {
|
|
@@ -397,11 +409,29 @@ const getters = {
|
|
|
397
409
|
);
|
|
398
410
|
},
|
|
399
411
|
|
|
400
|
-
|
|
401
|
-
|
|
412
|
+
documentHasNoCorrectAnnotations: (state) => () => {
|
|
413
|
+
if (
|
|
402
414
|
state.annotations &&
|
|
403
415
|
state.annotations.filter((ann) => ann.is_correct).length > 0
|
|
404
|
-
)
|
|
416
|
+
) {
|
|
417
|
+
return false;
|
|
418
|
+
} else {
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* If automatic splitting is enabled for the project
|
|
425
|
+
*/
|
|
426
|
+
waitingForSplittingConfirmation: () => (document) => {
|
|
427
|
+
return document && document.status_data === 41;
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Show the Smart Split switch or not
|
|
432
|
+
*/
|
|
433
|
+
documentHasProposedSplit: () => (document) => {
|
|
434
|
+
return document.proposed_split && document.proposed_split.length > 0;
|
|
405
435
|
},
|
|
406
436
|
|
|
407
437
|
/**
|
|
@@ -574,8 +604,8 @@ const actions = {
|
|
|
574
604
|
setSelectedEntities: ({ commit }, entities) => {
|
|
575
605
|
commit("SET_SELECTED_ENTITIES", entities);
|
|
576
606
|
},
|
|
577
|
-
|
|
578
|
-
commit("
|
|
607
|
+
setSplittingSuggestions: ({ commit }, value) => {
|
|
608
|
+
commit("SET_SPLITTING_SUGGESTIONS", value);
|
|
579
609
|
},
|
|
580
610
|
|
|
581
611
|
/**
|
|
@@ -605,7 +635,7 @@ const actions = {
|
|
|
605
635
|
|
|
606
636
|
// load first page
|
|
607
637
|
if (response.data.pages.length > 0) {
|
|
608
|
-
|
|
638
|
+
dispatch("fetchDocumentPage", initialPage);
|
|
609
639
|
}
|
|
610
640
|
// set information on the store
|
|
611
641
|
commit("SET_ANNOTATION_SETS", annotationSets);
|
|
@@ -623,6 +653,10 @@ const actions = {
|
|
|
623
653
|
});
|
|
624
654
|
}
|
|
625
655
|
|
|
656
|
+
if (getters.documentHasProposedSplit(response.data)) {
|
|
657
|
+
commit("SET_SPLITTING_SUGGESTIONS", response.data.proposed_split);
|
|
658
|
+
}
|
|
659
|
+
|
|
626
660
|
categoryId = response.data.category;
|
|
627
661
|
// TODO: add this validation to a method
|
|
628
662
|
isRecalculatingAnnotations = response.data.labeling_available !== 1;
|
|
@@ -634,12 +668,12 @@ const actions = {
|
|
|
634
668
|
});
|
|
635
669
|
|
|
636
670
|
if (!state.publicView) {
|
|
671
|
+
dispatch("fetchMissingAnnotations");
|
|
672
|
+
|
|
637
673
|
await dispatch("project/fetchCurrentUser", null, {
|
|
638
674
|
root: true,
|
|
639
675
|
});
|
|
640
676
|
|
|
641
|
-
await dispatch("fetchMissingAnnotations");
|
|
642
|
-
|
|
643
677
|
if (projectId) {
|
|
644
678
|
await dispatch("category/fetchCategories", projectId, {
|
|
645
679
|
root: true,
|
|
@@ -704,7 +738,7 @@ const actions = {
|
|
|
704
738
|
HTTP.post(`/annotations/`, annotation)
|
|
705
739
|
.then(async (response) => {
|
|
706
740
|
if (response.status === 201) {
|
|
707
|
-
dispatch("fetchMissingAnnotations");
|
|
741
|
+
await dispatch("fetchMissingAnnotations");
|
|
708
742
|
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
709
743
|
|
|
710
744
|
if (!getters.annotationSetExists(response.data.annotation_set)) {
|
|
@@ -719,6 +753,7 @@ const actions = {
|
|
|
719
753
|
} else {
|
|
720
754
|
commit("ADD_ANNOTATION", response.data);
|
|
721
755
|
}
|
|
756
|
+
|
|
722
757
|
resolve(response);
|
|
723
758
|
}
|
|
724
759
|
})
|
|
@@ -729,16 +764,20 @@ const actions = {
|
|
|
729
764
|
});
|
|
730
765
|
},
|
|
731
766
|
|
|
732
|
-
updateAnnotation: (
|
|
767
|
+
updateAnnotation: (
|
|
768
|
+
{ commit, getters, dispatch },
|
|
769
|
+
{ updatedValues, annotationId }
|
|
770
|
+
) => {
|
|
733
771
|
commit("SET_NEW_ACCEPTED_ANNOTATIONS", [annotationId]);
|
|
734
772
|
|
|
735
773
|
return new Promise((resolve, reject) => {
|
|
736
774
|
HTTP.patch(`/annotations/${annotationId}/`, updatedValues)
|
|
737
|
-
.then((response) => {
|
|
775
|
+
.then(async (response) => {
|
|
738
776
|
if (response.status === 200) {
|
|
739
777
|
commit("UPDATE_ANNOTATION", response.data);
|
|
740
778
|
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
741
779
|
commit("SET_NEW_ACCEPTED_ANNOTATIONS", null);
|
|
780
|
+
|
|
742
781
|
resolve(true);
|
|
743
782
|
}
|
|
744
783
|
})
|
|
@@ -749,13 +788,14 @@ const actions = {
|
|
|
749
788
|
});
|
|
750
789
|
},
|
|
751
790
|
|
|
752
|
-
deleteAnnotation: ({ commit, getters }, { annotationId }) => {
|
|
791
|
+
deleteAnnotation: ({ commit, getters, dispatch }, { annotationId }) => {
|
|
753
792
|
return new Promise((resolve, reject) => {
|
|
754
793
|
HTTP.delete(`/annotations/${annotationId}/`)
|
|
755
|
-
.then((response) => {
|
|
794
|
+
.then(async (response) => {
|
|
756
795
|
if (response.status === 204) {
|
|
757
796
|
commit("DELETE_ANNOTATION", annotationId);
|
|
758
797
|
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
798
|
+
|
|
759
799
|
resolve(true);
|
|
760
800
|
}
|
|
761
801
|
})
|
|
@@ -793,25 +833,27 @@ const actions = {
|
|
|
793
833
|
},
|
|
794
834
|
|
|
795
835
|
fetchMissingAnnotations: ({ commit, state, getters }) => {
|
|
796
|
-
return
|
|
797
|
-
`/missing-annotations/?document=${state.documentId}&limit=100`
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
836
|
+
return new Promise((resolve, reject) => {
|
|
837
|
+
HTTP.get(`/missing-annotations/?document=${state.documentId}&limit=100`)
|
|
838
|
+
.then((response) => {
|
|
839
|
+
commit("SET_MISSING_ANNOTATIONS", response.data.results);
|
|
840
|
+
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
841
|
+
resolve(response);
|
|
842
|
+
})
|
|
843
|
+
.catch((error) => {
|
|
844
|
+
reject(error.response);
|
|
845
|
+
console.log(error);
|
|
846
|
+
});
|
|
847
|
+
});
|
|
806
848
|
},
|
|
807
849
|
|
|
808
850
|
addMissingAnnotations: ({ commit, dispatch }, missingAnnotations) => {
|
|
809
851
|
return new Promise((resolve, reject) => {
|
|
810
|
-
|
|
811
|
-
.then((response) => {
|
|
852
|
+
HTTP.post(`/missing-annotations/`, missingAnnotations)
|
|
853
|
+
.then(async (response) => {
|
|
812
854
|
if (response.status === 201) {
|
|
813
855
|
commit("SET_REJECTED_MISSING_ANNOTATIONS", null);
|
|
814
|
-
dispatch("fetchMissingAnnotations");
|
|
856
|
+
await dispatch("fetchMissingAnnotations");
|
|
815
857
|
}
|
|
816
858
|
|
|
817
859
|
resolve(response);
|
|
@@ -825,10 +867,10 @@ const actions = {
|
|
|
825
867
|
|
|
826
868
|
deleteMissingAnnotation: ({ commit, getters, dispatch }, id) => {
|
|
827
869
|
return new Promise((resolve) => {
|
|
828
|
-
|
|
829
|
-
.then((response) => {
|
|
870
|
+
HTTP.delete(`/missing-annotations/${id}/`)
|
|
871
|
+
.then(async (response) => {
|
|
830
872
|
if (response.status === 204) {
|
|
831
|
-
dispatch("fetchMissingAnnotations");
|
|
873
|
+
await dispatch("fetchMissingAnnotations");
|
|
832
874
|
resolve(true);
|
|
833
875
|
}
|
|
834
876
|
})
|
|
@@ -869,8 +911,11 @@ const actions = {
|
|
|
869
911
|
`documents/${state.documentId}/?fields=status_data,labeling_available`
|
|
870
912
|
)
|
|
871
913
|
.then((response) => {
|
|
872
|
-
if (
|
|
873
|
-
|
|
914
|
+
if (
|
|
915
|
+
getters.isDocumentReadyToBeReviewed(response.data) ||
|
|
916
|
+
getters.waitingForSplittingConfirmation(response.data)
|
|
917
|
+
) {
|
|
918
|
+
// ready or has splitting suggestions
|
|
874
919
|
return resolve(true);
|
|
875
920
|
} else if (getters.documentHadErrorDuringExtraction(response.data)) {
|
|
876
921
|
// error
|
|
@@ -950,7 +995,7 @@ const actions = {
|
|
|
950
995
|
},
|
|
951
996
|
|
|
952
997
|
contactSupport: ({ rootState }, error) => {
|
|
953
|
-
const url = "https://konfuzio.com/
|
|
998
|
+
const url = "https://konfuzio.com/support/";
|
|
954
999
|
const params = `project=${rootState.project.projectId}&email=${rootState.project.currentUser}&issue=${error}`;
|
|
955
1000
|
const fullUrl = `${url}?${params}`;
|
|
956
1001
|
|
|
@@ -994,7 +1039,7 @@ const mutations = {
|
|
|
994
1039
|
(existingAnnotation) => existingAnnotation.id === annotation.id
|
|
995
1040
|
);
|
|
996
1041
|
if (indexOfAnnotationInAnnotations > -1) {
|
|
997
|
-
state.annotations
|
|
1042
|
+
state.annotations.splice(indexOfAnnotationInAnnotations, 1, annotation);
|
|
998
1043
|
}
|
|
999
1044
|
let updatedAnnotation = false;
|
|
1000
1045
|
state.annotationSets.forEach((annotationSet) => {
|
|
@@ -1137,12 +1182,13 @@ const mutations = {
|
|
|
1137
1182
|
SET_SERVER_ERROR: (state, value) => {
|
|
1138
1183
|
state.serverError = value;
|
|
1139
1184
|
},
|
|
1140
|
-
|
|
1141
|
-
state.categorizeModalIsActive = value;
|
|
1142
|
-
},
|
|
1185
|
+
|
|
1143
1186
|
UPDATE_FILE_NAME: (state, value) => {
|
|
1144
1187
|
state.selectedDocument.data_file_name = value;
|
|
1145
1188
|
},
|
|
1189
|
+
SET_SPLITTING_SUGGESTIONS: (state, array) => {
|
|
1190
|
+
state.splittingSuggestions = array;
|
|
1191
|
+
},
|
|
1146
1192
|
};
|
|
1147
1193
|
|
|
1148
1194
|
export default {
|
package/src/store/edit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import myImports from "../api";
|
|
2
|
+
import { getURLQueryParam, navigateToNewDocumentURL } from "../utils/utils";
|
|
2
3
|
|
|
3
4
|
const HTTP = myImports.HTTP;
|
|
4
5
|
|
|
@@ -6,9 +7,10 @@ const state = {
|
|
|
6
7
|
editMode: false,
|
|
7
8
|
splitOverview: false,
|
|
8
9
|
isMultipleSelection: false,
|
|
9
|
-
|
|
10
|
+
pagesForPostprocess: [],
|
|
10
11
|
selectedPages: [],
|
|
11
12
|
updatedDocument: [],
|
|
13
|
+
showEditConfirmationModal: false,
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
const actions = {
|
|
@@ -25,8 +27,8 @@ const actions = {
|
|
|
25
27
|
commit("SET_SPLIT_OVERVIEW", overview);
|
|
26
28
|
},
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
commit("
|
|
30
|
+
setPagesForPostprocess: ({ commit }, pages) => {
|
|
31
|
+
commit("SET_PAGES_FOR_POSTPROCESS", pages);
|
|
30
32
|
},
|
|
31
33
|
|
|
32
34
|
setUpdatedDocument: ({ commit }, updatedDocument) => {
|
|
@@ -57,42 +59,41 @@ const actions = {
|
|
|
57
59
|
},
|
|
58
60
|
|
|
59
61
|
rotatePage: ({ state, commit }, { page, direction }) => {
|
|
60
|
-
if (state.
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
rotatedAngle = 90;
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
...p,
|
|
72
|
-
angle: rotatedAngle,
|
|
73
|
-
};
|
|
62
|
+
if (state.pagesForPostprocess.find((p) => p.id === page[0].id)) {
|
|
63
|
+
const pagesForPostprocess = state.pagesForPostprocess.map((p) => {
|
|
64
|
+
let rotatedAngle;
|
|
65
|
+
if (direction === "left") {
|
|
66
|
+
rotatedAngle = p.angle - 90;
|
|
67
|
+
if (p.id === page[0].id) {
|
|
68
|
+
if (rotatedAngle === -270) {
|
|
69
|
+
rotatedAngle = 90;
|
|
74
70
|
}
|
|
75
|
-
return
|
|
71
|
+
return {
|
|
72
|
+
...p,
|
|
73
|
+
angle: rotatedAngle,
|
|
74
|
+
};
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
...p,
|
|
85
|
-
angle: rotatedAngle,
|
|
86
|
-
};
|
|
76
|
+
return p;
|
|
77
|
+
}
|
|
78
|
+
if (direction === "right") {
|
|
79
|
+
rotatedAngle = p.angle + 90;
|
|
80
|
+
if (p.id === page[0].id) {
|
|
81
|
+
if (rotatedAngle === 270) {
|
|
82
|
+
rotatedAngle = -90;
|
|
87
83
|
}
|
|
88
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
...p,
|
|
86
|
+
angle: rotatedAngle,
|
|
87
|
+
};
|
|
89
88
|
}
|
|
90
|
-
|
|
89
|
+
return p;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
91
92
|
|
|
92
|
-
commit("
|
|
93
|
+
commit("SET_PAGES_FOR_POSTPROCESS", pagesForPostprocess);
|
|
93
94
|
} else {
|
|
94
95
|
if (direction === "left") {
|
|
95
|
-
state.
|
|
96
|
+
state.pagesForPostprocess.push({
|
|
96
97
|
id: page.id,
|
|
97
98
|
number: page.number,
|
|
98
99
|
angle: -90,
|
|
@@ -102,7 +103,7 @@ const actions = {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
if (direction === "right") {
|
|
105
|
-
state.
|
|
106
|
+
state.pagesForPostprocess.push({
|
|
106
107
|
id: page.id,
|
|
107
108
|
number: page.number,
|
|
108
109
|
angle: 90,
|
|
@@ -115,7 +116,7 @@ const actions = {
|
|
|
115
116
|
|
|
116
117
|
updateRotationToTheLeft: ({ state, commit }) => {
|
|
117
118
|
// updated the angles that will be sent to the backend
|
|
118
|
-
const array = state.
|
|
119
|
+
const array = state.pagesForPostprocess.map((p) => {
|
|
119
120
|
let rotatedAngle = p.angle - 90;
|
|
120
121
|
if (rotatedAngle === -270) {
|
|
121
122
|
rotatedAngle = 90;
|
|
@@ -126,12 +127,12 @@ const actions = {
|
|
|
126
127
|
};
|
|
127
128
|
});
|
|
128
129
|
|
|
129
|
-
commit("
|
|
130
|
+
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
130
131
|
},
|
|
131
132
|
|
|
132
133
|
updateRotationToTheRight: ({ state, commit }) => {
|
|
133
134
|
// updated the angles that will be sent to the backend
|
|
134
|
-
const array = state.
|
|
135
|
+
const array = state.pagesForPostprocess.map((p) => {
|
|
135
136
|
let rotatedAngle = p.angle + 90;
|
|
136
137
|
if (rotatedAngle === 270) {
|
|
137
138
|
rotatedAngle = -90;
|
|
@@ -142,13 +143,16 @@ const actions = {
|
|
|
142
143
|
};
|
|
143
144
|
});
|
|
144
145
|
|
|
145
|
-
commit("
|
|
146
|
+
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
146
147
|
},
|
|
147
148
|
|
|
148
149
|
editDocument: ({ rootState, dispatch }, editedDocument) => {
|
|
149
150
|
dispatch("document/startRecalculatingAnnotations", null, {
|
|
150
151
|
root: true,
|
|
151
152
|
});
|
|
153
|
+
|
|
154
|
+
const oldId = rootState.document.documentId;
|
|
155
|
+
|
|
152
156
|
return new Promise((resolve) => {
|
|
153
157
|
HTTP.post(
|
|
154
158
|
`/documents/${rootState.document.documentId}/postprocess/`,
|
|
@@ -156,15 +160,22 @@ const actions = {
|
|
|
156
160
|
)
|
|
157
161
|
.then(async (response) => {
|
|
158
162
|
if (response && response.status === 200) {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
const newId = response.data[0].id;
|
|
164
|
+
|
|
165
|
+
if (newId !== oldId) {
|
|
166
|
+
if (getURLQueryParam("document")) {
|
|
167
|
+
navigateToNewDocumentURL(oldId, newId);
|
|
168
|
+
} else {
|
|
169
|
+
await dispatch("document/setDocId", newId, {
|
|
170
|
+
root: true,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
dispatch("document/pollDocumentEndpoint", null, {
|
|
174
|
+
root: true,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
168
179
|
resolve(null);
|
|
169
180
|
} else {
|
|
170
181
|
resolve(response);
|
|
@@ -176,6 +187,10 @@ const actions = {
|
|
|
176
187
|
});
|
|
177
188
|
});
|
|
178
189
|
},
|
|
190
|
+
|
|
191
|
+
setShowEditConfirmationModal: ({ commit }, value) => {
|
|
192
|
+
commit("SET_SHOW_EDIT_CONFIRMATION_MODAL", value);
|
|
193
|
+
},
|
|
179
194
|
};
|
|
180
195
|
|
|
181
196
|
const mutations = {
|
|
@@ -187,8 +202,8 @@ const mutations = {
|
|
|
187
202
|
state.splitOverview = overview;
|
|
188
203
|
},
|
|
189
204
|
|
|
190
|
-
|
|
191
|
-
state.
|
|
205
|
+
SET_PAGES_FOR_POSTPROCESS: (state, pages) => {
|
|
206
|
+
state.pagesForPostprocess = pages;
|
|
192
207
|
},
|
|
193
208
|
|
|
194
209
|
SET_UPDATED_DOCUMENT: (state, updatedDocument) => {
|
|
@@ -200,6 +215,9 @@ const mutations = {
|
|
|
200
215
|
ADD_SELECTED_PAGE: (state, selectedPage) => {
|
|
201
216
|
state.selectedPages.push(selectedPage);
|
|
202
217
|
},
|
|
218
|
+
SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
|
|
219
|
+
state.showEditConfirmationModal = value;
|
|
220
|
+
},
|
|
203
221
|
};
|
|
204
222
|
|
|
205
223
|
export default {
|