@konfuzio/document-validation-ui 0.1.14 → 0.1.15
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/README.md +12 -0
- package/cypress.config.js +13 -0
- package/dist/css/app.css +1 -1
- package/dist/index.html +1 -1
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/dist/js/chunk-vendors.js +3 -3
- package/dist/js/chunk-vendors.js.map +1 -1
- package/package.json +5 -1
- package/src/api.js +53 -23
- package/src/assets/images/DraggableIcon.vue +14 -0
- package/src/assets/images/GridIcon.vue +16 -0
- package/src/assets/images/MagicWandIcon.vue +16 -0
- package/src/assets/images/NotFoundIcon.vue +16 -0
- package/src/assets/images/ServerImage.vue +19 -9
- package/src/assets/images/SettingsIcon.vue +14 -0
- package/src/assets/images/SplitZigZag.vue +47 -14
- package/src/assets/images/StarIcon.vue +16 -0
- package/src/assets/scss/ann_set_table_options.scss +26 -0
- package/src/assets/scss/annotation_details.scss +86 -71
- package/src/assets/scss/choose_label_set_modal.scss +1 -1
- package/src/assets/scss/document_annotations.scss +242 -229
- package/src/assets/scss/document_category.scss +12 -7
- package/src/assets/scss/document_dashboard.scss +7 -2
- package/src/assets/scss/document_edit.scss +151 -173
- package/src/assets/scss/document_name.scss +0 -2
- package/src/assets/scss/document_thumbnails.scss +1 -1
- package/src/assets/scss/document_toolbar.scss +23 -1
- package/src/assets/scss/document_top_bar.scss +40 -1
- package/src/assets/scss/edit_page_thumbnail.scss +53 -0
- package/src/assets/scss/multi_ann_table_overlay.scss +38 -0
- package/src/assets/scss/new_annotation.scss +17 -3
- package/src/assets/scss/scrolling_document.scss +1 -1
- package/src/assets/scss/theme.scss +801 -0
- package/src/assets/scss/variables.scss +5 -663
- package/src/components/App.cy.js +7 -0
- package/src/components/App.vue +98 -11
- package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +168 -0
- package/src/components/DocumentAnnotations/AnnotationContent.vue +50 -84
- package/src/components/DocumentAnnotations/AnnotationDetails.vue +37 -12
- package/src/components/DocumentAnnotations/AnnotationRow.vue +244 -199
- package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -0
- package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +4 -2
- package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +295 -0
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +195 -146
- package/src/components/DocumentAnnotations/DocumentLabel.vue +46 -9
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +59 -88
- package/src/components/DocumentAnnotations/ExtractingData.vue +18 -6
- package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +337 -0
- package/src/components/DocumentAnnotations/index.js +1 -1
- package/src/components/DocumentCategory.vue +89 -65
- package/src/components/DocumentDashboard.vue +59 -48
- package/src/components/DocumentEdit/DocumentEdit.vue +302 -105
- package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -0
- package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -0
- package/src/components/DocumentEdit/EditPages.vue +60 -103
- package/src/components/DocumentEdit/EditSidebar.vue +101 -48
- package/src/components/DocumentEdit/{SplitOverview.vue → RenameAndCategorize.vue} +15 -13
- package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
- package/src/components/DocumentEdit/SplitInfoBar.vue +21 -0
- package/src/components/DocumentEdit/index.js +1 -1
- package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +9 -8
- package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
- package/src/components/DocumentPage/ActionBar.vue +3 -3
- package/src/components/DocumentPage/AnnSetTableOptions.vue +110 -0
- package/src/components/DocumentPage/BoxSelection.vue +4 -1
- package/src/components/DocumentPage/DocumentPage.vue +92 -68
- package/src/components/DocumentPage/DocumentToolbar.vue +105 -16
- package/src/components/DocumentPage/DummyPage.vue +9 -7
- package/src/components/DocumentPage/MultiAnnSelection.vue +96 -27
- package/src/components/DocumentPage/NewAnnotation.vue +31 -35
- package/src/components/DocumentPage/ScrollingDocument.vue +46 -5
- package/src/components/DocumentPage/ScrollingPage.vue +5 -6
- package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +64 -0
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +53 -13
- package/src/components/DocumentTopBar/DocumentName.vue +16 -4
- package/src/components/DocumentTopBar/DocumentTopBar.vue +86 -15
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +99 -72
- package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +6 -3
- package/src/components/DocumentsList/DocumentsList.vue +6 -2
- package/src/components/index.js +1 -0
- package/src/constants.js +2 -1
- package/src/icons.js +45 -0
- package/src/locales/de.json +48 -21
- package/src/locales/en.json +37 -11
- package/src/locales/es.json +41 -13
- package/src/main.js +5 -66
- package/src/store/category.js +20 -36
- package/src/store/display.js +74 -1
- package/src/store/document.js +305 -109
- package/src/store/edit.js +160 -61
- package/src/store/project.js +46 -16
- package/src/store/selection.js +42 -10
- package/src/utils/utils.js +36 -0
- package/dist/css/chunk-vendors.css +0 -5
- package/src/assets/scss/categorize_modal.scss +0 -45
- package/src/assets/scss/main.scss +0 -24
- package/src/components/DocumentAnnotations/ActionButtons.vue +0 -250
- package/src/components/DocumentAnnotations/CategorizeModal.vue +0 -219
- package/src/components/DocumentAnnotations/RejectedLabels.vue +0 -96
- package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +0 -253
package/src/store/edit.js
CHANGED
|
@@ -1,14 +1,53 @@
|
|
|
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
|
|
|
5
10
|
const state = {
|
|
6
11
|
editMode: false,
|
|
7
|
-
|
|
8
|
-
isMultipleSelection:
|
|
9
|
-
|
|
12
|
+
renameAndCategorize: false,
|
|
13
|
+
isMultipleSelection: true,
|
|
14
|
+
pagesForPostprocess: [],
|
|
10
15
|
selectedPages: [],
|
|
11
16
|
updatedDocument: [],
|
|
17
|
+
showEditConfirmationModal: false,
|
|
18
|
+
submitEditChanges: false,
|
|
19
|
+
redirectingUser: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getters = {
|
|
23
|
+
isPageSelected: (state) => (id) => {
|
|
24
|
+
return state.selectedPages.find((page) => page.id === id);
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
documentShouldBePostprocessed: (state, _, rootState) => {
|
|
28
|
+
const foundRotatedPage = state.pagesForPostprocess.find(
|
|
29
|
+
(page) => page.angle !== 0
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
let foundReorderedPage = false;
|
|
33
|
+
|
|
34
|
+
state.pagesForPostprocess.map((page, index) => {
|
|
35
|
+
if (
|
|
36
|
+
(page.id === rootState.document.selectedDocument.pages[index].id &&
|
|
37
|
+
page.number !==
|
|
38
|
+
rootState.document.selectedDocument.pages[index].number) ||
|
|
39
|
+
(page.id !== rootState.document.selectedDocument.pages[index].id &&
|
|
40
|
+
page.number ===
|
|
41
|
+
rootState.document.selectedDocument.pages[index].number)
|
|
42
|
+
) {
|
|
43
|
+
foundReorderedPage = true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
state.updatedDocument.length > 1 || foundRotatedPage || foundReorderedPage
|
|
49
|
+
);
|
|
50
|
+
},
|
|
12
51
|
};
|
|
13
52
|
|
|
14
53
|
const actions = {
|
|
@@ -18,21 +57,46 @@ const actions = {
|
|
|
18
57
|
|
|
19
58
|
disableEditMode: ({ commit }) => {
|
|
20
59
|
commit("SET_EDIT_MODE", false);
|
|
21
|
-
commit("
|
|
60
|
+
commit("SET_RENAME_AND_CATEGORIZE", false);
|
|
22
61
|
},
|
|
23
62
|
|
|
24
|
-
|
|
25
|
-
commit("
|
|
63
|
+
setRenameAndCategorize: ({ commit }, value) => {
|
|
64
|
+
commit("SET_RENAME_AND_CATEGORIZE", value);
|
|
26
65
|
},
|
|
27
66
|
|
|
28
|
-
|
|
29
|
-
commit("
|
|
67
|
+
setPagesForPostprocess: ({ commit }, pages) => {
|
|
68
|
+
commit("SET_PAGES_FOR_POSTPROCESS", pages);
|
|
30
69
|
},
|
|
31
70
|
|
|
32
71
|
setUpdatedDocument: ({ commit }, updatedDocument) => {
|
|
33
72
|
commit("SET_UPDATED_DOCUMENT", updatedDocument);
|
|
34
73
|
},
|
|
35
74
|
|
|
75
|
+
setSubmitEditChanges: ({ commit }, value) => {
|
|
76
|
+
commit("SET_SUBMIT_EDIT_CHANGES", value);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
selectPage: ({ state, commit }, page) => {
|
|
80
|
+
if (state.isMultipleSelection) {
|
|
81
|
+
commit("ADD_SELECTED_PAGE", page);
|
|
82
|
+
} else {
|
|
83
|
+
commit("SET_SELECTED_PAGES", []);
|
|
84
|
+
commit("ADD_SELECTED_PAGE", page);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
unselectPage: ({ state, commit }, selectedPage) => {
|
|
89
|
+
const found = state.selectedPages.find(
|
|
90
|
+
(page) => page.id === selectedPage.id
|
|
91
|
+
);
|
|
92
|
+
if (found) {
|
|
93
|
+
const filtered = state.selectedPages.filter(
|
|
94
|
+
(page) => page.id !== selectedPage.id
|
|
95
|
+
);
|
|
96
|
+
commit("SET_SELECTED_PAGES", filtered);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
|
|
36
100
|
setSelectedPages: ({ state, commit }, selectedPage) => {
|
|
37
101
|
if (!selectedPage) {
|
|
38
102
|
commit("SET_SELECTED_PAGES", []);
|
|
@@ -57,42 +121,41 @@ const actions = {
|
|
|
57
121
|
},
|
|
58
122
|
|
|
59
123
|
rotatePage: ({ state, commit }, { page, direction }) => {
|
|
60
|
-
if (state.
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
rotatedAngle = 90;
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
...p,
|
|
72
|
-
angle: rotatedAngle,
|
|
73
|
-
};
|
|
124
|
+
if (state.pagesForPostprocess.find((p) => p.id === page.id)) {
|
|
125
|
+
const pagesForPostprocess = state.pagesForPostprocess.map((p) => {
|
|
126
|
+
let rotatedAngle;
|
|
127
|
+
if (direction === "left") {
|
|
128
|
+
rotatedAngle = p.angle - 90;
|
|
129
|
+
if (p.id === page.id) {
|
|
130
|
+
if (rotatedAngle === -270) {
|
|
131
|
+
rotatedAngle = 90;
|
|
74
132
|
}
|
|
75
|
-
return
|
|
133
|
+
return {
|
|
134
|
+
...p,
|
|
135
|
+
angle: rotatedAngle,
|
|
136
|
+
};
|
|
76
137
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
...p,
|
|
85
|
-
angle: rotatedAngle,
|
|
86
|
-
};
|
|
138
|
+
return p;
|
|
139
|
+
}
|
|
140
|
+
if (direction === "right") {
|
|
141
|
+
rotatedAngle = p.angle + 90;
|
|
142
|
+
if (p.id === page.id) {
|
|
143
|
+
if (rotatedAngle === 270) {
|
|
144
|
+
rotatedAngle = -90;
|
|
87
145
|
}
|
|
88
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
...p,
|
|
148
|
+
angle: rotatedAngle,
|
|
149
|
+
};
|
|
89
150
|
}
|
|
90
|
-
|
|
151
|
+
return p;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
91
154
|
|
|
92
|
-
commit("
|
|
155
|
+
commit("SET_PAGES_FOR_POSTPROCESS", pagesForPostprocess);
|
|
93
156
|
} else {
|
|
94
157
|
if (direction === "left") {
|
|
95
|
-
state.
|
|
158
|
+
state.pagesForPostprocess.push({
|
|
96
159
|
id: page.id,
|
|
97
160
|
number: page.number,
|
|
98
161
|
angle: -90,
|
|
@@ -102,7 +165,7 @@ const actions = {
|
|
|
102
165
|
}
|
|
103
166
|
|
|
104
167
|
if (direction === "right") {
|
|
105
|
-
state.
|
|
168
|
+
state.pagesForPostprocess.push({
|
|
106
169
|
id: page.id,
|
|
107
170
|
number: page.number,
|
|
108
171
|
angle: 90,
|
|
@@ -115,7 +178,7 @@ const actions = {
|
|
|
115
178
|
|
|
116
179
|
updateRotationToTheLeft: ({ state, commit }) => {
|
|
117
180
|
// updated the angles that will be sent to the backend
|
|
118
|
-
const array = state.
|
|
181
|
+
const array = state.pagesForPostprocess.map((p) => {
|
|
119
182
|
let rotatedAngle = p.angle - 90;
|
|
120
183
|
if (rotatedAngle === -270) {
|
|
121
184
|
rotatedAngle = 90;
|
|
@@ -126,12 +189,12 @@ const actions = {
|
|
|
126
189
|
};
|
|
127
190
|
});
|
|
128
191
|
|
|
129
|
-
commit("
|
|
192
|
+
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
130
193
|
},
|
|
131
194
|
|
|
132
195
|
updateRotationToTheRight: ({ state, commit }) => {
|
|
133
196
|
// updated the angles that will be sent to the backend
|
|
134
|
-
const array = state.
|
|
197
|
+
const array = state.pagesForPostprocess.map((p) => {
|
|
135
198
|
let rotatedAngle = p.angle + 90;
|
|
136
199
|
if (rotatedAngle === 270) {
|
|
137
200
|
rotatedAngle = -90;
|
|
@@ -142,40 +205,66 @@ const actions = {
|
|
|
142
205
|
};
|
|
143
206
|
});
|
|
144
207
|
|
|
145
|
-
commit("
|
|
208
|
+
commit("SET_PAGES_FOR_POSTPROCESS", array);
|
|
146
209
|
},
|
|
147
210
|
|
|
148
|
-
editDocument: ({ rootState, dispatch }, editedDocument) => {
|
|
211
|
+
editDocument: ({ rootState, commit, dispatch }, editedDocument) => {
|
|
149
212
|
dispatch("document/startRecalculatingAnnotations", null, {
|
|
150
213
|
root: true,
|
|
151
214
|
});
|
|
152
|
-
|
|
215
|
+
|
|
216
|
+
const oldId = rootState.document.documentId;
|
|
217
|
+
|
|
218
|
+
return new Promise((resolve, reject) => {
|
|
153
219
|
HTTP.post(
|
|
154
220
|
`/documents/${rootState.document.documentId}/postprocess/`,
|
|
155
221
|
editedDocument
|
|
156
222
|
)
|
|
157
223
|
.then(async (response) => {
|
|
158
224
|
if (response && response.status === 200) {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
225
|
+
const newId = response.data[0].id;
|
|
226
|
+
dispatch("document/setSplittingSuggestions", null, { root: true });
|
|
227
|
+
|
|
228
|
+
commit("SET_SUBMIT_EDIT_CHANGES", false);
|
|
229
|
+
|
|
230
|
+
if (newId != oldId) {
|
|
231
|
+
if (getURLQueryParam("document") || getURLPath("docs")) {
|
|
232
|
+
navigateToNewDocumentURL(oldId, newId);
|
|
233
|
+
} else {
|
|
234
|
+
await dispatch("document/setDocId", newId, {
|
|
235
|
+
root: true,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
dispatch("document/pollDocumentEndpoint", null, {
|
|
239
|
+
root: true,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
dispatch("document/setSelectedDocument", response.data[0], {
|
|
244
|
+
root: true,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
dispatch("document/pollDocumentEndpoint", null, {
|
|
248
|
+
root: true,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
171
251
|
}
|
|
252
|
+
resolve(response);
|
|
172
253
|
})
|
|
173
254
|
.catch((error) => {
|
|
174
|
-
|
|
255
|
+
reject(error.response);
|
|
175
256
|
console.log(error);
|
|
176
257
|
});
|
|
177
258
|
});
|
|
178
259
|
},
|
|
260
|
+
|
|
261
|
+
setShowEditConfirmationModal: ({ commit }, value) => {
|
|
262
|
+
commit("SET_SHOW_EDIT_CONFIRMATION_MODAL", value);
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
setRedirectingUser: ({ commit }, value) => {
|
|
266
|
+
commit("SET_REDIRECTING_USER", value);
|
|
267
|
+
},
|
|
179
268
|
};
|
|
180
269
|
|
|
181
270
|
const mutations = {
|
|
@@ -183,12 +272,12 @@ const mutations = {
|
|
|
183
272
|
state.editMode = option;
|
|
184
273
|
},
|
|
185
274
|
|
|
186
|
-
|
|
187
|
-
state.
|
|
275
|
+
SET_RENAME_AND_CATEGORIZE: (state, value) => {
|
|
276
|
+
state.renameAndCategorize = value;
|
|
188
277
|
},
|
|
189
278
|
|
|
190
|
-
|
|
191
|
-
state.
|
|
279
|
+
SET_PAGES_FOR_POSTPROCESS: (state, pages) => {
|
|
280
|
+
state.pagesForPostprocess = pages;
|
|
192
281
|
},
|
|
193
282
|
|
|
194
283
|
SET_UPDATED_DOCUMENT: (state, updatedDocument) => {
|
|
@@ -200,6 +289,15 @@ const mutations = {
|
|
|
200
289
|
ADD_SELECTED_PAGE: (state, selectedPage) => {
|
|
201
290
|
state.selectedPages.push(selectedPage);
|
|
202
291
|
},
|
|
292
|
+
SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
|
|
293
|
+
state.showEditConfirmationModal = value;
|
|
294
|
+
},
|
|
295
|
+
SET_SUBMIT_EDIT_CHANGES: (state, value) => {
|
|
296
|
+
state.submitEditChanges = value;
|
|
297
|
+
},
|
|
298
|
+
SET_REDIRECTING_USER: (state, value) => {
|
|
299
|
+
state.redirectingUser = value;
|
|
300
|
+
},
|
|
203
301
|
};
|
|
204
302
|
|
|
205
303
|
export default {
|
|
@@ -207,4 +305,5 @@ export default {
|
|
|
207
305
|
state,
|
|
208
306
|
actions,
|
|
209
307
|
mutations,
|
|
308
|
+
getters,
|
|
210
309
|
};
|
package/src/store/project.js
CHANGED
|
@@ -2,8 +2,10 @@ import myImports from "../api";
|
|
|
2
2
|
const HTTP = myImports.HTTP;
|
|
3
3
|
|
|
4
4
|
const state = {
|
|
5
|
-
projectId:
|
|
6
|
-
currentUser: null
|
|
5
|
+
projectId: process.env.VUE_APP_PROJECT_ID,
|
|
6
|
+
currentUser: null,
|
|
7
|
+
documentsListPath: null,
|
|
8
|
+
documentsInProject: null,
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
const getters = {
|
|
@@ -11,13 +13,13 @@ const getters = {
|
|
|
11
13
|
* Gets label sets for an annotation set creation
|
|
12
14
|
*/
|
|
13
15
|
labelSetsFilteredForAnnotationSetCreation:
|
|
14
|
-
state => (labelsSet, annotationSets) => {
|
|
16
|
+
(state) => (labelsSet, annotationSets) => {
|
|
15
17
|
let returnLabels = [];
|
|
16
18
|
if (labelsSet) {
|
|
17
|
-
returnLabels = labelsSet.filter(labelSet => {
|
|
19
|
+
returnLabels = labelsSet.filter((labelSet) => {
|
|
18
20
|
// check if label set has multiple and if not, if there's already an annotation set created
|
|
19
21
|
if (!labelSet.has_multiple_annotation_sets) {
|
|
20
|
-
const existingAnnotationSet = annotationSets.find(annSet => {
|
|
22
|
+
const existingAnnotationSet = annotationSets.find((annSet) => {
|
|
21
23
|
return annSet.id === labelSet.id;
|
|
22
24
|
});
|
|
23
25
|
return existingAnnotationSet;
|
|
@@ -27,7 +29,7 @@ const getters = {
|
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
return returnLabels;
|
|
30
|
-
}
|
|
32
|
+
},
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
const actions = {
|
|
@@ -38,10 +40,10 @@ const actions = {
|
|
|
38
40
|
fetchLabelSetDetails: ({ commit, state }, labelSetId) => {
|
|
39
41
|
return new Promise((resolve, reject) => {
|
|
40
42
|
HTTP.get(`label-sets/${labelSetId}/`)
|
|
41
|
-
.then(response => {
|
|
43
|
+
.then((response) => {
|
|
42
44
|
return resolve(response.data);
|
|
43
45
|
})
|
|
44
|
-
.catch(error => {
|
|
46
|
+
.catch((error) => {
|
|
45
47
|
reject(error);
|
|
46
48
|
console.log(error);
|
|
47
49
|
});
|
|
@@ -52,10 +54,10 @@ const actions = {
|
|
|
52
54
|
fetchLabelSets: ({ state }) => {
|
|
53
55
|
return new Promise((resolve, reject) => {
|
|
54
56
|
HTTP.get(`label-sets/?project=${state.projectId}`)
|
|
55
|
-
.then(response => {
|
|
57
|
+
.then((response) => {
|
|
56
58
|
return resolve(response.data.results);
|
|
57
59
|
})
|
|
58
|
-
.catch(error => {
|
|
60
|
+
.catch((error) => {
|
|
59
61
|
reject(error);
|
|
60
62
|
console.log(error);
|
|
61
63
|
});
|
|
@@ -64,17 +66,39 @@ const actions = {
|
|
|
64
66
|
|
|
65
67
|
fetchCurrentUser: ({ commit }) => {
|
|
66
68
|
return HTTP.get(`/auth/me/`)
|
|
67
|
-
.then(response => {
|
|
68
|
-
commit("SET_CURRENT_USER", response.data
|
|
69
|
+
.then((response) => {
|
|
70
|
+
commit("SET_CURRENT_USER", response.data);
|
|
69
71
|
})
|
|
70
|
-
.catch(error => {
|
|
72
|
+
.catch((error) => {
|
|
71
73
|
console.log(error);
|
|
72
74
|
});
|
|
73
75
|
},
|
|
74
76
|
|
|
75
77
|
setCurrentUser: ({ commit }, currentUser) => {
|
|
76
78
|
commit("SET_CURRENT_USER", currentUser);
|
|
77
|
-
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
setDocumentsListPath: ({ commit }, path) => {
|
|
82
|
+
commit("SET_DOCUMENTS_LIST_PATH", path);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
setDocumentsInProject: ({ commit }, documents) => {
|
|
86
|
+
commit("SET_DOCUMENTS_IN_PROJECT", documents);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
fetchDocumentList: ({ commit, state }, parameters) => {
|
|
90
|
+
return HTTP.get(
|
|
91
|
+
`documents/?project=${state.projectId}&assignee=${state.currentUser.username}&limit=100&${parameters}`
|
|
92
|
+
)
|
|
93
|
+
.then((response) => {
|
|
94
|
+
if (response.data.results) {
|
|
95
|
+
commit("SET_DOCUMENTS_IN_PROJECT", response.data.results);
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
.catch((error) => {
|
|
99
|
+
console.log(error, "Could not fetch document list from the backend");
|
|
100
|
+
});
|
|
101
|
+
},
|
|
78
102
|
};
|
|
79
103
|
|
|
80
104
|
const mutations = {
|
|
@@ -83,7 +107,13 @@ const mutations = {
|
|
|
83
107
|
},
|
|
84
108
|
SET_CURRENT_USER: (state, currentUser) => {
|
|
85
109
|
state.currentUser = currentUser;
|
|
86
|
-
}
|
|
110
|
+
},
|
|
111
|
+
SET_DOCUMENTS_LIST_PATH: (state, path) => {
|
|
112
|
+
state.documentsListPath = path;
|
|
113
|
+
},
|
|
114
|
+
SET_DOCUMENTS_IN_PROJECT: (state, documents) => {
|
|
115
|
+
state.documentsInProject = documents;
|
|
116
|
+
},
|
|
87
117
|
};
|
|
88
118
|
|
|
89
119
|
export default {
|
|
@@ -91,5 +121,5 @@ export default {
|
|
|
91
121
|
state,
|
|
92
122
|
actions,
|
|
93
123
|
mutations,
|
|
94
|
-
getters
|
|
124
|
+
getters,
|
|
95
125
|
};
|
package/src/store/selection.js
CHANGED
|
@@ -14,6 +14,7 @@ const state = {
|
|
|
14
14
|
isSelecting: false,
|
|
15
15
|
spanSelection: null,
|
|
16
16
|
elementSelected: null, // selected element id
|
|
17
|
+
selectedEntities: null,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
const getters = {
|
|
@@ -37,9 +38,6 @@ const getters = {
|
|
|
37
38
|
}
|
|
38
39
|
return null;
|
|
39
40
|
},
|
|
40
|
-
isValueArray: () => (value) => {
|
|
41
|
-
return Array.isArray(value);
|
|
42
|
-
},
|
|
43
41
|
};
|
|
44
42
|
|
|
45
43
|
const actions = {
|
|
@@ -70,15 +68,22 @@ const actions = {
|
|
|
70
68
|
commit("MOVE_SELECTION", points);
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
commit("SET_SELECTED_ENTITIES", null);
|
|
74
72
|
},
|
|
75
73
|
|
|
76
74
|
endSelection: ({ commit, state }, end) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
let xDiff;
|
|
76
|
+
let yDiff;
|
|
77
|
+
|
|
78
|
+
if (end) {
|
|
79
|
+
xDiff = Math.abs(state.selection.start.x - end.x);
|
|
80
|
+
yDiff = Math.abs(state.selection.start.y - end.y);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// if "end" is not provided, start and end points are the same, or if we have a selection smaller than 5x5,
|
|
80
84
|
// just reset
|
|
81
85
|
if (
|
|
86
|
+
!end ||
|
|
82
87
|
(yDiff <= 5 && xDiff <= 5) ||
|
|
83
88
|
(state.selection.start.x === end.x && state.selection.start.y == end.y)
|
|
84
89
|
) {
|
|
@@ -99,9 +104,23 @@ const actions = {
|
|
|
99
104
|
commit("SET_SPAN_SELECTION", span);
|
|
100
105
|
},
|
|
101
106
|
|
|
102
|
-
|
|
107
|
+
setSelectedEntities: ({ commit }, entities) => {
|
|
108
|
+
commit("SET_SELECTED_ENTITIES", entities);
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
getTextFromBboxes: ({ commit, rootState }, { box, entities }) => {
|
|
112
|
+
let span;
|
|
113
|
+
|
|
114
|
+
if (entities) {
|
|
115
|
+
span = box.flatMap((s) => {
|
|
116
|
+
return s.original;
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
span = [box];
|
|
120
|
+
}
|
|
121
|
+
|
|
103
122
|
return HTTP.post(`documents/${rootState.document.documentId}/bbox/`, {
|
|
104
|
-
span
|
|
123
|
+
span,
|
|
105
124
|
})
|
|
106
125
|
.then((response) => {
|
|
107
126
|
if (response.data.span.length && response.data.span.length > 0) {
|
|
@@ -119,13 +138,23 @@ const actions = {
|
|
|
119
138
|
* an annotation on this empty area, adding the offset_string
|
|
120
139
|
* attribute, ready to be filled.
|
|
121
140
|
*/
|
|
122
|
-
commit("SET_SPAN_SELECTION",
|
|
141
|
+
commit("SET_SPAN_SELECTION", span);
|
|
123
142
|
}
|
|
124
143
|
})
|
|
125
144
|
.catch((error) => {
|
|
126
145
|
alert("Could not fetch the selected text from the backend");
|
|
127
146
|
});
|
|
128
147
|
},
|
|
148
|
+
|
|
149
|
+
getTextFromEntities: ({ commit, dispatch }, selectedEntities) => {
|
|
150
|
+
if (!selectedEntities) return;
|
|
151
|
+
|
|
152
|
+
return dispatch("getTextFromBboxes", {
|
|
153
|
+
box: selectedEntities,
|
|
154
|
+
entities: true,
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
|
|
129
158
|
setSpanSelection: ({ commit }, span) => {
|
|
130
159
|
commit("SET_SPAN_SELECTION", span);
|
|
131
160
|
},
|
|
@@ -167,6 +196,9 @@ const mutations = {
|
|
|
167
196
|
SET_SELECTION: (state, selection) => {
|
|
168
197
|
state.selection = selection;
|
|
169
198
|
},
|
|
199
|
+
SET_SELECTED_ENTITIES: (state, entities) => {
|
|
200
|
+
state.selectedEntities = entities;
|
|
201
|
+
},
|
|
170
202
|
};
|
|
171
203
|
|
|
172
204
|
export default {
|
package/src/utils/utils.js
CHANGED
|
@@ -5,14 +5,50 @@ export function sleep(duration) {
|
|
|
5
5
|
export function getURLQueryParam(param) {
|
|
6
6
|
const queryString = window.location.search;
|
|
7
7
|
const urlParams = new URLSearchParams(queryString);
|
|
8
|
+
|
|
8
9
|
if (urlParams.has(param)) {
|
|
9
10
|
return urlParams.get(param);
|
|
10
11
|
}
|
|
11
12
|
return undefined;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
export function getURLPath(value) {
|
|
16
|
+
const path = window.location.pathname;
|
|
17
|
+
|
|
18
|
+
if (!path.includes(`/${value}/`)) return;
|
|
19
|
+
|
|
20
|
+
const id = path.split(value)[1].split("/")[1];
|
|
21
|
+
|
|
22
|
+
if (id === "") return;
|
|
23
|
+
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
|
|
14
27
|
export function navigateToNewDocumentURL(oldId, newId) {
|
|
15
28
|
const url = window.location.href;
|
|
16
29
|
const newUrl = url.replace(oldId, newId);
|
|
17
30
|
window.location.replace(newUrl);
|
|
18
31
|
}
|
|
32
|
+
|
|
33
|
+
export function navigateToDocumentsList(path, projectId, userId) {
|
|
34
|
+
if (!path) return;
|
|
35
|
+
|
|
36
|
+
const lastCharOfString = path.charAt(path.length - 1);
|
|
37
|
+
let slash = "/";
|
|
38
|
+
|
|
39
|
+
if (lastCharOfString === slash) {
|
|
40
|
+
slash = "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const parameters = `?project=${projectId}&is_reviewed__exact=0&assignee__id__exact=${userId}`;
|
|
44
|
+
|
|
45
|
+
const newPath = `${path}${slash}${parameters}`;
|
|
46
|
+
|
|
47
|
+
window.location.href = newPath;
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function isElementArray(element) {
|
|
53
|
+
return Array.isArray(element);
|
|
54
|
+
}
|