@konfuzio/document-validation-ui 0.1.5 → 0.1.6-multi-ann-set-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.
Files changed (73) hide show
  1. package/dist/css/app.css +1 -1
  2. package/dist/index.html +1 -1
  3. package/dist/js/app.js +1 -1
  4. package/dist/js/app.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/.DS_Store +0 -0
  7. package/src/assets/images/DraggableIcon.vue +14 -0
  8. package/src/assets/images/GridIcon.vue +16 -0
  9. package/src/assets/images/MagicWandIcon.vue +16 -0
  10. package/src/assets/images/NotFoundIcon.vue +16 -0
  11. package/src/assets/images/SettingsIcon.vue +14 -0
  12. package/src/assets/images/SplitZigZag.vue +47 -14
  13. package/src/assets/images/StarIcon.vue +16 -0
  14. package/src/assets/scss/ann_set_table_options.scss +26 -0
  15. package/src/assets/scss/annotation_details.scss +85 -73
  16. package/src/assets/scss/document_annotations.scss +54 -57
  17. package/src/assets/scss/document_category.scss +0 -1
  18. package/src/assets/scss/document_dashboard.scss +7 -2
  19. package/src/assets/scss/document_edit.scss +90 -46
  20. package/src/assets/scss/main.scss +725 -7
  21. package/src/assets/scss/multi_ann_table_overlay.scss +38 -0
  22. package/src/assets/scss/splitting_confirmation_modal.scss +41 -0
  23. package/src/assets/scss/variables.scss +2 -657
  24. package/src/components/App.vue +9 -3
  25. package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +171 -0
  26. package/src/components/DocumentAnnotations/AnnotationContent.vue +5 -3
  27. package/src/components/DocumentAnnotations/AnnotationDetails.vue +28 -7
  28. package/src/components/DocumentAnnotations/AnnotationRow.vue +133 -41
  29. package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +86 -0
  30. package/src/components/DocumentAnnotations/CategorizeModal.vue +28 -2
  31. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +121 -97
  32. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +21 -5
  33. package/src/components/DocumentAnnotations/ExtractingData.vue +3 -3
  34. package/src/components/DocumentAnnotations/index.js +0 -1
  35. package/src/components/DocumentCategory.vue +13 -5
  36. package/src/components/DocumentDashboard.vue +17 -6
  37. package/src/components/DocumentEdit/DocumentEdit.vue +208 -68
  38. package/src/components/DocumentEdit/EditConfirmationModal.vue +54 -0
  39. package/src/components/DocumentEdit/EditPages.vue +29 -18
  40. package/src/components/DocumentEdit/EditSidebar.vue +92 -45
  41. package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
  42. package/src/components/DocumentEdit/SplitInfoBar.vue +19 -0
  43. package/src/components/DocumentEdit/SplitOverview.vue +4 -5
  44. package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +3 -4
  45. package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
  46. package/src/components/DocumentModals/SplittingSuggestionsModal.vue +120 -0
  47. package/src/components/DocumentPage/ActionBar.vue +3 -3
  48. package/src/components/DocumentPage/AnnSetTableOptions.vue +107 -0
  49. package/src/components/DocumentPage/DocumentPage.vue +39 -10
  50. package/src/components/DocumentPage/DocumentToolbar.vue +6 -2
  51. package/src/components/DocumentPage/MultiAnnSelection.vue +90 -2
  52. package/src/components/DocumentPage/MultiAnnotationTableOverlay.vue +274 -0
  53. package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +19 -46
  54. package/src/components/DocumentPage/NewAnnotation.vue +1 -1
  55. package/src/components/DocumentPage/ScrollingDocument.vue +43 -4
  56. package/src/components/DocumentPage/ScrollingPage.vue +4 -5
  57. package/src/components/DocumentThumbnails/DocumentThumbnails.vue +14 -11
  58. package/src/components/DocumentTopBar/DocumentName.vue +6 -1
  59. package/src/components/DocumentTopBar/DocumentTopBar.vue +9 -9
  60. package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +38 -32
  61. package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +9 -3
  62. package/src/components/DocumentsList/DocumentsList.vue +11 -2
  63. package/src/locales/de.json +23 -6
  64. package/src/locales/en.json +24 -6
  65. package/src/locales/es.json +23 -6
  66. package/src/store/category.js +1 -1
  67. package/src/store/display.js +51 -0
  68. package/src/store/document.js +181 -24
  69. package/src/store/edit.js +71 -48
  70. package/src/store/project.js +14 -14
  71. package/src/utils/utils.js +13 -0
  72. package/src/components/DocumentAnnotations/ActionButtons.vue +0 -257
  73. package/src/components/DocumentAnnotations/RejectedLabels.vue +0 -96
@@ -29,6 +29,8 @@ const state = {
29
29
  interactionBlocked: false,
30
30
  documentActionBar: null, // document action bar properties
31
31
  categorizeModalIsActive: false,
32
+ pageChangedFromThumbnail: false,
33
+ showAnnSetTable: null,
32
34
  };
33
35
 
34
36
  const getters = {
@@ -59,6 +61,31 @@ const getters = {
59
61
  imageScale: (state) => (page) => {
60
62
  return new BigNumber(page.size[0]).div(page.original_size[0]).toNumber();
61
63
  },
64
+ bboxToPoint:
65
+ (state, getters) =>
66
+ (page, point, hasOffset = false) => {
67
+ const imageScale = getters.imageScale(page);
68
+ const { x, y } = point;
69
+ const pageHeight = new BigNumber(page.original_size[1]);
70
+ const newPoint = {
71
+ // left
72
+ x: new BigNumber(x)
73
+ .minus(hasOffset ? 1 : 0)
74
+ .times(state.scale)
75
+ .times(imageScale)
76
+ .div(PIXEL_RATIO)
77
+ .toNumber(),
78
+ // top
79
+ y: pageHeight
80
+ .minus(new BigNumber(y))
81
+ .minus(hasOffset ? 17.1 : 0)
82
+ .times(state.scale)
83
+ .times(imageScale)
84
+ .div(PIXEL_RATIO)
85
+ .toNumber(),
86
+ };
87
+ return newPoint;
88
+ },
62
89
  bboxToRect:
63
90
  (state, getters) =>
64
91
  (page, bbox, hasOffset = false) => {
@@ -206,9 +233,18 @@ const actions = {
206
233
  show ? { icon, text, action, loading } : null
207
234
  );
208
235
  },
236
+ showAnnSetTable({ commit }, tableSet) {
237
+ commit("SET_ANN_SET_TABLE", tableSet);
238
+ },
239
+ toggleAnnSetTable({ commit }, tableSet) {
240
+ commit("TOGGLE_ANN_SET_TABLE", tableSet);
241
+ },
209
242
  setCategorizeModalIsActive: ({ commit }, value) => {
210
243
  commit("SET_CATEGORIZE_MODAL_IS_ACTIVE", value);
211
244
  },
245
+ setPageChangedFromThumbnail: ({ commit }, value) => {
246
+ commit("SET_PAGE_CHANGED_FROM_THUMBNAIL", value);
247
+ },
212
248
  };
213
249
 
214
250
  const mutations = {
@@ -232,9 +268,24 @@ const mutations = {
232
268
  state.documentActionBar = actionBar;
233
269
  },
234
270
 
271
+ SET_ANN_SET_TABLE: (state, tableSet) => {
272
+ state.showAnnSetTable = tableSet;
273
+ },
274
+
275
+ TOGGLE_ANN_SET_TABLE: (state, tableSet) => {
276
+ if (state.showAnnSetTable) {
277
+ state.showAnnSetTable = null;
278
+ } else {
279
+ state.showAnnSetTable = tableSet;
280
+ }
281
+ },
282
+
235
283
  SET_CATEGORIZE_MODAL_IS_ACTIVE: (state, value) => {
236
284
  state.categorizeModalIsActive = value;
237
285
  },
286
+ SET_PAGE_CHANGED_FROM_THUMBNAIL: (state, value) => {
287
+ state.pageChangedFromThumbnail = value;
288
+ },
238
289
  };
239
290
 
240
291
  export default {
@@ -3,6 +3,7 @@ import { sleep } from "../utils/utils";
3
3
 
4
4
  const HTTP = myImports.HTTP;
5
5
  const documentPollDuration = 1000;
6
+ export const table_reference_api = "api.v3.dvui.table";
6
7
 
7
8
  const state = {
8
9
  loading: true,
@@ -21,13 +22,15 @@ const state = {
21
22
  showActionError: false,
22
23
  errorMessage: null,
23
24
  showDocumentError: false,
24
- rejectedMissingAnnotations: null,
25
+ annotationsMarkedAsMissing: null,
25
26
  errorMessageWidth: null,
26
27
  hoveredAnnotationSet: null,
27
28
  finishedReview: false,
28
29
  newAcceptedAnnotations: null,
29
30
  selectedEntities: null,
30
31
  serverError: false,
32
+ splittingSuggestions: null,
33
+ documentIsReviewed: false,
31
34
  };
32
35
 
33
36
  const getters = {
@@ -157,6 +160,78 @@ const getters = {
157
160
  return state.annotationSets.find((annSet) => annSet.id === annotationSetId);
158
161
  },
159
162
 
163
+ /* Get annotation sets created in table */
164
+ annotationSetsInTable: (state) => () => {
165
+ const annotationSetsList = {};
166
+ state.annotationSets.forEach((annotationSet) => {
167
+ let addAnnotationSet = false;
168
+ if (annotationSet.labels) {
169
+ annotationSet.labels.forEach((label) => {
170
+ if (
171
+ label.annotations &&
172
+ label.annotations.find(
173
+ (annotation) =>
174
+ annotation.origin && annotation.origin === table_reference_api
175
+ )
176
+ ) {
177
+ addAnnotationSet = true;
178
+ return;
179
+ }
180
+ });
181
+ }
182
+ if (addAnnotationSet) {
183
+ // group by label set
184
+ if (annotationSetsList[`${annotationSet.label_set.id}`]) {
185
+ annotationSetsList[`${annotationSet.label_set.id}`].push(
186
+ annotationSet
187
+ );
188
+ } else {
189
+ annotationSetsList[`${annotationSet.label_set.id}`] = [annotationSet];
190
+ }
191
+ }
192
+ });
193
+ return annotationSetsList;
194
+ },
195
+
196
+ /* Get annotation sets without tables */
197
+ annotationSetsToShowInList: (state) => () => {
198
+ const annotationSetsList = [];
199
+ state.annotationSets.forEach((annotationSet) => {
200
+ let addAnnotationSet = true;
201
+ if (annotationSet.labels) {
202
+ annotationSet.labels.forEach((label) => {
203
+ if (
204
+ label.annotations &&
205
+ label.annotations.find(
206
+ (annotation) =>
207
+ annotation.origin && annotation.origin === table_reference_api
208
+ )
209
+ ) {
210
+ addAnnotationSet = false;
211
+ return;
212
+ }
213
+ });
214
+ }
215
+ if (addAnnotationSet) {
216
+ annotationSetsList.push(annotationSet);
217
+ }
218
+ });
219
+ return annotationSetsList;
220
+ },
221
+
222
+ /* Get annotations inside a list of annotation sets */
223
+ annotationsInAnnotationsSets: (state) => (annotationsSets) => {
224
+ const annotations = [];
225
+ annotationsSets.forEach((annotationSet) => {
226
+ annotationSet.labels.forEach((label) => {
227
+ label.annotations.forEach((annotation) => {
228
+ annotations.push(annotation);
229
+ });
230
+ });
231
+ });
232
+ return annotations;
233
+ },
234
+
160
235
  /* Process annotations and extract labels and sets */
161
236
  processAnnotationSets: (state, getters) => (annotationSets) => {
162
237
  // group annotations for sidebar
@@ -228,6 +303,7 @@ const getters = {
228
303
  });
229
304
  return found ? `${value + 1}` : "";
230
305
  }
306
+ return "";
231
307
  },
232
308
 
233
309
  /**
@@ -308,6 +384,27 @@ const getters = {
308
384
  return pendingEmpty.length;
309
385
  },
310
386
 
387
+ annotationIsNotFound: (state) => (annotationSet, label) => {
388
+ // Check if the combined label and label set have been marked as missing
389
+ // or if the document is in public mode
390
+ if (state.missingAnnotations.length === 0) {
391
+ return false;
392
+ } else {
393
+ const found = state.missingAnnotations.filter(
394
+ (el) =>
395
+ el.label === label.id &&
396
+ el.annotation_set === annotationSet.id &&
397
+ el.label_set === annotationSet.label_set.id
398
+ );
399
+
400
+ if (found.length !== 0) {
401
+ return true;
402
+ } else {
403
+ return false;
404
+ }
405
+ }
406
+ },
407
+
311
408
  // Check if document is ready to be finished
312
409
  isDocumentReviewFinished: (state) => () => {
313
410
  // check if all annotations have been revised
@@ -335,7 +432,7 @@ const getters = {
335
432
 
336
433
  // if all annotations have been revised
337
434
  // and if there are no empty annotations or
338
- // all empty annotations were rejected,
435
+ // all empty annotations were marked as missing,
339
436
  // we can finish the review
340
437
  if (
341
438
  !emptyAnnotations ||
@@ -419,6 +516,20 @@ const getters = {
419
516
  }
420
517
  },
421
518
 
519
+ /**
520
+ * If automatic splitting is enabled for the project
521
+ */
522
+ waitingForSplittingConfirmation: () => (document) => {
523
+ return document && document.status_data === 41;
524
+ },
525
+
526
+ /**
527
+ * Show the Smart Split switch or not
528
+ */
529
+ documentHasProposedSplit: () => (document) => {
530
+ return document.proposed_split && document.proposed_split.length > 0;
531
+ },
532
+
422
533
  /**
423
534
  * Joins all strings in a multi-entity Annotation array
424
535
  * to look like a single string
@@ -445,7 +556,7 @@ const getters = {
445
556
  /**
446
557
  * Check status of annotation
447
558
  */
448
- notFound: () => (annotation) => {
559
+ notExtracted: () => (annotation) => {
449
560
  if (annotation) {
450
561
  return !annotation.span;
451
562
  } else {
@@ -574,8 +685,8 @@ const actions = {
574
685
  setDocumentError: ({ commit }, value) => {
575
686
  commit("SET_DOCUMENT_ERROR", value);
576
687
  },
577
- setRejectedMissingAnnotations: ({ commit }, annotations) => {
578
- commit("SET_REJECTED_MISSING_ANNOTATIONS", annotations);
688
+ setAnnotationsMarkedAsMissing: ({ commit }, annotations) => {
689
+ commit("SET_ANNOTATIONS_MARKED_AS_MISSING", annotations);
579
690
  },
580
691
  setErrorMessageWidth: ({ commit }, width) => {
581
692
  commit("SET_ERROR_MESSAGE_WIDTH", width);
@@ -589,6 +700,12 @@ const actions = {
589
700
  setSelectedEntities: ({ commit }, entities) => {
590
701
  commit("SET_SELECTED_ENTITIES", entities);
591
702
  },
703
+ setSplittingSuggestions: ({ commit }, value) => {
704
+ commit("SET_SPLITTING_SUGGESTIONS", value);
705
+ },
706
+ setDocumentIsReviewed: ({ commit }, value) => {
707
+ commit("SET_DOCUMENT_IS_REVIEWED", value);
708
+ },
592
709
 
593
710
  /**
594
711
  * Actions that use HTTP requests always return the axios promise,
@@ -619,11 +736,13 @@ const actions = {
619
736
  if (response.data.pages.length > 0) {
620
737
  dispatch("fetchDocumentPage", initialPage);
621
738
  }
739
+
622
740
  // set information on the store
623
741
  commit("SET_ANNOTATION_SETS", annotationSets);
624
742
  commit("SET_ANNOTATIONS", annotations);
625
743
  commit("SET_LABELS", labels);
626
744
  commit("SET_SELECTED_DOCUMENT", response.data);
745
+ commit("SET_DOCUMENT_IS_REVIEWED", response.data.is_reviewed);
627
746
  commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
628
747
 
629
748
  if (rootState.project.projectId) {
@@ -635,6 +754,10 @@ const actions = {
635
754
  });
636
755
  }
637
756
 
757
+ if (getters.documentHasProposedSplit(response.data)) {
758
+ commit("SET_SPLITTING_SUGGESTIONS", response.data.proposed_split);
759
+ }
760
+
638
761
  categoryId = response.data.category;
639
762
  // TODO: add this validation to a method
640
763
  isRecalculatingAnnotations = response.data.labeling_available !== 1;
@@ -698,7 +821,7 @@ const actions = {
698
821
  id: annotation.id,
699
822
  span,
700
823
  page: span.page_index + 1,
701
- labelName: label.name,
824
+ labelName: label ? label.name : "",
702
825
  };
703
826
  commit("SET_DOCUMENT_ANNOTATION_SELECTED", value);
704
827
  },
@@ -716,7 +839,7 @@ const actions = {
716
839
  HTTP.post(`/annotations/`, annotation)
717
840
  .then(async (response) => {
718
841
  if (response.status === 201) {
719
- dispatch("fetchMissingAnnotations");
842
+ await dispatch("fetchMissingAnnotations");
720
843
  commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
721
844
 
722
845
  if (!getters.annotationSetExists(response.data.annotation_set)) {
@@ -827,13 +950,14 @@ const actions = {
827
950
  });
828
951
  },
829
952
 
830
- addMissingAnnotations: ({ commit, dispatch }, missingAnnotations) => {
953
+ addMissingAnnotations: ({ commit, getters }, missingAnnotations) => {
831
954
  return new Promise((resolve, reject) => {
832
- return HTTP.post(`/missing-annotations/`, missingAnnotations)
833
- .then((response) => {
955
+ HTTP.post(`/missing-annotations/`, missingAnnotations)
956
+ .then(async (response) => {
834
957
  if (response.status === 201) {
835
- commit("SET_REJECTED_MISSING_ANNOTATIONS", null);
836
- dispatch("fetchMissingAnnotations");
958
+ commit("SET_ANNOTATIONS_MARKED_AS_MISSING", null);
959
+ commit("ADD_MISSING_ANNOTATIONS", response.data);
960
+ commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
837
961
  }
838
962
 
839
963
  resolve(response);
@@ -845,12 +969,13 @@ const actions = {
845
969
  });
846
970
  },
847
971
 
848
- deleteMissingAnnotation: ({ commit, getters, dispatch }, id) => {
972
+ deleteMissingAnnotation: ({ commit, getters }, id) => {
849
973
  return new Promise((resolve, reject) => {
850
974
  return HTTP.delete(`/missing-annotations/${id}/`)
851
975
  .then((response) => {
852
976
  if (response.status === 204) {
853
- dispatch("fetchMissingAnnotations");
977
+ commit("DELETE_MISSING_ANNOTATION", id);
978
+ commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
854
979
  resolve(true);
855
980
  }
856
981
  })
@@ -891,8 +1016,11 @@ const actions = {
891
1016
  `documents/${state.documentId}/?fields=status_data,labeling_available`
892
1017
  )
893
1018
  .then((response) => {
894
- if (getters.isDocumentReadyToBeReviewed(response.data)) {
895
- // ready
1019
+ if (
1020
+ getters.isDocumentReadyToBeReviewed(response.data) ||
1021
+ getters.waitingForSplittingConfirmation(response.data)
1022
+ ) {
1023
+ // ready or has splitting suggestions
896
1024
  return resolve(true);
897
1025
  } else if (getters.documentHadErrorDuringExtraction(response.data)) {
898
1026
  // error
@@ -1029,11 +1157,21 @@ const mutations = {
1029
1157
  (existingAnnotation) => existingAnnotation.id === annotation.id
1030
1158
  );
1031
1159
  if (indexOfAnnotationAnnotationSets > -1) {
1032
- label.annotations.splice(
1033
- indexOfAnnotationAnnotationSets,
1034
- 1,
1035
- annotation
1036
- );
1160
+ // checks if an annotation label was changed and add it to the new label
1161
+ if (annotation.label && annotation.label.id !== label.id) {
1162
+ label.annotations.splice(indexOfAnnotationAnnotationSets, 1);
1163
+
1164
+ const labelToAdd = annotationSet.labels.find(
1165
+ (labelToAdd) => labelToAdd.id === annotation.label.id
1166
+ );
1167
+ labelToAdd.annotations.push(annotation);
1168
+ } else {
1169
+ label.annotations.splice(
1170
+ indexOfAnnotationAnnotationSets,
1171
+ 1,
1172
+ annotation
1173
+ );
1174
+ }
1037
1175
  updatedAnnotation = true;
1038
1176
  return;
1039
1177
  }
@@ -1110,7 +1248,7 @@ const mutations = {
1110
1248
  },
1111
1249
  SET_SELECTED_DOCUMENT: (state, document) => {
1112
1250
  if (document.is_reviewed === true) {
1113
- state.publicView = true;
1251
+ state.documentIsReviewed = true;
1114
1252
  }
1115
1253
  state.selectedDocument = document;
1116
1254
 
@@ -1123,7 +1261,20 @@ const mutations = {
1123
1261
  SET_MISSING_ANNOTATIONS: (state, missingAnnotations) => {
1124
1262
  state.missingAnnotations = missingAnnotations;
1125
1263
  },
1264
+ ADD_MISSING_ANNOTATIONS: (state, missingAnnotations) => {
1265
+ missingAnnotations.map((annotation) => {
1266
+ state.missingAnnotations.push(annotation);
1267
+ });
1268
+ },
1269
+ DELETE_MISSING_ANNOTATION: (state, id) => {
1270
+ const indexOfAnnotationToDelete = state.missingAnnotations.findIndex(
1271
+ (annotation) => annotation.id === id
1272
+ );
1126
1273
 
1274
+ if (indexOfAnnotationToDelete > -1) {
1275
+ state.missingAnnotations.splice(indexOfAnnotationToDelete, 1);
1276
+ }
1277
+ },
1127
1278
  SET_SHOW_ACTION_ERROR: (state, value) => {
1128
1279
  state.showActionError = value;
1129
1280
  },
@@ -1133,8 +1284,8 @@ const mutations = {
1133
1284
  SET_DOCUMENT_ERROR: (state, value) => {
1134
1285
  state.showDocumentError = value;
1135
1286
  },
1136
- SET_REJECTED_MISSING_ANNOTATIONS: (state, annotations) => {
1137
- state.rejectedMissingAnnotations = annotations;
1287
+ SET_ANNOTATIONS_MARKED_AS_MISSING: (state, annotations) => {
1288
+ state.annotationsMarkedAsMissing = annotations;
1138
1289
  },
1139
1290
  SET_ERROR_MESSAGE_WIDTH: (state, width) => {
1140
1291
  state.errorMessageWidth = width;
@@ -1164,6 +1315,12 @@ const mutations = {
1164
1315
  UPDATE_FILE_NAME: (state, value) => {
1165
1316
  state.selectedDocument.data_file_name = value;
1166
1317
  },
1318
+ SET_SPLITTING_SUGGESTIONS: (state, array) => {
1319
+ state.splittingSuggestions = array;
1320
+ },
1321
+ SET_DOCUMENT_IS_REVIEWED: (state, value) => {
1322
+ state.documentIsReviewed = value;
1323
+ },
1167
1324
  };
1168
1325
 
1169
1326
  export default {
package/src/store/edit.js CHANGED
@@ -1,4 +1,9 @@
1
1
  import myImports from "../api";
2
+ import {
3
+ getURLQueryParam,
4
+ navigateToNewDocumentURL,
5
+ getURLPath,
6
+ } from "../utils/utils";
2
7
 
3
8
  const HTTP = myImports.HTTP;
4
9
 
@@ -6,9 +11,10 @@ const state = {
6
11
  editMode: false,
7
12
  splitOverview: false,
8
13
  isMultipleSelection: false,
9
- documentPagesListForEditMode: [], // TODO: change name
14
+ pagesForPostprocess: [],
10
15
  selectedPages: [],
11
16
  updatedDocument: [],
17
+ showEditConfirmationModal: false,
12
18
  };
13
19
 
14
20
  const actions = {
@@ -25,8 +31,8 @@ const actions = {
25
31
  commit("SET_SPLIT_OVERVIEW", overview);
26
32
  },
27
33
 
28
- setDocumentPagesListForEditMode: ({ commit }, pages) => {
29
- commit("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", pages);
34
+ setPagesForPostprocess: ({ commit }, pages) => {
35
+ commit("SET_PAGES_FOR_POSTPROCESS", pages);
30
36
  },
31
37
 
32
38
  setUpdatedDocument: ({ commit }, updatedDocument) => {
@@ -57,42 +63,41 @@ const actions = {
57
63
  },
58
64
 
59
65
  rotatePage: ({ state, commit }, { page, direction }) => {
60
- if (state.documentPagesListForEditMode.find((p) => p.id === page[0].id)) {
61
- const documentPagesListForEditMode =
62
- state.documentPagesListForEditMode.map((p) => {
63
- let rotatedAngle;
64
- if (direction === "left") {
65
- rotatedAngle = p.angle - 90;
66
- if (p.id === page[0].id) {
67
- if (rotatedAngle === -270) {
68
- rotatedAngle = 90;
69
- }
70
- return {
71
- ...p,
72
- angle: rotatedAngle,
73
- };
66
+ if (state.pagesForPostprocess.find((p) => p.id === page[0].id)) {
67
+ const pagesForPostprocess = state.pagesForPostprocess.map((p) => {
68
+ let rotatedAngle;
69
+ if (direction === "left") {
70
+ rotatedAngle = p.angle - 90;
71
+ if (p.id === page[0].id) {
72
+ if (rotatedAngle === -270) {
73
+ rotatedAngle = 90;
74
74
  }
75
- return p;
75
+ return {
76
+ ...p,
77
+ angle: rotatedAngle,
78
+ };
76
79
  }
77
- if (direction === "right") {
78
- rotatedAngle = p.angle + 90;
79
- if (p.id === page[0].id) {
80
- if (rotatedAngle === 270) {
81
- rotatedAngle = -90;
82
- }
83
- return {
84
- ...p,
85
- angle: rotatedAngle,
86
- };
80
+ return p;
81
+ }
82
+ if (direction === "right") {
83
+ rotatedAngle = p.angle + 90;
84
+ if (p.id === page[0].id) {
85
+ if (rotatedAngle === 270) {
86
+ rotatedAngle = -90;
87
87
  }
88
- return p;
88
+ return {
89
+ ...p,
90
+ angle: rotatedAngle,
91
+ };
89
92
  }
90
- });
93
+ return p;
94
+ }
95
+ });
91
96
 
92
- commit("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", documentPagesListForEditMode);
97
+ commit("SET_PAGES_FOR_POSTPROCESS", pagesForPostprocess);
93
98
  } else {
94
99
  if (direction === "left") {
95
- state.documentPagesListForEditMode.push({
100
+ state.pagesForPostprocess.push({
96
101
  id: page.id,
97
102
  number: page.number,
98
103
  angle: -90,
@@ -102,7 +107,7 @@ const actions = {
102
107
  }
103
108
 
104
109
  if (direction === "right") {
105
- state.documentPagesListForEditMode.push({
110
+ state.pagesForPostprocess.push({
106
111
  id: page.id,
107
112
  number: page.number,
108
113
  angle: 90,
@@ -115,7 +120,7 @@ const actions = {
115
120
 
116
121
  updateRotationToTheLeft: ({ state, commit }) => {
117
122
  // updated the angles that will be sent to the backend
118
- const array = state.documentPagesListForEditMode.map((p) => {
123
+ const array = state.pagesForPostprocess.map((p) => {
119
124
  let rotatedAngle = p.angle - 90;
120
125
  if (rotatedAngle === -270) {
121
126
  rotatedAngle = 90;
@@ -126,12 +131,12 @@ const actions = {
126
131
  };
127
132
  });
128
133
 
129
- commit("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", array);
134
+ commit("SET_PAGES_FOR_POSTPROCESS", array);
130
135
  },
131
136
 
132
137
  updateRotationToTheRight: ({ state, commit }) => {
133
138
  // updated the angles that will be sent to the backend
134
- const array = state.documentPagesListForEditMode.map((p) => {
139
+ const array = state.pagesForPostprocess.map((p) => {
135
140
  let rotatedAngle = p.angle + 90;
136
141
  if (rotatedAngle === 270) {
137
142
  rotatedAngle = -90;
@@ -142,13 +147,16 @@ const actions = {
142
147
  };
143
148
  });
144
149
 
145
- commit("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", array);
150
+ commit("SET_PAGES_FOR_POSTPROCESS", array);
146
151
  },
147
152
 
148
153
  editDocument: ({ rootState, dispatch }, editedDocument) => {
149
154
  dispatch("document/startRecalculatingAnnotations", null, {
150
155
  root: true,
151
156
  });
157
+
158
+ const oldId = rootState.document.documentId;
159
+
152
160
  return new Promise((resolve, reject) => {
153
161
  HTTP.post(
154
162
  `/documents/${rootState.document.documentId}/postprocess/`,
@@ -156,15 +164,23 @@ const actions = {
156
164
  )
157
165
  .then(async (response) => {
158
166
  if (response && response.status === 200) {
159
- const newDocument = response.data[0];
160
- const newId = newDocument.id;
161
-
162
- await dispatch("document/setDocId", newId, {
163
- root: true,
164
- });
165
- dispatch("document/pollDocumentEndpoint", null, {
166
- root: true,
167
- });
167
+ const newId = response.data[0].id;
168
+ dispatch("document/setSplittingSuggestions", null, { root: true });
169
+
170
+ if (newId !== oldId) {
171
+ if (getURLQueryParam("document") || getURLPath("docs")) {
172
+ navigateToNewDocumentURL(oldId, newId);
173
+ } else {
174
+ await dispatch("document/setDocId", newId, {
175
+ root: true,
176
+ });
177
+
178
+ dispatch("document/pollDocumentEndpoint", null, {
179
+ root: true,
180
+ });
181
+ }
182
+ }
183
+
168
184
  resolve(null);
169
185
  } else {
170
186
  resolve(response);
@@ -176,6 +192,10 @@ const actions = {
176
192
  });
177
193
  });
178
194
  },
195
+
196
+ setShowEditConfirmationModal: ({ commit }, value) => {
197
+ commit("SET_SHOW_EDIT_CONFIRMATION_MODAL", value);
198
+ },
179
199
  };
180
200
 
181
201
  const mutations = {
@@ -187,8 +207,8 @@ const mutations = {
187
207
  state.splitOverview = overview;
188
208
  },
189
209
 
190
- SET_DOCUMENT_PAGES_FOR_EDIT_MODE: (state, pages) => {
191
- state.documentPagesListForEditMode = pages;
210
+ SET_PAGES_FOR_POSTPROCESS: (state, pages) => {
211
+ state.pagesForPostprocess = pages;
192
212
  },
193
213
 
194
214
  SET_UPDATED_DOCUMENT: (state, updatedDocument) => {
@@ -200,6 +220,9 @@ const mutations = {
200
220
  ADD_SELECTED_PAGE: (state, selectedPage) => {
201
221
  state.selectedPages.push(selectedPage);
202
222
  },
223
+ SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
224
+ state.showEditConfirmationModal = value;
225
+ },
203
226
  };
204
227
 
205
228
  export default {