@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
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
- documentPagesListForEditMode: [], // TODO: change name
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
- setDocumentPagesListForEditMode: ({ commit }, pages) => {
29
- commit("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", pages);
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.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
- };
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 p;
71
+ return {
72
+ ...p,
73
+ angle: rotatedAngle,
74
+ };
76
75
  }
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
- };
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 p;
84
+ return {
85
+ ...p,
86
+ angle: rotatedAngle,
87
+ };
89
88
  }
90
- });
89
+ return p;
90
+ }
91
+ });
91
92
 
92
- commit("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", documentPagesListForEditMode);
93
+ commit("SET_PAGES_FOR_POSTPROCESS", pagesForPostprocess);
93
94
  } else {
94
95
  if (direction === "left") {
95
- state.documentPagesListForEditMode.push({
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.documentPagesListForEditMode.push({
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.documentPagesListForEditMode.map((p) => {
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("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", array);
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.documentPagesListForEditMode.map((p) => {
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("SET_DOCUMENT_PAGES_FOR_EDIT_MODE", array);
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 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
- });
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
- SET_DOCUMENT_PAGES_FOR_EDIT_MODE: (state, pages) => {
191
- state.documentPagesListForEditMode = pages;
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 {
@@ -3,7 +3,7 @@ const HTTP = myImports.HTTP;
3
3
 
4
4
  const state = {
5
5
  projectId: null,
6
- currentUser: null
6
+ currentUser: null,
7
7
  };
8
8
 
9
9
  const getters = {
@@ -11,13 +11,13 @@ const getters = {
11
11
  * Gets label sets for an annotation set creation
12
12
  */
13
13
  labelSetsFilteredForAnnotationSetCreation:
14
- state => (labelsSet, annotationSets) => {
14
+ (state) => (labelsSet, annotationSets) => {
15
15
  let returnLabels = [];
16
16
  if (labelsSet) {
17
- returnLabels = labelsSet.filter(labelSet => {
17
+ returnLabels = labelsSet.filter((labelSet) => {
18
18
  // check if label set has multiple and if not, if there's already an annotation set created
19
19
  if (!labelSet.has_multiple_annotation_sets) {
20
- const existingAnnotationSet = annotationSets.find(annSet => {
20
+ const existingAnnotationSet = annotationSets.find((annSet) => {
21
21
  return annSet.id === labelSet.id;
22
22
  });
23
23
  return existingAnnotationSet;
@@ -27,7 +27,7 @@ const getters = {
27
27
  });
28
28
  }
29
29
  return returnLabels;
30
- }
30
+ },
31
31
  };
32
32
 
33
33
  const actions = {
@@ -38,10 +38,10 @@ const actions = {
38
38
  fetchLabelSetDetails: ({ commit, state }, labelSetId) => {
39
39
  return new Promise((resolve, reject) => {
40
40
  HTTP.get(`label-sets/${labelSetId}/`)
41
- .then(response => {
41
+ .then((response) => {
42
42
  return resolve(response.data);
43
43
  })
44
- .catch(error => {
44
+ .catch((error) => {
45
45
  reject(error);
46
46
  console.log(error);
47
47
  });
@@ -52,10 +52,10 @@ const actions = {
52
52
  fetchLabelSets: ({ state }) => {
53
53
  return new Promise((resolve, reject) => {
54
54
  HTTP.get(`label-sets/?project=${state.projectId}`)
55
- .then(response => {
55
+ .then((response) => {
56
56
  return resolve(response.data.results);
57
57
  })
58
- .catch(error => {
58
+ .catch((error) => {
59
59
  reject(error);
60
60
  console.log(error);
61
61
  });
@@ -64,17 +64,17 @@ const actions = {
64
64
 
65
65
  fetchCurrentUser: ({ commit }) => {
66
66
  return HTTP.get(`/auth/me/`)
67
- .then(response => {
67
+ .then((response) => {
68
68
  commit("SET_CURRENT_USER", response.data.username);
69
69
  })
70
- .catch(error => {
70
+ .catch((error) => {
71
71
  console.log(error);
72
72
  });
73
73
  },
74
74
 
75
75
  setCurrentUser: ({ commit }, currentUser) => {
76
76
  commit("SET_CURRENT_USER", currentUser);
77
- }
77
+ },
78
78
  };
79
79
 
80
80
  const mutations = {
@@ -83,7 +83,7 @@ const mutations = {
83
83
  },
84
84
  SET_CURRENT_USER: (state, currentUser) => {
85
85
  state.currentUser = currentUser;
86
- }
86
+ },
87
87
  };
88
88
 
89
89
  export default {
@@ -91,5 +91,5 @@ export default {
91
91
  state,
92
92
  actions,
93
93
  mutations,
94
- getters
94
+ getters,
95
95
  };