@konfuzio/document-validation-ui 0.1.4-pre-release-1 → 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.
Files changed (52) hide show
  1. package/README.md +3 -3
  2. package/dist/css/app.css +1 -1
  3. package/dist/index.html +1 -1
  4. package/dist/js/app.js +1 -1
  5. package/dist/js/app.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/assets/images/MagicWandIcon.vue +16 -0
  8. package/src/assets/images/ServerImage.vue +3 -0
  9. package/src/assets/images/SplitZigZag.vue +47 -14
  10. package/src/assets/images/StarIcon.vue +16 -0
  11. package/src/assets/scss/document_category.scss +0 -1
  12. package/src/assets/scss/document_dashboard.scss +6 -0
  13. package/src/assets/scss/document_edit.scss +135 -46
  14. package/src/assets/scss/document_page.scss +1 -1
  15. package/src/assets/scss/splitting_confirmation_modal.scss +41 -0
  16. package/src/assets/scss/variables.scss +63 -1
  17. package/src/components/App.vue +11 -1
  18. package/src/components/DocumentAnnotations/ActionButtons.vue +7 -0
  19. package/src/components/DocumentAnnotations/AnnotationContent.vue +3 -0
  20. package/src/components/DocumentAnnotations/AnnotationRow.vue +3 -0
  21. package/src/components/DocumentAnnotations/CategorizeModal.vue +24 -4
  22. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +11 -3
  23. package/src/components/DocumentAnnotations/DocumentLabel.vue +2 -0
  24. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +6 -1
  25. package/src/components/DocumentCategory.vue +54 -13
  26. package/src/components/DocumentDashboard.vue +39 -49
  27. package/src/components/DocumentEdit/DocumentEdit.vue +207 -69
  28. package/src/components/DocumentEdit/EditConfirmationModal.vue +54 -0
  29. package/src/components/DocumentEdit/EditPages.vue +30 -18
  30. package/src/components/DocumentEdit/EditSidebar.vue +95 -45
  31. package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
  32. package/src/components/DocumentEdit/SplitInfoBar.vue +19 -0
  33. package/src/components/DocumentEdit/SplitOverview.vue +6 -5
  34. package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +3 -4
  35. package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
  36. package/src/components/DocumentModals/SplittingSuggestionsModal.vue +121 -0
  37. package/src/components/DocumentPage/DocumentPage.vue +10 -4
  38. package/src/components/DocumentPage/DocumentToolbar.vue +7 -3
  39. package/src/components/DocumentPage/DummyPage.vue +9 -7
  40. package/src/components/DocumentPage/ScrollingDocument.vue +8 -3
  41. package/src/components/DocumentThumbnails/DocumentThumbnails.vue +45 -8
  42. package/src/components/DocumentTopBar/DocumentName.vue +1 -0
  43. package/src/components/DocumentTopBar/DocumentTopBar.vue +2 -4
  44. package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +6 -20
  45. package/src/components/index.js +1 -0
  46. package/src/locales/de.json +17 -4
  47. package/src/locales/en.json +17 -2
  48. package/src/locales/es.json +16 -3
  49. package/src/store/display.js +8 -0
  50. package/src/store/document.js +93 -41
  51. package/src/store/edit.js +66 -48
  52. package/src/store/project.js +14 -14
@@ -1,12 +1,13 @@
1
1
  <template>
2
- <div class="document-pages">
2
+ <div ref="documentThumbnails" class="document-pages">
3
3
  <div v-if="selectedDocument">
4
4
  <div
5
5
  v-for="page in selectedDocument.pages"
6
+ ref="docPage"
6
7
  :key="page.id"
7
8
  :class="[
8
9
  'document-thumbnail',
9
- currentPage == page.number && 'selected'
10
+ currentPage == page.number && 'selected',
10
11
  ]"
11
12
  @click="changePage(page.number)"
12
13
  >
@@ -16,7 +17,7 @@
16
17
  v-if="!loading && !recalculatingAnnotations"
17
18
  :class="[
18
19
  'img-thumbnail',
19
- currentPage == page.number && 'selected'
20
+ currentPage == page.number && 'selected',
20
21
  ]"
21
22
  :width="'40px'"
22
23
  :image-url="`${page.thumbnail_url}?${selectedDocument.downloaded_at}`"
@@ -57,19 +58,44 @@ export default {
57
58
  name: "DocumentThumbnails",
58
59
  components: {
59
60
  ServerImage,
60
- LoadingThumbnail
61
+ LoadingThumbnail,
62
+ },
63
+ data() {
64
+ return {
65
+ thumbnailClicked: false,
66
+ previousScrollPosition: 0,
67
+ };
61
68
  },
62
69
  computed: {
63
70
  ...mapState("document", [
64
71
  "selectedDocument",
65
72
  "recalculatingAnnotations",
66
- "loading"
73
+ "loading",
67
74
  ]),
68
- ...mapState("display", ["currentPage"])
75
+ ...mapState("display", ["currentPage"]),
76
+ },
77
+ watch: {
78
+ currentPage(newPage) {
79
+ if (newPage && !this.thumbnailClicked) {
80
+ this.scrollToThumbnail();
81
+ }
82
+ },
69
83
  },
84
+ mounted() {
85
+ const scrollingPage = document.querySelector(".scrolling-document");
86
+
87
+ if (scrollingPage) {
88
+ scrollingPage.addEventListener("scroll", () => {
89
+ this.scrollToThumbnail();
90
+ });
91
+ }
92
+ },
93
+
70
94
  methods: {
71
95
  /* Change page if not the currently open and not in modal */
72
96
  changePage(pageNumber) {
97
+ this.thumbnailClicked = true;
98
+
73
99
  if (
74
100
  !this.loading &&
75
101
  !this.recalculatingAnnotations &&
@@ -80,8 +106,19 @@ export default {
80
106
  parseInt(pageNumber, 10)
81
107
  );
82
108
  }
83
- }
84
- }
109
+ },
110
+
111
+ scrollToThumbnail() {
112
+ // select only the active thumbnail
113
+ const selectedPage = this.$refs.docPage.filter((image) =>
114
+ image.className.includes("selected")
115
+ );
116
+
117
+ if (selectedPage && selectedPage[0]) {
118
+ selectedPage[0].scrollIntoView();
119
+ }
120
+ },
121
+ },
85
122
  };
86
123
  </script>
87
124
 
@@ -69,6 +69,7 @@ export default {
69
69
  props: {
70
70
  dataFileName: {
71
71
  type: String,
72
+ default: "",
72
73
  },
73
74
  },
74
75
  data() {
@@ -4,10 +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="categories && !editMode && !recalculatingAnnotations"
10
- />
7
+ <div v-if="!recalculatingAnnotations" class="left-bar-components">
8
+ <DocumentCategory v-if="categories && !editMode && !publicView" />
11
9
  </div>
12
10
 
13
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
- // If we are in the overview (so more than 1 doc)
111
- // or in the edit mode (only 1 doc)
112
- else if (this.updatedDocument) {
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";
@@ -14,7 +14,6 @@
14
14
  "test": "Test",
15
15
  "excluded": "Ausgenommen",
16
16
  "set_status": "Setzen Sie bitte einen Status",
17
- "category_error": "Die Kategorie kann nicht geändert werden, da bereits akzeptierte Annotationen oder manuell erstellte Annotationen zu diesem Dokument vorhanden sind.",
18
17
  "status_error": "Wir konnten den Status nicht ändern. Bitte versuchen Sie es später erneut.",
19
18
  "edit": "Bearbeiten",
20
19
  "save": "Speichern",
@@ -64,7 +63,7 @@
64
63
  "edit_early_access": "Sie sind einer der Nutzer, die Zugang zu diesen Funktionalitäten vor dem offiziellen Erscheinungstermin erhalten.",
65
64
  "selected": "ausgewählt",
66
65
  "rotate_selected": "Ausgewählte Seite drehen",
67
- "edit_not_available": "Dokumente mit dem Status 'Vorbereitung', 'Training' oder 'Test' sowie Dokumente mit dem Status 'Schreibgeschützt' oder 'Geprüft' können nicht bearbeitet werden.",
66
+ "edit_not_available": "Dokumente mit dem Status 'Vorbereitung', 'Training' oder 'Test' sowie Dokumente mit dem Status 'Geprüft' können nicht bearbeitet werden.",
68
67
  "back_to_edit": "Zurück zum Bearbeiten Modus",
69
68
  "split_document": "Dokument aufteilen",
70
69
  "submit": "Senden",
@@ -111,7 +110,21 @@
111
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.",
112
111
  "drag_drop_columns_multi_ann": "Drag and Drop, um die Reihenfolge der Labels zu ändern",
113
112
  "error_creating_multi_ann": "Nicht alle Annotationen wurden erfolgreich erstellt.",
114
- "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.",
115
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>.",
116
- "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>."
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>.",
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
  }
@@ -67,7 +67,7 @@
67
67
  "edit_early_access": "You are one of the users who have access to these functionalities before the release date.",
68
68
  "selected": "selected",
69
69
  "rotate_selected": "Rotate selected",
70
- "edit_not_available": "Editing is not possible for documents with a status of 'Preparation', 'Training' or 'Test', or documents that are 'Read Only' or 'Reviewed'",
70
+ "edit_not_available": "Editing is not possible for documents with a status of 'Preparation', 'Training' or 'Test', or documents that are 'Reviewed'",
71
71
  "back_to_edit": "Back to edit",
72
72
  "split_document": "Split document",
73
73
  "select_label": "Select Label",
@@ -113,5 +113,20 @@
113
113
  "error_creating_multi_ann": "Not all annotation sets were created successfully.",
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
- "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>."
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.",
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."
117
132
  }
@@ -14,7 +14,6 @@
14
14
  "test": "Prueba",
15
15
  "excluded": "Excluído",
16
16
  "set_status": "Establecer estado",
17
- "category_error": "La categoría no se puede cambiar porque hay anotaciones que ya han sido aceptadas o creadas manualmente en este documento.",
18
17
  "status_error": "No ha sido posible cambiar el estado del documento. Por favor, inténtelo de nuevo más tarde.",
19
18
  "edit": "Editar",
20
19
  "save": "Guardar",
@@ -68,7 +67,7 @@
68
67
  "edit_early_access": "Eres uno de los usuarios que tiene acceso a estas funcionalidades antes de la fecha de lanzamiento.",
69
68
  "selected": "seleccionadas",
70
69
  "rotate_selected": "Rotar seleccionadas",
71
- "edit_not_available": "No es posible editar documentos con estado en 'Preparación', 'Entrenamiento' o 'Pruebas', así como documentos que son de 'Sólo Lectura' o 'Revisados'",
70
+ "edit_not_available": "No es posible editar documentos con estado en 'Preparación', 'Entrenamiento' o 'Pruebas', así como documentos que han sido 'Revisados'",
72
71
  "back_to_edit": "Volver a editar",
73
72
  "split_document": "Dividir documento",
74
73
  "select_label": "Seleccionar etiqueta",
@@ -112,5 +111,19 @@
112
111
  "error_creating_multi_ann": "No todos los grupos de anotaciones fueron creados de manera exitosa.",
113
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.",
114
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>.",
115
- "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>."
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.",
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
  }
@@ -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 {
@@ -28,7 +28,7 @@ const state = {
28
28
  newAcceptedAnnotations: null,
29
29
  selectedEntities: null,
30
30
  serverError: false,
31
- categorizeModalIsActive: false,
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) => {
@@ -350,12 +362,14 @@ const getters = {
350
362
  const annotationsWithPendingReview = [];
351
363
 
352
364
  labels.map((label) => {
353
- const foundPendingAnnotation = label.annotations.find(
365
+ const foundPendingAnnotations = label.annotations.filter(
354
366
  (ann) => !ann.revised
355
367
  );
356
368
 
357
- if (foundPendingAnnotation) {
358
- annotationsWithPendingReview.push(foundPendingAnnotation);
369
+ if (foundPendingAnnotations && foundPendingAnnotations.length > 0) {
370
+ foundPendingAnnotations.map((annotation) => {
371
+ annotationsWithPendingReview.push(annotation);
372
+ });
359
373
  }
360
374
  });
361
375
 
@@ -391,11 +405,35 @@ const getters = {
391
405
  document.dataset_status === 1 ||
392
406
  document.dataset_status === 2 ||
393
407
  document.dataset_status === 3 ||
394
- document.is_reviewed ||
395
- state.publicView
408
+ document.is_reviewed
396
409
  );
397
410
  },
398
411
 
412
+ documentHasNoCorrectAnnotations: (state) => () => {
413
+ if (
414
+ state.annotations &&
415
+ state.annotations.filter((ann) => ann.is_correct).length > 0
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;
435
+ },
436
+
399
437
  /**
400
438
  * Joins all strings in a multi-entity Annotation array
401
439
  * to look like a single string
@@ -566,8 +604,8 @@ const actions = {
566
604
  setSelectedEntities: ({ commit }, entities) => {
567
605
  commit("SET_SELECTED_ENTITIES", entities);
568
606
  },
569
- setCategorizeModalIsActive: ({ commit }, value) => {
570
- commit("SET_CATEGORIZE_MODAL_IS_ACTIVE", value);
607
+ setSplittingSuggestions: ({ commit }, value) => {
608
+ commit("SET_SPLITTING_SUGGESTIONS", value);
571
609
  },
572
610
 
573
611
  /**
@@ -597,7 +635,7 @@ const actions = {
597
635
 
598
636
  // load first page
599
637
  if (response.data.pages.length > 0) {
600
- await dispatch("fetchDocumentPage", initialPage);
638
+ dispatch("fetchDocumentPage", initialPage);
601
639
  }
602
640
  // set information on the store
603
641
  commit("SET_ANNOTATION_SETS", annotationSets);
@@ -615,6 +653,10 @@ const actions = {
615
653
  });
616
654
  }
617
655
 
656
+ if (getters.documentHasProposedSplit(response.data)) {
657
+ commit("SET_SPLITTING_SUGGESTIONS", response.data.proposed_split);
658
+ }
659
+
618
660
  categoryId = response.data.category;
619
661
  // TODO: add this validation to a method
620
662
  isRecalculatingAnnotations = response.data.labeling_available !== 1;
@@ -626,12 +668,12 @@ const actions = {
626
668
  });
627
669
 
628
670
  if (!state.publicView) {
671
+ dispatch("fetchMissingAnnotations");
672
+
629
673
  await dispatch("project/fetchCurrentUser", null, {
630
674
  root: true,
631
675
  });
632
676
 
633
- await dispatch("fetchMissingAnnotations");
634
-
635
677
  if (projectId) {
636
678
  await dispatch("category/fetchCategories", projectId, {
637
679
  root: true,
@@ -696,7 +738,7 @@ const actions = {
696
738
  HTTP.post(`/annotations/`, annotation)
697
739
  .then(async (response) => {
698
740
  if (response.status === 201) {
699
- dispatch("fetchMissingAnnotations");
741
+ await dispatch("fetchMissingAnnotations");
700
742
  commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
701
743
 
702
744
  if (!getters.annotationSetExists(response.data.annotation_set)) {
@@ -711,6 +753,7 @@ const actions = {
711
753
  } else {
712
754
  commit("ADD_ANNOTATION", response.data);
713
755
  }
756
+
714
757
  resolve(response);
715
758
  }
716
759
  })
@@ -721,16 +764,20 @@ const actions = {
721
764
  });
722
765
  },
723
766
 
724
- updateAnnotation: ({ commit, getters }, { updatedValues, annotationId }) => {
767
+ updateAnnotation: (
768
+ { commit, getters, dispatch },
769
+ { updatedValues, annotationId }
770
+ ) => {
725
771
  commit("SET_NEW_ACCEPTED_ANNOTATIONS", [annotationId]);
726
772
 
727
773
  return new Promise((resolve, reject) => {
728
774
  HTTP.patch(`/annotations/${annotationId}/`, updatedValues)
729
- .then((response) => {
775
+ .then(async (response) => {
730
776
  if (response.status === 200) {
731
777
  commit("UPDATE_ANNOTATION", response.data);
732
778
  commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
733
779
  commit("SET_NEW_ACCEPTED_ANNOTATIONS", null);
780
+
734
781
  resolve(true);
735
782
  }
736
783
  })
@@ -741,13 +788,14 @@ const actions = {
741
788
  });
742
789
  },
743
790
 
744
- deleteAnnotation: ({ commit, getters }, { annotationId }) => {
791
+ deleteAnnotation: ({ commit, getters, dispatch }, { annotationId }) => {
745
792
  return new Promise((resolve, reject) => {
746
793
  HTTP.delete(`/annotations/${annotationId}/`)
747
- .then((response) => {
794
+ .then(async (response) => {
748
795
  if (response.status === 204) {
749
796
  commit("DELETE_ANNOTATION", annotationId);
750
797
  commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
798
+
751
799
  resolve(true);
752
800
  }
753
801
  })
@@ -785,25 +833,27 @@ const actions = {
785
833
  },
786
834
 
787
835
  fetchMissingAnnotations: ({ commit, state, getters }) => {
788
- return HTTP.get(
789
- `/missing-annotations/?document=${state.documentId}&limit=100`
790
- )
791
- .then((response) => {
792
- commit("SET_MISSING_ANNOTATIONS", response.data.results);
793
- commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
794
- })
795
- .catch((error) => {
796
- console.log(error);
797
- });
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
+ });
798
848
  },
799
849
 
800
850
  addMissingAnnotations: ({ commit, dispatch }, missingAnnotations) => {
801
851
  return new Promise((resolve, reject) => {
802
- return HTTP.post(`/missing-annotations/`, missingAnnotations)
803
- .then((response) => {
852
+ HTTP.post(`/missing-annotations/`, missingAnnotations)
853
+ .then(async (response) => {
804
854
  if (response.status === 201) {
805
855
  commit("SET_REJECTED_MISSING_ANNOTATIONS", null);
806
- dispatch("fetchMissingAnnotations");
856
+ await dispatch("fetchMissingAnnotations");
807
857
  }
808
858
 
809
859
  resolve(response);
@@ -817,10 +867,10 @@ const actions = {
817
867
 
818
868
  deleteMissingAnnotation: ({ commit, getters, dispatch }, id) => {
819
869
  return new Promise((resolve) => {
820
- return HTTP.delete(`/missing-annotations/${id}/`)
821
- .then((response) => {
870
+ HTTP.delete(`/missing-annotations/${id}/`)
871
+ .then(async (response) => {
822
872
  if (response.status === 204) {
823
- dispatch("fetchMissingAnnotations");
873
+ await dispatch("fetchMissingAnnotations");
824
874
  resolve(true);
825
875
  }
826
876
  })
@@ -861,8 +911,11 @@ const actions = {
861
911
  `documents/${state.documentId}/?fields=status_data,labeling_available`
862
912
  )
863
913
  .then((response) => {
864
- if (getters.isDocumentReadyToBeReviewed(response.data)) {
865
- // ready
914
+ if (
915
+ getters.isDocumentReadyToBeReviewed(response.data) ||
916
+ getters.waitingForSplittingConfirmation(response.data)
917
+ ) {
918
+ // ready or has splitting suggestions
866
919
  return resolve(true);
867
920
  } else if (getters.documentHadErrorDuringExtraction(response.data)) {
868
921
  // error
@@ -942,10 +995,8 @@ const actions = {
942
995
  },
943
996
 
944
997
  contactSupport: ({ rootState }, error) => {
945
- const url =
946
- "https://konfuzio.atlassian.net/servicedesk/customer/portal/1/group/1/create/1";
998
+ const url = "https://konfuzio.com/support/";
947
999
  const params = `project=${rootState.project.projectId}&email=${rootState.project.currentUser}&issue=${error}`;
948
-
949
1000
  const fullUrl = `${url}?${params}`;
950
1001
 
951
1002
  window.open(fullUrl, "_blank");
@@ -988,7 +1039,7 @@ const mutations = {
988
1039
  (existingAnnotation) => existingAnnotation.id === annotation.id
989
1040
  );
990
1041
  if (indexOfAnnotationInAnnotations > -1) {
991
- state.annotations[indexOfAnnotationInAnnotations] = annotation;
1042
+ state.annotations.splice(indexOfAnnotationInAnnotations, 1, annotation);
992
1043
  }
993
1044
  let updatedAnnotation = false;
994
1045
  state.annotationSets.forEach((annotationSet) => {
@@ -1131,12 +1182,13 @@ const mutations = {
1131
1182
  SET_SERVER_ERROR: (state, value) => {
1132
1183
  state.serverError = value;
1133
1184
  },
1134
- SET_CATEGORIZE_MODAL_IS_ACTIVE: (state, value) => {
1135
- state.categorizeModalIsActive = value;
1136
- },
1185
+
1137
1186
  UPDATE_FILE_NAME: (state, value) => {
1138
1187
  state.selectedDocument.data_file_name = value;
1139
1188
  },
1189
+ SET_SPLITTING_SUGGESTIONS: (state, array) => {
1190
+ state.splittingSuggestions = array;
1191
+ },
1140
1192
  };
1141
1193
 
1142
1194
  export default {