@konfuzio/document-validation-ui 0.1.5 → 0.1.6-multi-ann-set
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/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/package.json +1 -1
- package/src/.DS_Store +0 -0
- 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/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 +85 -73
- package/src/assets/scss/document_annotations.scss +54 -57
- package/src/assets/scss/document_category.scss +0 -1
- package/src/assets/scss/document_dashboard.scss +7 -2
- package/src/assets/scss/document_edit.scss +90 -46
- package/src/assets/scss/main.scss +725 -7
- package/src/assets/scss/multi_ann_table_overlay.scss +44 -0
- package/src/assets/scss/splitting_confirmation_modal.scss +41 -0
- package/src/assets/scss/variables.scss +2 -657
- package/src/components/App.vue +3 -2
- package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +153 -0
- package/src/components/DocumentAnnotations/AnnotationDetails.vue +28 -7
- package/src/components/DocumentAnnotations/AnnotationRow.vue +131 -40
- package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +86 -0
- package/src/components/DocumentAnnotations/CategorizeModal.vue +24 -2
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +114 -82
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +16 -3
- package/src/components/DocumentAnnotations/ExtractingData.vue +3 -3
- package/src/components/DocumentAnnotations/index.js +0 -1
- package/src/components/DocumentCategory.vue +13 -5
- package/src/components/DocumentDashboard.vue +17 -6
- package/src/components/DocumentEdit/DocumentEdit.vue +208 -68
- package/src/components/DocumentEdit/EditConfirmationModal.vue +54 -0
- package/src/components/DocumentEdit/EditPages.vue +29 -18
- package/src/components/DocumentEdit/EditSidebar.vue +92 -45
- package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
- package/src/components/DocumentEdit/SplitInfoBar.vue +19 -0
- package/src/components/DocumentEdit/SplitOverview.vue +4 -5
- package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +3 -4
- package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
- package/src/components/DocumentModals/SplittingSuggestionsModal.vue +120 -0
- package/src/components/DocumentPage/ActionBar.vue +3 -3
- package/src/components/DocumentPage/AnnSetTableOptions.vue +107 -0
- package/src/components/DocumentPage/DocumentPage.vue +12 -2
- package/src/components/DocumentPage/MultiAnnSelection.vue +89 -1
- package/src/components/DocumentPage/MultiAnnotationTableOverlay.vue +274 -0
- package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +19 -46
- package/src/components/DocumentPage/ScrollingDocument.vue +43 -4
- package/src/components/DocumentPage/ScrollingPage.vue +4 -5
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +14 -11
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +35 -30
- package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +3 -1
- package/src/locales/de.json +23 -6
- package/src/locales/en.json +24 -6
- package/src/locales/es.json +23 -6
- package/src/store/display.js +51 -0
- package/src/store/document.js +171 -23
- package/src/store/edit.js +67 -48
- package/src/store/project.js +14 -14
- package/src/components/DocumentAnnotations/ActionButtons.vue +0 -257
- package/src/components/DocumentAnnotations/RejectedLabels.vue +0 -96
package/src/store/document.js
CHANGED
|
@@ -3,6 +3,7 @@ import { sleep } from "../utils/utils";
|
|
|
3
3
|
|
|
4
4
|
const HTTP = myImports.HTTP;
|
|
5
5
|
const documentPollDuration = 1000;
|
|
6
|
+
export const table_reference_api = "api.v3.dvui.table";
|
|
6
7
|
|
|
7
8
|
const state = {
|
|
8
9
|
loading: true,
|
|
@@ -21,13 +22,14 @@ const state = {
|
|
|
21
22
|
showActionError: false,
|
|
22
23
|
errorMessage: null,
|
|
23
24
|
showDocumentError: false,
|
|
24
|
-
|
|
25
|
+
annotationsMarkedAsMissing: null,
|
|
25
26
|
errorMessageWidth: null,
|
|
26
27
|
hoveredAnnotationSet: null,
|
|
27
28
|
finishedReview: false,
|
|
28
29
|
newAcceptedAnnotations: null,
|
|
29
30
|
selectedEntities: null,
|
|
30
31
|
serverError: false,
|
|
32
|
+
splittingSuggestions: null,
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
const getters = {
|
|
@@ -157,6 +159,78 @@ const getters = {
|
|
|
157
159
|
return state.annotationSets.find((annSet) => annSet.id === annotationSetId);
|
|
158
160
|
},
|
|
159
161
|
|
|
162
|
+
/* Get annotation sets created in table */
|
|
163
|
+
annotationSetsInTable: (state) => () => {
|
|
164
|
+
const annotationSetsList = {};
|
|
165
|
+
state.annotationSets.forEach((annotationSet) => {
|
|
166
|
+
let addAnnotationSet = false;
|
|
167
|
+
if (annotationSet.labels) {
|
|
168
|
+
annotationSet.labels.forEach((label) => {
|
|
169
|
+
if (
|
|
170
|
+
label.annotations &&
|
|
171
|
+
label.annotations.find(
|
|
172
|
+
(annotation) =>
|
|
173
|
+
annotation.origin && annotation.origin === table_reference_api
|
|
174
|
+
)
|
|
175
|
+
) {
|
|
176
|
+
addAnnotationSet = true;
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (addAnnotationSet) {
|
|
182
|
+
// group by label set
|
|
183
|
+
if (annotationSetsList[`${annotationSet.label_set.id}`]) {
|
|
184
|
+
annotationSetsList[`${annotationSet.label_set.id}`].push(
|
|
185
|
+
annotationSet
|
|
186
|
+
);
|
|
187
|
+
} else {
|
|
188
|
+
annotationSetsList[`${annotationSet.label_set.id}`] = [annotationSet];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return annotationSetsList;
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
/* Get annotation sets without tables */
|
|
196
|
+
annotationSetsToShowInList: (state) => () => {
|
|
197
|
+
const annotationSetsList = [];
|
|
198
|
+
state.annotationSets.forEach((annotationSet) => {
|
|
199
|
+
let addAnnotationSet = true;
|
|
200
|
+
if (annotationSet.labels) {
|
|
201
|
+
annotationSet.labels.forEach((label) => {
|
|
202
|
+
if (
|
|
203
|
+
label.annotations &&
|
|
204
|
+
label.annotations.find(
|
|
205
|
+
(annotation) =>
|
|
206
|
+
annotation.origin && annotation.origin === table_reference_api
|
|
207
|
+
)
|
|
208
|
+
) {
|
|
209
|
+
addAnnotationSet = false;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (addAnnotationSet) {
|
|
215
|
+
annotationSetsList.push(annotationSet);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return annotationSetsList;
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
/* Get annotations inside a list of annotation sets */
|
|
222
|
+
annotationsInAnnotationsSets: (state) => (annotationsSets) => {
|
|
223
|
+
const annotations = [];
|
|
224
|
+
annotationsSets.forEach((annotationSet) => {
|
|
225
|
+
annotationSet.labels.forEach((label) => {
|
|
226
|
+
label.annotations.forEach((annotation) => {
|
|
227
|
+
annotations.push(annotation);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
return annotations;
|
|
232
|
+
},
|
|
233
|
+
|
|
160
234
|
/* Process annotations and extract labels and sets */
|
|
161
235
|
processAnnotationSets: (state, getters) => (annotationSets) => {
|
|
162
236
|
// group annotations for sidebar
|
|
@@ -228,6 +302,7 @@ const getters = {
|
|
|
228
302
|
});
|
|
229
303
|
return found ? `${value + 1}` : "";
|
|
230
304
|
}
|
|
305
|
+
return "";
|
|
231
306
|
},
|
|
232
307
|
|
|
233
308
|
/**
|
|
@@ -308,6 +383,27 @@ const getters = {
|
|
|
308
383
|
return pendingEmpty.length;
|
|
309
384
|
},
|
|
310
385
|
|
|
386
|
+
annotationIsNotFound: (state) => (annotationSet, label) => {
|
|
387
|
+
// Check if the combined label and label set have been marked as missing
|
|
388
|
+
// or if the document is in public mode
|
|
389
|
+
if (state.missingAnnotations.length === 0) {
|
|
390
|
+
return false;
|
|
391
|
+
} else {
|
|
392
|
+
const found = state.missingAnnotations.filter(
|
|
393
|
+
(el) =>
|
|
394
|
+
el.label === label.id &&
|
|
395
|
+
el.annotation_set === annotationSet.id &&
|
|
396
|
+
el.label_set === annotationSet.label_set.id
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
if (found.length !== 0) {
|
|
400
|
+
return true;
|
|
401
|
+
} else {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
|
|
311
407
|
// Check if document is ready to be finished
|
|
312
408
|
isDocumentReviewFinished: (state) => () => {
|
|
313
409
|
// check if all annotations have been revised
|
|
@@ -335,7 +431,7 @@ const getters = {
|
|
|
335
431
|
|
|
336
432
|
// if all annotations have been revised
|
|
337
433
|
// and if there are no empty annotations or
|
|
338
|
-
// all empty annotations were
|
|
434
|
+
// all empty annotations were marked as missing,
|
|
339
435
|
// we can finish the review
|
|
340
436
|
if (
|
|
341
437
|
!emptyAnnotations ||
|
|
@@ -419,6 +515,20 @@ const getters = {
|
|
|
419
515
|
}
|
|
420
516
|
},
|
|
421
517
|
|
|
518
|
+
/**
|
|
519
|
+
* If automatic splitting is enabled for the project
|
|
520
|
+
*/
|
|
521
|
+
waitingForSplittingConfirmation: () => (document) => {
|
|
522
|
+
return document && document.status_data === 41;
|
|
523
|
+
},
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Show the Smart Split switch or not
|
|
527
|
+
*/
|
|
528
|
+
documentHasProposedSplit: () => (document) => {
|
|
529
|
+
return document.proposed_split && document.proposed_split.length > 0;
|
|
530
|
+
},
|
|
531
|
+
|
|
422
532
|
/**
|
|
423
533
|
* Joins all strings in a multi-entity Annotation array
|
|
424
534
|
* to look like a single string
|
|
@@ -445,7 +555,7 @@ const getters = {
|
|
|
445
555
|
/**
|
|
446
556
|
* Check status of annotation
|
|
447
557
|
*/
|
|
448
|
-
|
|
558
|
+
notExtracted: () => (annotation) => {
|
|
449
559
|
if (annotation) {
|
|
450
560
|
return !annotation.span;
|
|
451
561
|
} else {
|
|
@@ -574,8 +684,8 @@ const actions = {
|
|
|
574
684
|
setDocumentError: ({ commit }, value) => {
|
|
575
685
|
commit("SET_DOCUMENT_ERROR", value);
|
|
576
686
|
},
|
|
577
|
-
|
|
578
|
-
commit("
|
|
687
|
+
setAnnotationsMarkedAsMissing: ({ commit }, annotations) => {
|
|
688
|
+
commit("SET_ANNOTATIONS_MARKED_AS_MISSING", annotations);
|
|
579
689
|
},
|
|
580
690
|
setErrorMessageWidth: ({ commit }, width) => {
|
|
581
691
|
commit("SET_ERROR_MESSAGE_WIDTH", width);
|
|
@@ -589,6 +699,9 @@ const actions = {
|
|
|
589
699
|
setSelectedEntities: ({ commit }, entities) => {
|
|
590
700
|
commit("SET_SELECTED_ENTITIES", entities);
|
|
591
701
|
},
|
|
702
|
+
setSplittingSuggestions: ({ commit }, value) => {
|
|
703
|
+
commit("SET_SPLITTING_SUGGESTIONS", value);
|
|
704
|
+
},
|
|
592
705
|
|
|
593
706
|
/**
|
|
594
707
|
* Actions that use HTTP requests always return the axios promise,
|
|
@@ -635,6 +748,10 @@ const actions = {
|
|
|
635
748
|
});
|
|
636
749
|
}
|
|
637
750
|
|
|
751
|
+
if (getters.documentHasProposedSplit(response.data)) {
|
|
752
|
+
commit("SET_SPLITTING_SUGGESTIONS", response.data.proposed_split);
|
|
753
|
+
}
|
|
754
|
+
|
|
638
755
|
categoryId = response.data.category;
|
|
639
756
|
// TODO: add this validation to a method
|
|
640
757
|
isRecalculatingAnnotations = response.data.labeling_available !== 1;
|
|
@@ -698,7 +815,7 @@ const actions = {
|
|
|
698
815
|
id: annotation.id,
|
|
699
816
|
span,
|
|
700
817
|
page: span.page_index + 1,
|
|
701
|
-
labelName: label.name,
|
|
818
|
+
labelName: label ? label.name : "",
|
|
702
819
|
};
|
|
703
820
|
commit("SET_DOCUMENT_ANNOTATION_SELECTED", value);
|
|
704
821
|
},
|
|
@@ -716,7 +833,7 @@ const actions = {
|
|
|
716
833
|
HTTP.post(`/annotations/`, annotation)
|
|
717
834
|
.then(async (response) => {
|
|
718
835
|
if (response.status === 201) {
|
|
719
|
-
dispatch("fetchMissingAnnotations");
|
|
836
|
+
await dispatch("fetchMissingAnnotations");
|
|
720
837
|
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
721
838
|
|
|
722
839
|
if (!getters.annotationSetExists(response.data.annotation_set)) {
|
|
@@ -827,13 +944,14 @@ const actions = {
|
|
|
827
944
|
});
|
|
828
945
|
},
|
|
829
946
|
|
|
830
|
-
addMissingAnnotations: ({ commit,
|
|
947
|
+
addMissingAnnotations: ({ commit, getters }, missingAnnotations) => {
|
|
831
948
|
return new Promise((resolve, reject) => {
|
|
832
|
-
|
|
833
|
-
.then((response) => {
|
|
949
|
+
HTTP.post(`/missing-annotations/`, missingAnnotations)
|
|
950
|
+
.then(async (response) => {
|
|
834
951
|
if (response.status === 201) {
|
|
835
|
-
commit("
|
|
836
|
-
|
|
952
|
+
commit("SET_ANNOTATIONS_MARKED_AS_MISSING", null);
|
|
953
|
+
commit("ADD_MISSING_ANNOTATIONS", response.data);
|
|
954
|
+
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
837
955
|
}
|
|
838
956
|
|
|
839
957
|
resolve(response);
|
|
@@ -845,12 +963,13 @@ const actions = {
|
|
|
845
963
|
});
|
|
846
964
|
},
|
|
847
965
|
|
|
848
|
-
deleteMissingAnnotation: ({ commit, getters
|
|
966
|
+
deleteMissingAnnotation: ({ commit, getters }, id) => {
|
|
849
967
|
return new Promise((resolve, reject) => {
|
|
850
968
|
return HTTP.delete(`/missing-annotations/${id}/`)
|
|
851
969
|
.then((response) => {
|
|
852
970
|
if (response.status === 204) {
|
|
853
|
-
|
|
971
|
+
commit("DELETE_MISSING_ANNOTATION", id);
|
|
972
|
+
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
854
973
|
resolve(true);
|
|
855
974
|
}
|
|
856
975
|
})
|
|
@@ -891,8 +1010,11 @@ const actions = {
|
|
|
891
1010
|
`documents/${state.documentId}/?fields=status_data,labeling_available`
|
|
892
1011
|
)
|
|
893
1012
|
.then((response) => {
|
|
894
|
-
if (
|
|
895
|
-
|
|
1013
|
+
if (
|
|
1014
|
+
getters.isDocumentReadyToBeReviewed(response.data) ||
|
|
1015
|
+
getters.waitingForSplittingConfirmation(response.data)
|
|
1016
|
+
) {
|
|
1017
|
+
// ready or has splitting suggestions
|
|
896
1018
|
return resolve(true);
|
|
897
1019
|
} else if (getters.documentHadErrorDuringExtraction(response.data)) {
|
|
898
1020
|
// error
|
|
@@ -1029,11 +1151,21 @@ const mutations = {
|
|
|
1029
1151
|
(existingAnnotation) => existingAnnotation.id === annotation.id
|
|
1030
1152
|
);
|
|
1031
1153
|
if (indexOfAnnotationAnnotationSets > -1) {
|
|
1032
|
-
label
|
|
1033
|
-
|
|
1034
|
-
1
|
|
1035
|
-
|
|
1036
|
-
|
|
1154
|
+
// checks if an annotation label was changed and add it to the new label
|
|
1155
|
+
if (annotation.label && annotation.label.id !== label.id) {
|
|
1156
|
+
label.annotations.splice(indexOfAnnotationAnnotationSets, 1);
|
|
1157
|
+
|
|
1158
|
+
const labelToAdd = annotationSet.labels.find(
|
|
1159
|
+
(labelToAdd) => labelToAdd.id === annotation.label.id
|
|
1160
|
+
);
|
|
1161
|
+
labelToAdd.annotations.push(annotation);
|
|
1162
|
+
} else {
|
|
1163
|
+
label.annotations.splice(
|
|
1164
|
+
indexOfAnnotationAnnotationSets,
|
|
1165
|
+
1,
|
|
1166
|
+
annotation
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1037
1169
|
updatedAnnotation = true;
|
|
1038
1170
|
return;
|
|
1039
1171
|
}
|
|
@@ -1123,7 +1255,20 @@ const mutations = {
|
|
|
1123
1255
|
SET_MISSING_ANNOTATIONS: (state, missingAnnotations) => {
|
|
1124
1256
|
state.missingAnnotations = missingAnnotations;
|
|
1125
1257
|
},
|
|
1258
|
+
ADD_MISSING_ANNOTATIONS: (state, missingAnnotations) => {
|
|
1259
|
+
missingAnnotations.map((annotation) => {
|
|
1260
|
+
state.missingAnnotations.push(annotation);
|
|
1261
|
+
});
|
|
1262
|
+
},
|
|
1263
|
+
DELETE_MISSING_ANNOTATION: (state, id) => {
|
|
1264
|
+
const indexOfAnnotationToDelete = state.missingAnnotations.findIndex(
|
|
1265
|
+
(annotation) => annotation.id === id
|
|
1266
|
+
);
|
|
1126
1267
|
|
|
1268
|
+
if (indexOfAnnotationToDelete > -1) {
|
|
1269
|
+
state.missingAnnotations.splice(indexOfAnnotationToDelete, 1);
|
|
1270
|
+
}
|
|
1271
|
+
},
|
|
1127
1272
|
SET_SHOW_ACTION_ERROR: (state, value) => {
|
|
1128
1273
|
state.showActionError = value;
|
|
1129
1274
|
},
|
|
@@ -1133,8 +1278,8 @@ const mutations = {
|
|
|
1133
1278
|
SET_DOCUMENT_ERROR: (state, value) => {
|
|
1134
1279
|
state.showDocumentError = value;
|
|
1135
1280
|
},
|
|
1136
|
-
|
|
1137
|
-
state.
|
|
1281
|
+
SET_ANNOTATIONS_MARKED_AS_MISSING: (state, annotations) => {
|
|
1282
|
+
state.annotationsMarkedAsMissing = annotations;
|
|
1138
1283
|
},
|
|
1139
1284
|
SET_ERROR_MESSAGE_WIDTH: (state, width) => {
|
|
1140
1285
|
state.errorMessageWidth = width;
|
|
@@ -1164,6 +1309,9 @@ const mutations = {
|
|
|
1164
1309
|
UPDATE_FILE_NAME: (state, value) => {
|
|
1165
1310
|
state.selectedDocument.data_file_name = value;
|
|
1166
1311
|
},
|
|
1312
|
+
SET_SPLITTING_SUGGESTIONS: (state, array) => {
|
|
1313
|
+
state.splittingSuggestions = array;
|
|
1314
|
+
},
|
|
1167
1315
|
};
|
|
1168
1316
|
|
|
1169
1317
|
export default {
|
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
|
-
|
|
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
|
-
|
|
29
|
-
commit("
|
|
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.
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
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
|
|
71
|
+
return {
|
|
72
|
+
...p,
|
|
73
|
+
angle: rotatedAngle,
|
|
74
|
+
};
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
84
|
+
return {
|
|
85
|
+
...p,
|
|
86
|
+
angle: rotatedAngle,
|
|
87
|
+
};
|
|
89
88
|
}
|
|
90
|
-
|
|
89
|
+
return p;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
91
92
|
|
|
92
|
-
commit("
|
|
93
|
+
commit("SET_PAGES_FOR_POSTPROCESS", pagesForPostprocess);
|
|
93
94
|
} else {
|
|
94
95
|
if (direction === "left") {
|
|
95
|
-
state.
|
|
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.
|
|
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.
|
|
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("
|
|
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.
|
|
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("
|
|
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, reject) => {
|
|
153
157
|
HTTP.post(
|
|
154
158
|
`/documents/${rootState.document.documentId}/postprocess/`,
|
|
@@ -156,15 +160,23 @@ const actions = {
|
|
|
156
160
|
)
|
|
157
161
|
.then(async (response) => {
|
|
158
162
|
if (response && response.status === 200) {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
const newId = response.data[0].id;
|
|
164
|
+
dispatch("document/setSplittingSuggestions", null, { root: true });
|
|
165
|
+
|
|
166
|
+
if (newId !== oldId) {
|
|
167
|
+
if (getURLQueryParam("document")) {
|
|
168
|
+
navigateToNewDocumentURL(oldId, newId);
|
|
169
|
+
} else {
|
|
170
|
+
await dispatch("document/setDocId", newId, {
|
|
171
|
+
root: true,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
dispatch("document/pollDocumentEndpoint", null, {
|
|
175
|
+
root: true,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
168
180
|
resolve(null);
|
|
169
181
|
} else {
|
|
170
182
|
resolve(response);
|
|
@@ -176,6 +188,10 @@ const actions = {
|
|
|
176
188
|
});
|
|
177
189
|
});
|
|
178
190
|
},
|
|
191
|
+
|
|
192
|
+
setShowEditConfirmationModal: ({ commit }, value) => {
|
|
193
|
+
commit("SET_SHOW_EDIT_CONFIRMATION_MODAL", value);
|
|
194
|
+
},
|
|
179
195
|
};
|
|
180
196
|
|
|
181
197
|
const mutations = {
|
|
@@ -187,8 +203,8 @@ const mutations = {
|
|
|
187
203
|
state.splitOverview = overview;
|
|
188
204
|
},
|
|
189
205
|
|
|
190
|
-
|
|
191
|
-
state.
|
|
206
|
+
SET_PAGES_FOR_POSTPROCESS: (state, pages) => {
|
|
207
|
+
state.pagesForPostprocess = pages;
|
|
192
208
|
},
|
|
193
209
|
|
|
194
210
|
SET_UPDATED_DOCUMENT: (state, updatedDocument) => {
|
|
@@ -200,6 +216,9 @@ const mutations = {
|
|
|
200
216
|
ADD_SELECTED_PAGE: (state, selectedPage) => {
|
|
201
217
|
state.selectedPages.push(selectedPage);
|
|
202
218
|
},
|
|
219
|
+
SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
|
|
220
|
+
state.showEditConfirmationModal = value;
|
|
221
|
+
},
|
|
203
222
|
};
|
|
204
223
|
|
|
205
224
|
export default {
|
package/src/store/project.js
CHANGED
|
@@ -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
|
};
|