@konfuzio/document-validation-ui 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +10 -10
- package/.prettierrc.json +1 -1
- package/LICENSE +21 -21
- package/README.md +24 -24
- package/cypress.config.js +13 -13
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/dist/js/chunk-vendors.js +1 -1
- package/dist/js/chunk-vendors.js.map +1 -1
- package/jest.config.js +4 -4
- package/package.json +66 -66
- package/src/api.js +82 -82
- package/src/assets/images/AcceptedCheckMark.vue +8 -8
- package/src/assets/images/AcceptedUser.vue +8 -8
- package/src/assets/images/ActionIcon.vue +60 -60
- package/src/assets/images/ArrowDownKey.vue +11 -11
- package/src/assets/images/ArrowUpKey.vue +11 -11
- package/src/assets/images/CategoryIconImg.vue +13 -13
- package/src/assets/images/CheckMark.vue +8 -8
- package/src/assets/images/DraggableIcon.vue +14 -14
- package/src/assets/images/EditDocIcon.vue +12 -12
- package/src/assets/images/EmptyStateImg.vue +129 -129
- package/src/assets/images/ErrorIcon.vue +28 -28
- package/src/assets/images/EyeIcon.vue +11 -11
- package/src/assets/images/FileNameNotSavedImage.vue +26 -26
- package/src/assets/images/FileNameSavedImage.vue +14 -14
- package/src/assets/images/FitZoomIcon.vue +16 -16
- package/src/assets/images/GridIcon.vue +16 -16
- package/src/assets/images/KeyboardIcon.vue +16 -16
- package/src/assets/images/MagicWandIcon.vue +16 -16
- package/src/assets/images/MinusIcon.vue +13 -13
- package/src/assets/images/NotFoundIcon.vue +16 -16
- package/src/assets/images/NotOptimizedIllustration.vue +651 -651
- package/src/assets/images/PlusIcon.vue +13 -13
- package/src/assets/images/QuestionMark.vue +12 -12
- package/src/assets/images/ServerImage.vue +73 -73
- package/src/assets/images/SettingsIcon.vue +14 -14
- package/src/assets/images/SplitLines.vue +18 -18
- package/src/assets/images/SplitZigZag.vue +49 -49
- package/src/assets/images/StarIcon.vue +16 -16
- package/src/assets/images/StatusImg.vue +14 -14
- package/src/assets/images/TranslateArrows.vue +33 -33
- package/src/assets/scss/ann_set_table_options.scss +26 -26
- package/src/assets/scss/annotation_details.scss +141 -141
- package/src/assets/scss/choose_label_set_modal.scss +65 -65
- package/src/assets/scss/document_action_bar.scss +37 -37
- package/src/assets/scss/document_annotations.scss +558 -558
- package/src/assets/scss/document_category.scss +85 -85
- package/src/assets/scss/document_dashboard.scss +52 -52
- package/src/assets/scss/document_edit.scss +410 -410
- package/src/assets/scss/document_error.scss +81 -81
- package/src/assets/scss/document_name.scss +60 -60
- package/src/assets/scss/document_page.scss +12 -12
- package/src/assets/scss/document_thumbnails.scss +41 -41
- package/src/assets/scss/document_toolbar.scss +111 -111
- package/src/assets/scss/document_top_bar.scss +171 -171
- package/src/assets/scss/document_viewport_modal.scss +25 -25
- package/src/assets/scss/documents_list.scss +141 -141
- package/src/assets/scss/edit_page_thumbnail.scss +53 -53
- package/src/assets/scss/empty_state.scss +34 -34
- package/src/assets/scss/extracting_data.scss +35 -35
- package/src/assets/scss/imports.scss +1 -1
- package/src/assets/scss/multi_ann_table_overlay.scss +38 -38
- package/src/assets/scss/multi_ann_table_popup.scss +12 -12
- package/src/assets/scss/new_annotation.scss +102 -102
- package/src/assets/scss/scrolling_document.scss +19 -19
- package/src/assets/scss/theme.scss +801 -801
- package/src/assets/scss/variables.scss +66 -66
- package/src/components/App.cy.js +7 -7
- package/src/components/App.vue +187 -187
- package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +152 -152
- package/src/components/DocumentAnnotations/AnnotationContent.vue +210 -210
- package/src/components/DocumentAnnotations/AnnotationDetails.vue +251 -251
- package/src/components/DocumentAnnotations/AnnotationRow.vue +752 -752
- package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -89
- package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +186 -186
- package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +441 -441
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +534 -534
- package/src/components/DocumentAnnotations/DocumentLabel.vue +189 -189
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +193 -193
- package/src/components/DocumentAnnotations/EmptyState.vue +21 -21
- package/src/components/DocumentAnnotations/ExtractingData.vue +41 -41
- package/src/components/DocumentAnnotations/LoadingAnnotations.vue +43 -43
- package/src/components/DocumentAnnotations/LoadingLabels.vue +43 -43
- package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +338 -338
- package/src/components/DocumentAnnotations/index.js +8 -8
- package/src/components/DocumentCategory.vue +281 -281
- package/src/components/DocumentDashboard.vue +170 -170
- package/src/components/DocumentEdit/DocumentEdit.cy.js +541 -541
- package/src/components/DocumentEdit/DocumentEdit.vue +503 -503
- package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -55
- package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -114
- package/src/components/DocumentEdit/EditPages.vue +161 -161
- package/src/components/DocumentEdit/EditSidebar.vue +154 -154
- package/src/components/DocumentEdit/RenameAndCategorize.vue +184 -184
- package/src/components/DocumentEdit/SidebarButtons.vue +53 -53
- package/src/components/DocumentEdit/SplitInfoBar.vue +21 -21
- package/src/components/DocumentEdit/index.js +4 -4
- package/src/components/DocumentModals/DocumentErrorModal.vue +58 -58
- package/src/components/DocumentModals/NotOptimizedViewportModal.vue +51 -51
- package/src/components/DocumentPage/ActionBar.vue +48 -48
- package/src/components/DocumentPage/AnnSetTableOptions.vue +111 -111
- package/src/components/DocumentPage/BoxSelection.vue +152 -152
- package/src/components/DocumentPage/DocumentPage.cy.js +92 -92
- package/src/components/DocumentPage/DocumentPage.vue +568 -568
- package/src/components/DocumentPage/DocumentToolbar.cy.js +215 -215
- package/src/components/DocumentPage/DocumentToolbar.vue +228 -228
- package/src/components/DocumentPage/DummyPage.vue +55 -55
- package/src/components/DocumentPage/MultiAnnSelection.vue +371 -371
- package/src/components/DocumentPage/NewAnnotation.vue +308 -308
- package/src/components/DocumentPage/ScrollingDocument.vue +149 -149
- package/src/components/DocumentPage/ScrollingPage.vue +179 -179
- package/src/components/DocumentPage/index.js +5 -5
- package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +67 -67
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +132 -132
- package/src/components/DocumentThumbnails/LoadingThumbnail.vue +25 -25
- package/src/components/DocumentThumbnails/index.js +1 -1
- package/src/components/DocumentTopBar/DocumentName.vue +236 -236
- package/src/components/DocumentTopBar/DocumentTopBar.cy.js +222 -222
- package/src/components/DocumentTopBar/DocumentTopBar.vue +202 -202
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +183 -183
- package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +74 -74
- package/src/components/DocumentTopBar/index.js +3 -3
- package/src/components/DocumentsList/DocumentsList.vue +121 -121
- package/src/components/DocumentsList/index.js +1 -1
- package/src/components/ErrorMessage.vue +40 -40
- package/src/components/index.js +1 -1
- package/src/constants.js +5 -5
- package/src/directives/scroll.js +28 -28
- package/src/i18n.js +22 -22
- package/src/icons.js +45 -45
- package/src/locales/de.json +148 -148
- package/src/locales/en.json +148 -148
- package/src/main.js +26 -26
- package/src/store/category.js +191 -191
- package/src/store/display.js +311 -311
- package/src/store/document.js +1438 -1438
- package/src/store/edit.js +316 -316
- package/src/store/index.js +21 -21
- package/src/store/project.js +143 -143
- package/src/store/selection.js +210 -210
- package/src/utils/utils.js +54 -54
- package/vue.config.js +25 -25
package/src/store/edit.js
CHANGED
|
@@ -1,316 +1,316 @@
|
|
|
1
|
-
import myImports from "../api";
|
|
2
|
-
import {
|
|
3
|
-
getURLQueryParam,
|
|
4
|
-
navigateToNewDocumentURL,
|
|
5
|
-
getURLPath,
|
|
6
|
-
} from "../utils/utils";
|
|
7
|
-
|
|
8
|
-
const HTTP = myImports.HTTP;
|
|
9
|
-
|
|
10
|
-
const state = {
|
|
11
|
-
editMode: false,
|
|
12
|
-
renameAndCategorize: false,
|
|
13
|
-
isMultipleSelection: true,
|
|
14
|
-
pagesForPostprocess: [],
|
|
15
|
-
selectedPages: [],
|
|
16
|
-
updatedDocument: [],
|
|
17
|
-
showEditConfirmationModal: false,
|
|
18
|
-
submitEditChanges: false,
|
|
19
|
-
redirectingUser: false,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const getters = {
|
|
23
|
-
isEditModeAvailable: (state, getters, rootState, rootGetters) => {
|
|
24
|
-
return (
|
|
25
|
-
!rootState.document.publicView &&
|
|
26
|
-
!rootGetters["document/isDocumentReviewed"] &&
|
|
27
|
-
!state.editMode
|
|
28
|
-
);
|
|
29
|
-
},
|
|
30
|
-
isPageSelected: (state) => (id) => {
|
|
31
|
-
return state.selectedPages.find((page) => page.id === id);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
documentShouldBePostprocessed: (state, _, rootState) => {
|
|
35
|
-
const foundRotatedPage = state.pagesForPostprocess.find(
|
|
36
|
-
(page) => page.angle !== 0
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
let foundReorderedPage = false;
|
|
40
|
-
|
|
41
|
-
state.pagesForPostprocess.map((page, index) => {
|
|
42
|
-
if (
|
|
43
|
-
(page.id === rootState.document.selectedDocument.pages[index].id &&
|
|
44
|
-
page.number !==
|
|
45
|
-
rootState.document.selectedDocument.pages[index].number) ||
|
|
46
|
-
(page.id !== rootState.document.selectedDocument.pages[index].id &&
|
|
47
|
-
page.number ===
|
|
48
|
-
rootState.document.selectedDocument.pages[index].number)
|
|
49
|
-
) {
|
|
50
|
-
foundReorderedPage = true;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
state.updatedDocument.length > 1 || foundRotatedPage || foundReorderedPage
|
|
56
|
-
);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const actions = {
|
|
61
|
-
enableEditMode: ({ commit }) => {
|
|
62
|
-
commit("SET_EDIT_MODE", true);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
disableEditMode: ({ commit }) => {
|
|
66
|
-
commit("SET_EDIT_MODE", false);
|
|
67
|
-
commit("SET_RENAME_AND_CATEGORIZE", false);
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
setRenameAndCategorize: ({ commit }, value) => {
|
|
71
|
-
commit("SET_RENAME_AND_CATEGORIZE", value);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
setPagesForPostprocess: ({ commit }, pages) => {
|
|
75
|
-
commit("SET_PAGES_FOR_POSTPROCESS", pages);
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
setUpdatedDocument: ({ commit }, updatedDocument) => {
|
|
79
|
-
commit("SET_UPDATED_DOCUMENT", updatedDocument);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
setSubmitEditChanges: ({ commit }, value) => {
|
|
83
|
-
commit("SET_SUBMIT_EDIT_CHANGES", value);
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
selectPage: ({ state, commit }, page) => {
|
|
87
|
-
if (state.isMultipleSelection) {
|
|
88
|
-
commit("ADD_SELECTED_PAGE", page);
|
|
89
|
-
} else {
|
|
90
|
-
commit("SET_SELECTED_PAGES", []);
|
|
91
|
-
commit("ADD_SELECTED_PAGE", page);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
unselectPage: ({ state, commit }, selectedPage) => {
|
|
96
|
-
const found = state.selectedPages.find(
|
|
97
|
-
(page) => page.id === selectedPage.id
|
|
98
|
-
);
|
|
99
|
-
if (found) {
|
|
100
|
-
const filtered = state.selectedPages.filter(
|
|
101
|
-
(page) => page.id !== selectedPage.id
|
|
102
|
-
);
|
|
103
|
-
commit("SET_SELECTED_PAGES", filtered);
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
setSelectedPages: ({ state, commit }, selectedPage) => {
|
|
108
|
-
if (!selectedPage) {
|
|
109
|
-
commit("SET_SELECTED_PAGES", []);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const found = state.selectedPages.find(
|
|
114
|
-
(page) => page.id === selectedPage.id
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
if (found) {
|
|
118
|
-
const filtered = state.selectedPages.filter(
|
|
119
|
-
(page) => page.id !== selectedPage.id
|
|
120
|
-
);
|
|
121
|
-
commit("SET_SELECTED_PAGES", filtered);
|
|
122
|
-
} else if (state.isMultipleSelection) {
|
|
123
|
-
commit("ADD_SELECTED_PAGE", selectedPage);
|
|
124
|
-
} else {
|
|
125
|
-
commit("SET_SELECTED_PAGES", []);
|
|
126
|
-
commit("ADD_SELECTED_PAGE", selectedPage);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
rotatePage: ({ state, commit }, { page, direction }) => {
|
|
131
|
-
if (state.pagesForPostprocess.find((p) => p.id === page.id)) {
|
|
132
|
-
const pagesForPostprocess = state.pagesForPostprocess.map((p) => {
|
|
133
|
-
let rotatedAngle;
|
|
134
|
-
if (direction === "left") {
|
|
135
|
-
rotatedAngle = p.angle - 90;
|
|
136
|
-
if (p.id === page.id) {
|
|
137
|
-
if (rotatedAngle === -270) {
|
|
138
|
-
rotatedAngle = 90;
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
...p,
|
|
142
|
-
angle: rotatedAngle,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
return p;
|
|
146
|
-
}
|
|
147
|
-
if (direction === "right") {
|
|
148
|
-
rotatedAngle = p.angle + 90;
|
|
149
|
-
if (p.id === page.id) {
|
|
150
|
-
if (rotatedAngle === 270) {
|
|
151
|
-
rotatedAngle = -90;
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
...p,
|
|
155
|
-
angle: rotatedAngle,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
return p;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
commit("SET_PAGES_FOR_POSTPROCESS", pagesForPostprocess);
|
|
163
|
-
} else {
|
|
164
|
-
if (direction === "left") {
|
|
165
|
-
state.pagesForPostprocess.push({
|
|
166
|
-
id: page.id,
|
|
167
|
-
number: page.number,
|
|
168
|
-
angle: -90,
|
|
169
|
-
thumbnail_url: page.thumbnail_url,
|
|
170
|
-
updated_at: page.updated_at,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (direction === "right") {
|
|
175
|
-
state.pagesForPostprocess.push({
|
|
176
|
-
id: page.id,
|
|
177
|
-
number: page.number,
|
|
178
|
-
angle: 90,
|
|
179
|
-
thumbnail_url: page.thumbnail_url,
|
|
180
|
-
updated_at: page.updated_at,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
updateRotationToTheLeft: ({ state, commit }) => {
|
|
187
|
-
// updated the angles that will be sent to the backend
|
|
188
|
-
const array = state.pagesForPostprocess.map((p) => {
|
|
189
|
-
let rotatedAngle = p.angle - 90;
|
|
190
|
-
if (rotatedAngle === -270) {
|
|
191
|
-
rotatedAngle = 90;
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
...p,
|
|
195
|
-
angle: rotatedAngle,
|
|
196
|
-
};
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
updateRotationToTheRight: ({ state, commit }) => {
|
|
203
|
-
// updated the angles that will be sent to the backend
|
|
204
|
-
const array = state.pagesForPostprocess.map((p) => {
|
|
205
|
-
let rotatedAngle = p.angle + 90;
|
|
206
|
-
if (rotatedAngle === 270) {
|
|
207
|
-
rotatedAngle = -90;
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
...p,
|
|
211
|
-
angle: rotatedAngle,
|
|
212
|
-
};
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
editDocument: ({ rootState, commit, dispatch }, editedDocument) => {
|
|
219
|
-
dispatch("document/startRecalculatingAnnotations", null, {
|
|
220
|
-
root: true,
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const oldId = rootState.document.documentId;
|
|
224
|
-
|
|
225
|
-
return new Promise((resolve, reject) => {
|
|
226
|
-
HTTP.post(
|
|
227
|
-
`/documents/${rootState.document.documentId}/postprocess/`,
|
|
228
|
-
editedDocument
|
|
229
|
-
)
|
|
230
|
-
.then(async (response) => {
|
|
231
|
-
if (response && response.status === 200) {
|
|
232
|
-
const newId = response.data[0].id;
|
|
233
|
-
dispatch("document/setSplittingSuggestions", null, { root: true });
|
|
234
|
-
|
|
235
|
-
commit("SET_SUBMIT_EDIT_CHANGES", false);
|
|
236
|
-
|
|
237
|
-
if (newId != oldId) {
|
|
238
|
-
if (getURLQueryParam("document") || getURLPath("docs")) {
|
|
239
|
-
navigateToNewDocumentURL(oldId, newId);
|
|
240
|
-
} else {
|
|
241
|
-
await dispatch("document/setDocId", newId, {
|
|
242
|
-
root: true,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
dispatch("document/pollDocumentEndpoint", null, {
|
|
246
|
-
root: true,
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
} else {
|
|
250
|
-
dispatch("document/setSelectedDocument", response.data[0], {
|
|
251
|
-
root: true,
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
dispatch("document/pollDocumentEndpoint", null, {
|
|
255
|
-
root: true,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
resolve(response);
|
|
260
|
-
})
|
|
261
|
-
.catch((error) => {
|
|
262
|
-
reject(error.response);
|
|
263
|
-
console.log(error);
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
setShowEditConfirmationModal: ({ commit }, value) => {
|
|
269
|
-
commit("SET_SHOW_EDIT_CONFIRMATION_MODAL", value);
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
setRedirectingUser: ({ commit }, value) => {
|
|
273
|
-
commit("SET_REDIRECTING_USER", value);
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
const mutations = {
|
|
278
|
-
SET_EDIT_MODE: (state, option) => {
|
|
279
|
-
state.editMode = option;
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
SET_RENAME_AND_CATEGORIZE: (state, value) => {
|
|
283
|
-
state.renameAndCategorize = value;
|
|
284
|
-
},
|
|
285
|
-
|
|
286
|
-
SET_PAGES_FOR_POSTPROCESS: (state, pages) => {
|
|
287
|
-
state.pagesForPostprocess = pages;
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
SET_UPDATED_DOCUMENT: (state, updatedDocument) => {
|
|
291
|
-
state.updatedDocument = updatedDocument;
|
|
292
|
-
},
|
|
293
|
-
SET_SELECTED_PAGES: (state, selectedPages) => {
|
|
294
|
-
state.selectedPages = selectedPages;
|
|
295
|
-
},
|
|
296
|
-
ADD_SELECTED_PAGE: (state, selectedPage) => {
|
|
297
|
-
state.selectedPages.push(selectedPage);
|
|
298
|
-
},
|
|
299
|
-
SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
|
|
300
|
-
state.showEditConfirmationModal = value;
|
|
301
|
-
},
|
|
302
|
-
SET_SUBMIT_EDIT_CHANGES: (state, value) => {
|
|
303
|
-
state.submitEditChanges = value;
|
|
304
|
-
},
|
|
305
|
-
SET_REDIRECTING_USER: (state, value) => {
|
|
306
|
-
state.redirectingUser = value;
|
|
307
|
-
},
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
export default {
|
|
311
|
-
namespaced: true,
|
|
312
|
-
state,
|
|
313
|
-
actions,
|
|
314
|
-
mutations,
|
|
315
|
-
getters,
|
|
316
|
-
};
|
|
1
|
+
import myImports from "../api";
|
|
2
|
+
import {
|
|
3
|
+
getURLQueryParam,
|
|
4
|
+
navigateToNewDocumentURL,
|
|
5
|
+
getURLPath,
|
|
6
|
+
} from "../utils/utils";
|
|
7
|
+
|
|
8
|
+
const HTTP = myImports.HTTP;
|
|
9
|
+
|
|
10
|
+
const state = {
|
|
11
|
+
editMode: false,
|
|
12
|
+
renameAndCategorize: false,
|
|
13
|
+
isMultipleSelection: true,
|
|
14
|
+
pagesForPostprocess: [],
|
|
15
|
+
selectedPages: [],
|
|
16
|
+
updatedDocument: [],
|
|
17
|
+
showEditConfirmationModal: false,
|
|
18
|
+
submitEditChanges: false,
|
|
19
|
+
redirectingUser: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getters = {
|
|
23
|
+
isEditModeAvailable: (state, getters, rootState, rootGetters) => {
|
|
24
|
+
return (
|
|
25
|
+
!rootState.document.publicView &&
|
|
26
|
+
!rootGetters["document/isDocumentReviewed"] &&
|
|
27
|
+
!state.editMode
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
isPageSelected: (state) => (id) => {
|
|
31
|
+
return state.selectedPages.find((page) => page.id === id);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
documentShouldBePostprocessed: (state, _, rootState) => {
|
|
35
|
+
const foundRotatedPage = state.pagesForPostprocess.find(
|
|
36
|
+
(page) => page.angle !== 0
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
let foundReorderedPage = false;
|
|
40
|
+
|
|
41
|
+
state.pagesForPostprocess.map((page, index) => {
|
|
42
|
+
if (
|
|
43
|
+
(page.id === rootState.document.selectedDocument.pages[index].id &&
|
|
44
|
+
page.number !==
|
|
45
|
+
rootState.document.selectedDocument.pages[index].number) ||
|
|
46
|
+
(page.id !== rootState.document.selectedDocument.pages[index].id &&
|
|
47
|
+
page.number ===
|
|
48
|
+
rootState.document.selectedDocument.pages[index].number)
|
|
49
|
+
) {
|
|
50
|
+
foundReorderedPage = true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
state.updatedDocument.length > 1 || foundRotatedPage || foundReorderedPage
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const actions = {
|
|
61
|
+
enableEditMode: ({ commit }) => {
|
|
62
|
+
commit("SET_EDIT_MODE", true);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
disableEditMode: ({ commit }) => {
|
|
66
|
+
commit("SET_EDIT_MODE", false);
|
|
67
|
+
commit("SET_RENAME_AND_CATEGORIZE", false);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
setRenameAndCategorize: ({ commit }, value) => {
|
|
71
|
+
commit("SET_RENAME_AND_CATEGORIZE", value);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
setPagesForPostprocess: ({ commit }, pages) => {
|
|
75
|
+
commit("SET_PAGES_FOR_POSTPROCESS", pages);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
setUpdatedDocument: ({ commit }, updatedDocument) => {
|
|
79
|
+
commit("SET_UPDATED_DOCUMENT", updatedDocument);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
setSubmitEditChanges: ({ commit }, value) => {
|
|
83
|
+
commit("SET_SUBMIT_EDIT_CHANGES", value);
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
selectPage: ({ state, commit }, page) => {
|
|
87
|
+
if (state.isMultipleSelection) {
|
|
88
|
+
commit("ADD_SELECTED_PAGE", page);
|
|
89
|
+
} else {
|
|
90
|
+
commit("SET_SELECTED_PAGES", []);
|
|
91
|
+
commit("ADD_SELECTED_PAGE", page);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
unselectPage: ({ state, commit }, selectedPage) => {
|
|
96
|
+
const found = state.selectedPages.find(
|
|
97
|
+
(page) => page.id === selectedPage.id
|
|
98
|
+
);
|
|
99
|
+
if (found) {
|
|
100
|
+
const filtered = state.selectedPages.filter(
|
|
101
|
+
(page) => page.id !== selectedPage.id
|
|
102
|
+
);
|
|
103
|
+
commit("SET_SELECTED_PAGES", filtered);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
setSelectedPages: ({ state, commit }, selectedPage) => {
|
|
108
|
+
if (!selectedPage) {
|
|
109
|
+
commit("SET_SELECTED_PAGES", []);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const found = state.selectedPages.find(
|
|
114
|
+
(page) => page.id === selectedPage.id
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
if (found) {
|
|
118
|
+
const filtered = state.selectedPages.filter(
|
|
119
|
+
(page) => page.id !== selectedPage.id
|
|
120
|
+
);
|
|
121
|
+
commit("SET_SELECTED_PAGES", filtered);
|
|
122
|
+
} else if (state.isMultipleSelection) {
|
|
123
|
+
commit("ADD_SELECTED_PAGE", selectedPage);
|
|
124
|
+
} else {
|
|
125
|
+
commit("SET_SELECTED_PAGES", []);
|
|
126
|
+
commit("ADD_SELECTED_PAGE", selectedPage);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
rotatePage: ({ state, commit }, { page, direction }) => {
|
|
131
|
+
if (state.pagesForPostprocess.find((p) => p.id === page.id)) {
|
|
132
|
+
const pagesForPostprocess = state.pagesForPostprocess.map((p) => {
|
|
133
|
+
let rotatedAngle;
|
|
134
|
+
if (direction === "left") {
|
|
135
|
+
rotatedAngle = p.angle - 90;
|
|
136
|
+
if (p.id === page.id) {
|
|
137
|
+
if (rotatedAngle === -270) {
|
|
138
|
+
rotatedAngle = 90;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
...p,
|
|
142
|
+
angle: rotatedAngle,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return p;
|
|
146
|
+
}
|
|
147
|
+
if (direction === "right") {
|
|
148
|
+
rotatedAngle = p.angle + 90;
|
|
149
|
+
if (p.id === page.id) {
|
|
150
|
+
if (rotatedAngle === 270) {
|
|
151
|
+
rotatedAngle = -90;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
...p,
|
|
155
|
+
angle: rotatedAngle,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return p;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
commit("SET_PAGES_FOR_POSTPROCESS", pagesForPostprocess);
|
|
163
|
+
} else {
|
|
164
|
+
if (direction === "left") {
|
|
165
|
+
state.pagesForPostprocess.push({
|
|
166
|
+
id: page.id,
|
|
167
|
+
number: page.number,
|
|
168
|
+
angle: -90,
|
|
169
|
+
thumbnail_url: page.thumbnail_url,
|
|
170
|
+
updated_at: page.updated_at,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (direction === "right") {
|
|
175
|
+
state.pagesForPostprocess.push({
|
|
176
|
+
id: page.id,
|
|
177
|
+
number: page.number,
|
|
178
|
+
angle: 90,
|
|
179
|
+
thumbnail_url: page.thumbnail_url,
|
|
180
|
+
updated_at: page.updated_at,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
updateRotationToTheLeft: ({ state, commit }) => {
|
|
187
|
+
// updated the angles that will be sent to the backend
|
|
188
|
+
const array = state.pagesForPostprocess.map((p) => {
|
|
189
|
+
let rotatedAngle = p.angle - 90;
|
|
190
|
+
if (rotatedAngle === -270) {
|
|
191
|
+
rotatedAngle = 90;
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
...p,
|
|
195
|
+
angle: rotatedAngle,
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
updateRotationToTheRight: ({ state, commit }) => {
|
|
203
|
+
// updated the angles that will be sent to the backend
|
|
204
|
+
const array = state.pagesForPostprocess.map((p) => {
|
|
205
|
+
let rotatedAngle = p.angle + 90;
|
|
206
|
+
if (rotatedAngle === 270) {
|
|
207
|
+
rotatedAngle = -90;
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
...p,
|
|
211
|
+
angle: rotatedAngle,
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
editDocument: ({ rootState, commit, dispatch }, editedDocument) => {
|
|
219
|
+
dispatch("document/startRecalculatingAnnotations", null, {
|
|
220
|
+
root: true,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const oldId = rootState.document.documentId;
|
|
224
|
+
|
|
225
|
+
return new Promise((resolve, reject) => {
|
|
226
|
+
HTTP.post(
|
|
227
|
+
`/documents/${rootState.document.documentId}/postprocess/`,
|
|
228
|
+
editedDocument
|
|
229
|
+
)
|
|
230
|
+
.then(async (response) => {
|
|
231
|
+
if (response && response.status === 200) {
|
|
232
|
+
const newId = response.data[0].id;
|
|
233
|
+
dispatch("document/setSplittingSuggestions", null, { root: true });
|
|
234
|
+
|
|
235
|
+
commit("SET_SUBMIT_EDIT_CHANGES", false);
|
|
236
|
+
|
|
237
|
+
if (newId != oldId) {
|
|
238
|
+
if (getURLQueryParam("document") || getURLPath("docs")) {
|
|
239
|
+
navigateToNewDocumentURL(oldId, newId);
|
|
240
|
+
} else {
|
|
241
|
+
await dispatch("document/setDocId", newId, {
|
|
242
|
+
root: true,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
dispatch("document/pollDocumentEndpoint", null, {
|
|
246
|
+
root: true,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
dispatch("document/setSelectedDocument", response.data[0], {
|
|
251
|
+
root: true,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
dispatch("document/pollDocumentEndpoint", null, {
|
|
255
|
+
root: true,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
resolve(response);
|
|
260
|
+
})
|
|
261
|
+
.catch((error) => {
|
|
262
|
+
reject(error.response);
|
|
263
|
+
console.log(error);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
setShowEditConfirmationModal: ({ commit }, value) => {
|
|
269
|
+
commit("SET_SHOW_EDIT_CONFIRMATION_MODAL", value);
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
setRedirectingUser: ({ commit }, value) => {
|
|
273
|
+
commit("SET_REDIRECTING_USER", value);
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const mutations = {
|
|
278
|
+
SET_EDIT_MODE: (state, option) => {
|
|
279
|
+
state.editMode = option;
|
|
280
|
+
},
|
|
281
|
+
|
|
282
|
+
SET_RENAME_AND_CATEGORIZE: (state, value) => {
|
|
283
|
+
state.renameAndCategorize = value;
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
SET_PAGES_FOR_POSTPROCESS: (state, pages) => {
|
|
287
|
+
state.pagesForPostprocess = pages;
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
SET_UPDATED_DOCUMENT: (state, updatedDocument) => {
|
|
291
|
+
state.updatedDocument = updatedDocument;
|
|
292
|
+
},
|
|
293
|
+
SET_SELECTED_PAGES: (state, selectedPages) => {
|
|
294
|
+
state.selectedPages = selectedPages;
|
|
295
|
+
},
|
|
296
|
+
ADD_SELECTED_PAGE: (state, selectedPage) => {
|
|
297
|
+
state.selectedPages.push(selectedPage);
|
|
298
|
+
},
|
|
299
|
+
SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
|
|
300
|
+
state.showEditConfirmationModal = value;
|
|
301
|
+
},
|
|
302
|
+
SET_SUBMIT_EDIT_CHANGES: (state, value) => {
|
|
303
|
+
state.submitEditChanges = value;
|
|
304
|
+
},
|
|
305
|
+
SET_REDIRECTING_USER: (state, value) => {
|
|
306
|
+
state.redirectingUser = value;
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export default {
|
|
311
|
+
namespaced: true,
|
|
312
|
+
state,
|
|
313
|
+
actions,
|
|
314
|
+
mutations,
|
|
315
|
+
getters,
|
|
316
|
+
};
|
package/src/store/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import Vue from "vue";
|
|
2
|
-
import Vuex from "vuex";
|
|
3
|
-
|
|
4
|
-
import display from "./display";
|
|
5
|
-
import document from "./document";
|
|
6
|
-
import category from "./category";
|
|
7
|
-
import project from "./project";
|
|
8
|
-
import selection from "./selection";
|
|
9
|
-
import edit from "./edit";
|
|
10
|
-
|
|
11
|
-
Vue.use(Vuex);
|
|
12
|
-
|
|
13
|
-
export default new Vuex.Store({
|
|
14
|
-
modules: {
|
|
15
|
-
display,
|
|
16
|
-
document,
|
|
17
|
-
category,
|
|
18
|
-
project,
|
|
19
|
-
selection,
|
|
20
|
-
edit
|
|
21
|
-
}
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
import Vuex from "vuex";
|
|
3
|
+
|
|
4
|
+
import display from "./display";
|
|
5
|
+
import document from "./document";
|
|
6
|
+
import category from "./category";
|
|
7
|
+
import project from "./project";
|
|
8
|
+
import selection from "./selection";
|
|
9
|
+
import edit from "./edit";
|
|
10
|
+
|
|
11
|
+
Vue.use(Vuex);
|
|
12
|
+
|
|
13
|
+
export default new Vuex.Store({
|
|
14
|
+
modules: {
|
|
15
|
+
display,
|
|
16
|
+
document,
|
|
17
|
+
category,
|
|
18
|
+
project,
|
|
19
|
+
selection,
|
|
20
|
+
edit
|
|
21
|
+
}
|
|
22
22
|
});
|