@konfuzio/document-validation-ui 0.1.14 → 0.1.16-dev.0

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 (102) hide show
  1. package/README.md +12 -0
  2. package/cypress.config.js +13 -0
  3. package/dist/css/app.css +1 -1
  4. package/dist/index.html +1 -1
  5. package/dist/js/app.js +1 -1
  6. package/dist/js/app.js.map +1 -1
  7. package/dist/js/chunk-vendors.js +3 -3
  8. package/dist/js/chunk-vendors.js.map +1 -1
  9. package/package.json +5 -1
  10. package/src/api.js +53 -23
  11. package/src/assets/images/DraggableIcon.vue +14 -0
  12. package/src/assets/images/GridIcon.vue +16 -0
  13. package/src/assets/images/MagicWandIcon.vue +16 -0
  14. package/src/assets/images/NotFoundIcon.vue +16 -0
  15. package/src/assets/images/ServerImage.vue +19 -9
  16. package/src/assets/images/SettingsIcon.vue +14 -0
  17. package/src/assets/images/SplitZigZag.vue +47 -14
  18. package/src/assets/images/StarIcon.vue +16 -0
  19. package/src/assets/scss/ann_set_table_options.scss +26 -0
  20. package/src/assets/scss/annotation_details.scss +86 -71
  21. package/src/assets/scss/choose_label_set_modal.scss +1 -1
  22. package/src/assets/scss/document_annotations.scss +242 -229
  23. package/src/assets/scss/document_category.scss +12 -7
  24. package/src/assets/scss/document_dashboard.scss +7 -2
  25. package/src/assets/scss/document_edit.scss +151 -173
  26. package/src/assets/scss/document_name.scss +0 -2
  27. package/src/assets/scss/document_thumbnails.scss +1 -1
  28. package/src/assets/scss/document_toolbar.scss +23 -1
  29. package/src/assets/scss/document_top_bar.scss +40 -1
  30. package/src/assets/scss/edit_page_thumbnail.scss +53 -0
  31. package/src/assets/scss/multi_ann_table_overlay.scss +38 -0
  32. package/src/assets/scss/new_annotation.scss +17 -3
  33. package/src/assets/scss/scrolling_document.scss +1 -1
  34. package/src/assets/scss/theme.scss +801 -0
  35. package/src/assets/scss/variables.scss +5 -663
  36. package/src/components/App.cy.js +7 -0
  37. package/src/components/App.vue +98 -11
  38. package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +168 -0
  39. package/src/components/DocumentAnnotations/AnnotationContent.vue +50 -84
  40. package/src/components/DocumentAnnotations/AnnotationDetails.vue +37 -12
  41. package/src/components/DocumentAnnotations/AnnotationRow.vue +244 -199
  42. package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -0
  43. package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +4 -2
  44. package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +295 -0
  45. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +195 -146
  46. package/src/components/DocumentAnnotations/DocumentLabel.vue +46 -9
  47. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +59 -88
  48. package/src/components/DocumentAnnotations/ExtractingData.vue +18 -6
  49. package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +337 -0
  50. package/src/components/DocumentAnnotations/index.js +1 -1
  51. package/src/components/DocumentCategory.vue +89 -65
  52. package/src/components/DocumentDashboard.vue +59 -48
  53. package/src/components/DocumentEdit/DocumentEdit.vue +302 -105
  54. package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -0
  55. package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -0
  56. package/src/components/DocumentEdit/EditPages.vue +60 -103
  57. package/src/components/DocumentEdit/EditSidebar.vue +101 -48
  58. package/src/components/DocumentEdit/{SplitOverview.vue → RenameAndCategorize.vue} +15 -13
  59. package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
  60. package/src/components/DocumentEdit/SplitInfoBar.vue +21 -0
  61. package/src/components/DocumentEdit/index.js +1 -1
  62. package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +9 -8
  63. package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
  64. package/src/components/DocumentPage/ActionBar.vue +3 -3
  65. package/src/components/DocumentPage/AnnSetTableOptions.vue +110 -0
  66. package/src/components/DocumentPage/BoxSelection.vue +4 -1
  67. package/src/components/DocumentPage/DocumentPage.vue +92 -68
  68. package/src/components/DocumentPage/DocumentToolbar.vue +105 -16
  69. package/src/components/DocumentPage/DummyPage.vue +9 -7
  70. package/src/components/DocumentPage/MultiAnnSelection.vue +96 -27
  71. package/src/components/DocumentPage/NewAnnotation.vue +31 -35
  72. package/src/components/DocumentPage/ScrollingDocument.vue +46 -5
  73. package/src/components/DocumentPage/ScrollingPage.vue +5 -6
  74. package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +64 -0
  75. package/src/components/DocumentThumbnails/DocumentThumbnails.vue +53 -13
  76. package/src/components/DocumentTopBar/DocumentName.vue +16 -4
  77. package/src/components/DocumentTopBar/DocumentTopBar.vue +86 -15
  78. package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +99 -72
  79. package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +6 -3
  80. package/src/components/DocumentsList/DocumentsList.vue +6 -2
  81. package/src/components/index.js +1 -0
  82. package/src/constants.js +2 -1
  83. package/src/icons.js +45 -0
  84. package/src/locales/de.json +48 -21
  85. package/src/locales/en.json +37 -11
  86. package/src/locales/es.json +41 -13
  87. package/src/main.js +5 -66
  88. package/src/store/category.js +20 -36
  89. package/src/store/display.js +74 -1
  90. package/src/store/document.js +305 -109
  91. package/src/store/edit.js +160 -61
  92. package/src/store/project.js +46 -16
  93. package/src/store/selection.js +42 -10
  94. package/src/utils/utils.js +36 -0
  95. package/dist/css/chunk-vendors.css +0 -5
  96. package/src/.DS_Store +0 -0
  97. package/src/assets/scss/categorize_modal.scss +0 -45
  98. package/src/assets/scss/main.scss +0 -24
  99. package/src/components/DocumentAnnotations/ActionButtons.vue +0 -250
  100. package/src/components/DocumentAnnotations/CategorizeModal.vue +0 -219
  101. package/src/components/DocumentAnnotations/RejectedLabels.vue +0 -96
  102. package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +0 -253
@@ -1,36 +1,51 @@
1
1
  <template>
2
- <div :class="['document-edit', splitOverview && 'split-overview-component']">
3
- <div v-if="!splitOverview" class="pages-section">
2
+ <div
3
+ :class="[
4
+ 'document-edit',
5
+ renameAndCategorize && 'rename-and-categorize-component',
6
+ ]"
7
+ >
8
+ <div v-if="!renameAndCategorize" class="pages-section">
4
9
  <EditPages
5
- :active-splitting-lines="activeSplittingLines"
6
- @change-page="changePage"
10
+ :splitting-lines="splittingLines"
11
+ :split-suggestions-enabled="splitSuggestionsEnabled"
7
12
  @handle-splitting-lines="handleSplittingLines"
8
13
  @check-move="checkMove"
9
14
  @handle-drag-end="handleDragEnd"
10
15
  />
16
+ <div class="info-bar">
17
+ <SplitInfoBar v-if="splitSuggestionsEnabled" />
18
+ </div>
11
19
  </div>
12
- <div v-else class="split-overview-section">
13
- <SplitOverview
20
+ <div v-else class="rename-and-categorize-section">
21
+ <RenameAndCategorize
14
22
  :file-name="fileName"
15
23
  :file-extension="fileExtension"
16
24
  @change-page="changePage"
17
25
  />
18
26
  </div>
19
- <div v-if="!splitOverview" class="sidebar">
27
+ <div v-if="!renameAndCategorize" class="sidebar">
20
28
  <EditSidebar
21
- @rotate-left="rotatePage"
22
- @rotate-right="rotatePage"
29
+ :split-suggestions-enabled="splitSuggestionsEnabled"
30
+ @rotate="rotatePage"
23
31
  @rotate-all-left="handleRotationsToTheLeft"
24
32
  @rotate-all-right="handleRotationsToTheRight"
33
+ @handle-splitting-suggestions="applySplittingSuggestions"
25
34
  />
26
35
  </div>
36
+ <div class="confirmation-modal-container">
37
+ <EditConfirmationModal @save-changes="saveEditChanges" />
38
+ </div>
27
39
  </div>
28
40
  </template>
29
41
  <script>
30
- import { mapState } from "vuex";
42
+ import { mapState, mapGetters } from "vuex";
31
43
  import EditSidebar from "./EditSidebar";
32
- import SplitOverview from "./SplitOverview";
44
+ import RenameAndCategorize from "./RenameAndCategorize";
33
45
  import EditPages from "./EditPages";
46
+ import SplitInfoBar from "./SplitInfoBar";
47
+ import EditConfirmationModal from "./EditConfirmationModal";
48
+ import { navigateToDocumentsList } from "../../utils/utils";
34
49
 
35
50
  /**
36
51
  * This component shows a document thumbnail grid view and sidebar, to be able to edit the document.
@@ -39,44 +54,66 @@ export default {
39
54
  name: "DocumentEdit",
40
55
  components: {
41
56
  EditSidebar,
42
- SplitOverview,
57
+ RenameAndCategorize,
43
58
  EditPages,
59
+ SplitInfoBar,
60
+ EditConfirmationModal,
44
61
  },
45
62
  data() {
46
63
  return {
47
- fileName: [],
64
+ fileName: null,
48
65
  fileExtension: null,
49
- activeSplittingLines: [],
66
+ splittingLines: [],
50
67
  dragging: false,
51
68
  prevPageAtIndex: null,
69
+ splitSuggestionsEnabled: false,
52
70
  };
53
71
  },
54
72
  computed: {
55
- ...mapState("document", ["recalculatingAnnotations", "selectedDocument"]),
73
+ ...mapState("document", [
74
+ "recalculatingAnnotations",
75
+ "selectedDocument",
76
+ "splittingSuggestions",
77
+ "pages",
78
+ ]),
56
79
  ...mapState("display", ["currentPage"]),
57
80
  ...mapState("edit", [
58
81
  "editMode",
59
- "documentPagesListForEditMode",
82
+ "pagesForPostprocess",
60
83
  "updatedDocument",
61
- "splitOverview",
84
+ "renameAndCategorize",
62
85
  "selectedPages",
86
+ "submitEditChanges",
63
87
  ]),
88
+ ...mapState("project", ["projectId", "documentsListPath", "currentUser"]),
89
+ ...mapGetters("edit", ["documentShouldBePostprocessed"]),
90
+ ...mapGetters("document", ["waitingForSplittingConfirmation"]),
64
91
  },
65
92
  watch: {
66
- pages() {
67
- if (!this.selectedDocument) return;
68
- this.setPages();
69
- },
70
- splitOverview(newValue) {
93
+ renameAndCategorize(newValue) {
71
94
  if (newValue) {
72
95
  this.splitFileNameFromExtension();
73
96
  }
74
97
  },
75
- documentPagesListForEditMode(newValue) {
98
+ pagesForPostprocess(newValue, oldValue) {
76
99
  if (newValue) {
77
- this.saveUpdatedDocument();
100
+ this.saveUpdatedDocuments();
101
+ }
102
+ },
103
+ splittingLines(newValue) {
104
+ const aiSplit = newValue.find((item) => item.origin === "AI");
105
+
106
+ // If there are no AI suggestions left, because of being manually removed by the user
107
+ // the Smart Split switch should be turned off
108
+ if (!aiSplit) {
109
+ this.splitSuggestionsEnabled = false;
78
110
  }
79
111
  },
112
+ submitEditChanges(newValue) {
113
+ if (!newValue) return;
114
+
115
+ this.saveEditChanges();
116
+ },
80
117
  },
81
118
  mounted() {
82
119
  this.setPages();
@@ -86,16 +123,30 @@ export default {
86
123
  if (!this.selectedDocument) {
87
124
  return;
88
125
  }
89
- // set array of pages only with the data we need
90
- const pages = this.createDocumentPagesListForEditMode();
91
- this.$store.dispatch("edit/setDocumentPagesListForEditMode", pages);
92
- // create array to handle the splitting
93
- // length - 1 because of how many lines to split we need (last one not necessary)
94
- this.activeSplittingLines = new Array(
95
- this.selectedDocument.pages.length - 1
126
+
127
+ // set array of pages only with the data we need for postprocessing the document
128
+ this.$store.dispatch(
129
+ "edit/setPagesForPostprocess",
130
+ this.createPagesForPostprocess()
96
131
  );
132
+
133
+ // Create array with placeholder data for the splitting points
134
+ if (this.selectedDocument.pages.length > 0) {
135
+ this.selectedDocument.pages.map((page) => {
136
+ if (page.number === this.selectedDocument.pages.length) {
137
+ this.setSplittingArray(page.number, null);
138
+ return;
139
+ }
140
+ this.setSplittingArray(0, null);
141
+ });
142
+
143
+ if (this.splittingSuggestions) {
144
+ this.splitSuggestionsEnabled = true;
145
+ this.setAutomaticSplitting();
146
+ }
147
+ }
97
148
  },
98
- createDocumentPagesListForEditMode() {
149
+ createPagesForPostprocess() {
99
150
  return this.selectedDocument.pages.map((page) => {
100
151
  return {
101
152
  id: page.id,
@@ -120,13 +171,11 @@ export default {
120
171
 
121
172
  /** ROTATE */
122
173
  rotatePage(direction) {
123
- const page = this.selectedPages.map((page) => {
124
- return page;
125
- });
126
-
127
- this.$store.dispatch("edit/rotatePage", {
128
- page,
129
- direction,
174
+ this.selectedPages.forEach((page) => {
175
+ this.$store.dispatch("edit/rotatePage", {
176
+ page,
177
+ direction,
178
+ });
130
179
  });
131
180
  },
132
181
  handleRotationsToTheLeft() {
@@ -137,76 +186,119 @@ export default {
137
186
  },
138
187
 
139
188
  /** SPLIT */
189
+ setAutomaticSplitting() {
190
+ // map over splitting suggestions to find the page number based on the page id
191
+ // to update the splittingLines array with this data
192
+ if (!this.splittingSuggestions) return;
193
+
194
+ this.splittingSuggestions.map((item) => {
195
+ const lastPage = this.selectedDocument.pages.find(
196
+ (page) => page.id === item.pages[item.pages.length - 1].id
197
+ );
198
+
199
+ this.handleSplittingLines(lastPage.number, "AI");
200
+ });
201
+ },
202
+ applySplittingSuggestions(value) {
203
+ // Show information bar
204
+ this.splitSuggestionsEnabled = value;
205
+
206
+ // Apply or remove split lines
207
+ this.setAutomaticSplitting();
208
+ },
209
+ setSplittingArray(pageNumber, splittingOrigin) {
210
+ // This function sets the splittingLines array
211
+ // based on splitting suggestions or no suggestions
212
+ this.splittingLines.push({
213
+ page: pageNumber,
214
+ origin: splittingOrigin,
215
+ });
216
+ },
140
217
  splitFileNameFromExtension() {
141
- if (!this.selectedDocument) return;
218
+ if (!this.selectedDocument && !this.selectedDocument.data_file_name)
219
+ return;
142
220
 
143
221
  // Save the file name and the extension in different variables
144
222
  // to be used in the next step of the splitting
223
+ this.fileName = this.selectedDocument.data_file_name
224
+ .split(".")
225
+ .slice(0, -1)
226
+ .join(".");
145
227
 
146
- if (this.selectedDocument.data_file_name) {
147
- this.fileName = this.selectedDocument.data_file_name
148
- .split(".")
149
- .slice(0, -1)
150
- .join(".");
151
- }
152
-
153
- if (this.selectedDocument.data_file_name) {
154
- this.fileExtension = this.selectedDocument.data_file_name
155
- .split(".")
156
- .at(-1);
157
- }
228
+ this.fileExtension = this.selectedDocument.data_file_name
229
+ .split(".")
230
+ .at(-1);
158
231
  },
159
- handleSplittingLines(page) {
160
- // For splitting line purposes
161
- // Add page number to specific index
162
- // Or replace it with 0 (to keep the same index) if it exists
163
- const found = this.activeSplittingLines.find(
164
- (item) => item === page.number
165
- );
232
+ handleSplittingLines(page, origin) {
233
+ // To select and deselect the division lines
234
+ // Add page number & origin to specific index
235
+ // Or replace it with 0 (to keep the same index & array length) if it exists
236
+ const found = this.splittingLines.find((item) => item.page === page);
237
+
238
+ // new line added or removed based on the page clicked:
239
+ const newPage = { page: page, origin: origin };
240
+ const removedPage = { page: 0, origin: origin };
166
241
 
167
- if (found) {
168
- this.activeSplittingLines.splice(page.number - 1, 1, 0);
242
+ if (this.splitSuggestionsEnabled && origin === "AI") {
243
+ // if manual suggestions were added but we enable automatic splitting,
244
+ // this last one takes over
245
+ this.splittingLines.splice(page - 1, 1, newPage);
246
+ } else if (
247
+ page === this.splittingLines.length ||
248
+ (!this.splitSuggestionsEnabled && !found && origin === "AI")
249
+ ) {
250
+ // check if it's the last item to keep unchanged
251
+ // Or if splitting is switched off, but some of the suggestion lines
252
+ // were removed manually
253
+ return;
254
+ } else if (found) {
255
+ // If splitting is switched off and we have manual splits,
256
+ // those should stay unchanged
257
+ if (!this.splitSuggestionsEnabled && found.origin !== origin) {
258
+ return;
259
+ }
260
+
261
+ this.splittingLines.splice(page - 1, 1, removedPage);
169
262
  } else {
170
- this.activeSplittingLines.splice(page.number - 1, 1, page.number);
263
+ this.splittingLines.splice(page - 1, 1, newPage);
171
264
  }
172
265
 
173
- this.saveUpdatedDocument();
266
+ this.saveUpdatedDocuments();
174
267
  },
175
- saveUpdatedDocument() {
268
+ saveUpdatedDocuments() {
176
269
  this.splitFileNameFromExtension();
177
270
 
178
- // Check how many sub docs we have
179
- const subDocuments = this.activeSplittingLines.filter(
180
- (item) => item !== 0
271
+ const clickedLines = this.splittingLines.filter(
272
+ (item) => item.page !== 0
273
+ );
274
+
275
+ const newDocuments = this.createEachNewDocument(
276
+ clickedLines,
277
+ clickedLines.length
181
278
  );
182
279
 
183
- // Create array of objects
184
- // with a fixed size based on how many sub documents are currently
185
- const pageObjectArray = new Array(subDocuments.length + 1);
186
-
187
- // Loop over the created array
188
- // for each iteration we create the page object with the correponding data
189
- for (let i = 0; i < pageObjectArray.length; i++) {
190
- const pageObject = {
191
- name: this.handleFileName(i),
192
- category: this.selectedDocument.category,
193
- pages: this.handleSubPages(i, subDocuments),
280
+ // // Set the state to the created array
281
+ this.$store.dispatch("edit/setUpdatedDocument", newDocuments);
282
+ },
283
+ createEachNewDocument(clickedLines, length) {
284
+ const documents = new Array(length);
285
+
286
+ for (let i = 0; i < length; i++) {
287
+ const newDocument = {
288
+ name: this.handleNewDocumentName(i),
289
+ category: this.handleNewDocumentCategory(i, clickedLines),
290
+ pages: this.handleNewDocumentPages(i, clickedLines),
194
291
  };
195
292
 
196
- // Then we replace the "undefined" with the created object
197
- pageObjectArray.splice(i, 1, pageObject);
293
+ // we replace the "undefined" with the created object
294
+ documents.splice(i, 1, newDocument);
198
295
  }
199
296
 
200
- // Set the state to the created array
201
- this.$store.dispatch("edit/setUpdatedDocument", pageObjectArray);
297
+ return documents;
202
298
  },
203
- handleFileName(index) {
299
+ handleNewDocumentName(index) {
204
300
  let newFileName;
205
301
 
206
- // Return original file name,
207
- // file name + copy,
208
- // or file name + copy + number
209
- // based on where the object will be located in the array
210
302
  if (index === 0) {
211
303
  newFileName = this.selectedDocument.data_file_name;
212
304
  } else if (index === 1) {
@@ -216,50 +308,155 @@ export default {
216
308
  }
217
309
  return newFileName;
218
310
  },
219
- handleSubPages(index, splittingLine) {
220
- // assign the correct pages to each object
311
+ handleNewDocumentCategory(index, clickedLines) {
312
+ if (clickedLines[index].origin && clickedLines[index].origin === "AI") {
313
+ // get the index of the new document in the splitting suggestions
314
+ // to return its category
315
+ const i = this.indexOfSplittingSuggestion(index, clickedLines);
316
+
317
+ return this.splittingSuggestions[i].category;
318
+ } else {
319
+ return this.selectedDocument.category;
320
+ }
321
+ },
322
+ handleNewDocumentPages(index, clickedLines) {
323
+ // assign the correct pages to each new document
221
324
  let pages;
222
325
 
223
326
  if (index === 0) {
224
- pages = this.documentPagesListForEditMode.slice(
225
- 0,
226
- splittingLine[index]
227
- );
327
+ pages = this.pagesForPostprocess.slice(0, clickedLines[index].page);
228
328
  } else {
229
- if (!splittingLine[index]) {
230
- pages = this.documentPagesListForEditMode.slice(
231
- splittingLine[index - 1]
232
- );
329
+ if (!clickedLines[index].page) {
330
+ pages = this.pagesForPostprocess.slice(clickedLines[index - 1].page);
233
331
  } else {
234
- pages = this.documentPagesListForEditMode.slice(
235
- splittingLine[index - 1],
236
- splittingLine[index]
332
+ pages = this.pagesForPostprocess.slice(
333
+ clickedLines[index - 1].page,
334
+ clickedLines[index].page
237
335
  );
238
336
  }
239
337
  }
338
+
240
339
  return pages;
241
340
  },
341
+ indexOfSplittingSuggestion(index, clickedLines) {
342
+ const foundPage = this.selectedDocument.pages.find(
343
+ (page) => page.number === clickedLines[index].page
344
+ );
345
+
346
+ const singleSplittingSuggestion = this.splittingSuggestions.find(
347
+ (item) => item.pages[item.pages.length - 1].id === foundPage.id
348
+ );
349
+
350
+ return this.splittingSuggestions.indexOf(singleSplittingSuggestion);
351
+ },
242
352
 
243
353
  /** SORT */
244
354
  checkMove(e) {
245
355
  // Save the page placed originally where the page we are dragging will go
246
- this.prevPageAtIndex = this.documentPagesListForEditMode.find(
356
+ this.prevPageAtIndex = this.pagesForPostprocess.find(
247
357
  (page) =>
248
- this.documentPagesListForEditMode.indexOf(page) ===
358
+ this.pagesForPostprocess.indexOf(page) ===
249
359
  e.draggedContext.futureIndex
250
360
  );
251
361
  },
252
362
  handleDragEnd() {
253
363
  // Update page numbers
254
- const pages = this.documentPagesListForEditMode.map((page) => {
255
- const index = this.documentPagesListForEditMode.indexOf(page);
364
+ const pages = this.pagesForPostprocess.map((page) => {
365
+ const index = this.pagesForPostprocess.indexOf(page);
256
366
  return {
257
367
  ...page,
258
368
  number: index + 1,
259
369
  };
260
370
  });
261
371
 
262
- this.$store.dispatch("edit/setDocumentPagesListForEditMode", pages);
372
+ this.$store.dispatch("edit/setPagesForPostprocess", pages);
373
+ },
374
+
375
+ /** SUBMIT CHANGES */
376
+ // Send update request to the backend
377
+ saveEditChanges() {
378
+ // Verify if there was splitting, rotating and/or reordering
379
+ if (
380
+ this.documentShouldBePostprocessed ||
381
+ this.waitingForSplittingConfirmation(this.selectedDocument)
382
+ ) {
383
+ this.$store
384
+ .dispatch("edit/editDocument", this.updatedDocument)
385
+ .catch((error) => {
386
+ this.$store.dispatch("document/createErrorMessage", {
387
+ error,
388
+ serverErrorMessage: this.$t("server_error"),
389
+ defaultErrorMessage: this.$t("edit_error"),
390
+ });
391
+ });
392
+
393
+ const redirection = navigateToDocumentsList(
394
+ this.documentsListPath,
395
+ this.projectId,
396
+ this.currentUser.id
397
+ );
398
+
399
+ if (redirection) {
400
+ this.$store.dispatch("edit/setRedirectingUser", true);
401
+ }
402
+ } else {
403
+ // Check if only the category and/or name changes:
404
+ const newCategory = this.updatedDocument[0].category;
405
+ const newName = this.updatedDocument[0].name;
406
+ let category = {};
407
+ let name = {};
408
+ let revisedCategory = {};
409
+
410
+ if (this.selectedDocument.category !== newCategory) {
411
+ Object.assign(category, {
412
+ category: newCategory,
413
+ });
414
+
415
+ this.$store.dispatch("document/startLoading");
416
+ }
417
+
418
+ if (!this.selectedDocument.category_is_revised && newCategory) {
419
+ Object.assign(revisedCategory, {
420
+ category_is_revised: true,
421
+ });
422
+ }
423
+
424
+ if (this.selectedDocument.data_file_name !== newName) {
425
+ Object.assign(name, { data_file_name: newName });
426
+ }
427
+
428
+ if (!category && !name) {
429
+ return;
430
+ }
431
+
432
+ const updatedValues = Object.assign(category, revisedCategory, name);
433
+
434
+ this.$store
435
+ .dispatch("document/updateDocument", updatedValues)
436
+ .catch((error) => {
437
+ this.$store.dispatch("document/endLoading");
438
+ this.$store.dispatch("document/createErrorMessage", {
439
+ error,
440
+ serverErrorMessage: this.$t("server_error"),
441
+ defaultErrorMessage: this.$t("edit_error"),
442
+ });
443
+ });
444
+ }
445
+
446
+ this.closeEditMode();
447
+ },
448
+
449
+ closeEditMode() {
450
+ this.$store.dispatch("edit/disableEditMode");
451
+ this.$store.dispatch("edit/setRenameAndCategorize", false);
452
+ this.$store.dispatch("edit/setUpdatedDocument", null);
453
+ this.$store.dispatch("edit/setSelectedPages", null);
454
+ this.$store.dispatch("edit/setSubmitEditChanges", false);
455
+ this.$store.dispatch("edit/setShowEditConfirmationModal", false);
456
+ this.$nextTick(() => {
457
+ // reset to first page
458
+ this.$store.dispatch("display/updateCurrentPage", 1);
459
+ });
263
460
  },
264
461
  },
265
462
  };
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <section class="edit-confirmation-modal">
3
+ <b-modal v-model="isModalActive" :can-cancel="[]" class="edit-modal">
4
+ <section class="modal-card-body">
5
+ <div class="header">
6
+ <p class="modal-title">{{ $t("confirm_splitting") }}</p>
7
+ </div>
8
+ <div class="content">{{ $t("splitting_warning") }}</div>
9
+ </section>
10
+ <footer class="modal-card-foot">
11
+ <b-button @click="closeModal">
12
+ {{ $t("no") }}
13
+ </b-button>
14
+ <b-button type="is-primary" @click="confirmChanges">
15
+ {{ $t("yes") }}
16
+ </b-button>
17
+ </footer>
18
+ </b-modal>
19
+ </section>
20
+ </template>
21
+
22
+ <script>
23
+ import { mapState } from "vuex";
24
+ /**
25
+ * This component shows a modal to confirm the edit changes in the document
26
+ */
27
+ export default {
28
+ name: "EditConfirmationModal",
29
+ data() {
30
+ return {
31
+ isModalActive: false,
32
+ };
33
+ },
34
+ computed: {
35
+ ...mapState("edit", ["showEditConfirmationModal"]),
36
+ },
37
+ watch: {
38
+ showEditConfirmationModal(newValue) {
39
+ this.isModalActive = newValue;
40
+ },
41
+ },
42
+ methods: {
43
+ closeModal() {
44
+ this.isModalActive = false;
45
+ this.$store.dispatch("edit/setShowEditConfirmationModal", false);
46
+ },
47
+ confirmChanges() {
48
+ this.$emit("save-changes");
49
+ this.isModalActive = false;
50
+ },
51
+ },
52
+ };
53
+ </script>
54
+
55
+ <style scoped lang="scss" src="../../assets/scss/document_edit.scss"></style>