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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +12 -0
  2. package/cypress.config.js +13 -0
  3. package/dist/css/app.css +1 -1
  4. package/dist/index.html +1 -1
  5. package/dist/js/app.js +1 -1
  6. package/dist/js/app.js.map +1 -1
  7. package/dist/js/chunk-vendors.js +3 -3
  8. package/dist/js/chunk-vendors.js.map +1 -1
  9. package/package.json +5 -1
  10. package/src/api.js +53 -23
  11. package/src/assets/images/DraggableIcon.vue +14 -0
  12. package/src/assets/images/GridIcon.vue +16 -0
  13. package/src/assets/images/MagicWandIcon.vue +16 -0
  14. package/src/assets/images/NotFoundIcon.vue +16 -0
  15. package/src/assets/images/ServerImage.vue +19 -9
  16. package/src/assets/images/SettingsIcon.vue +14 -0
  17. package/src/assets/images/SplitZigZag.vue +47 -14
  18. package/src/assets/images/StarIcon.vue +16 -0
  19. package/src/assets/scss/ann_set_table_options.scss +26 -0
  20. package/src/assets/scss/annotation_details.scss +86 -71
  21. package/src/assets/scss/choose_label_set_modal.scss +1 -1
  22. package/src/assets/scss/document_annotations.scss +242 -229
  23. package/src/assets/scss/document_category.scss +12 -7
  24. package/src/assets/scss/document_dashboard.scss +7 -2
  25. package/src/assets/scss/document_edit.scss +151 -173
  26. package/src/assets/scss/document_name.scss +0 -2
  27. package/src/assets/scss/document_thumbnails.scss +1 -1
  28. package/src/assets/scss/document_toolbar.scss +23 -1
  29. package/src/assets/scss/document_top_bar.scss +40 -1
  30. package/src/assets/scss/edit_page_thumbnail.scss +53 -0
  31. package/src/assets/scss/multi_ann_table_overlay.scss +38 -0
  32. package/src/assets/scss/new_annotation.scss +17 -3
  33. package/src/assets/scss/scrolling_document.scss +1 -1
  34. package/src/assets/scss/theme.scss +801 -0
  35. package/src/assets/scss/variables.scss +5 -663
  36. package/src/components/App.cy.js +7 -0
  37. package/src/components/App.vue +98 -11
  38. package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +168 -0
  39. package/src/components/DocumentAnnotations/AnnotationContent.vue +50 -84
  40. package/src/components/DocumentAnnotations/AnnotationDetails.vue +37 -12
  41. package/src/components/DocumentAnnotations/AnnotationRow.vue +244 -199
  42. package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -0
  43. package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +4 -2
  44. package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +295 -0
  45. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +195 -146
  46. package/src/components/DocumentAnnotations/DocumentLabel.vue +46 -9
  47. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +59 -88
  48. package/src/components/DocumentAnnotations/ExtractingData.vue +18 -6
  49. package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +337 -0
  50. package/src/components/DocumentAnnotations/index.js +1 -1
  51. package/src/components/DocumentCategory.vue +89 -65
  52. package/src/components/DocumentDashboard.vue +59 -48
  53. package/src/components/DocumentEdit/DocumentEdit.vue +302 -105
  54. package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -0
  55. package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -0
  56. package/src/components/DocumentEdit/EditPages.vue +60 -103
  57. package/src/components/DocumentEdit/EditSidebar.vue +101 -48
  58. package/src/components/DocumentEdit/{SplitOverview.vue → RenameAndCategorize.vue} +15 -13
  59. package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
  60. package/src/components/DocumentEdit/SplitInfoBar.vue +21 -0
  61. package/src/components/DocumentEdit/index.js +1 -1
  62. package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +9 -8
  63. package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
  64. package/src/components/DocumentPage/ActionBar.vue +3 -3
  65. package/src/components/DocumentPage/AnnSetTableOptions.vue +110 -0
  66. package/src/components/DocumentPage/BoxSelection.vue +4 -1
  67. package/src/components/DocumentPage/DocumentPage.vue +92 -68
  68. package/src/components/DocumentPage/DocumentToolbar.vue +105 -16
  69. package/src/components/DocumentPage/DummyPage.vue +9 -7
  70. package/src/components/DocumentPage/MultiAnnSelection.vue +96 -27
  71. package/src/components/DocumentPage/NewAnnotation.vue +31 -35
  72. package/src/components/DocumentPage/ScrollingDocument.vue +46 -5
  73. package/src/components/DocumentPage/ScrollingPage.vue +5 -6
  74. package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +64 -0
  75. package/src/components/DocumentThumbnails/DocumentThumbnails.vue +53 -13
  76. package/src/components/DocumentTopBar/DocumentName.vue +16 -4
  77. package/src/components/DocumentTopBar/DocumentTopBar.vue +86 -15
  78. package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +99 -72
  79. package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +6 -3
  80. package/src/components/DocumentsList/DocumentsList.vue +6 -2
  81. package/src/components/index.js +1 -0
  82. package/src/constants.js +2 -1
  83. package/src/icons.js +45 -0
  84. package/src/locales/de.json +48 -21
  85. package/src/locales/en.json +37 -11
  86. package/src/locales/es.json +41 -13
  87. package/src/main.js +5 -66
  88. package/src/store/category.js +20 -36
  89. package/src/store/display.js +74 -1
  90. package/src/store/document.js +305 -109
  91. package/src/store/edit.js +160 -61
  92. package/src/store/project.js +46 -16
  93. package/src/store/selection.js +42 -10
  94. package/src/utils/utils.js +36 -0
  95. package/dist/css/chunk-vendors.css +0 -5
  96. package/src/.DS_Store +0 -0
  97. package/src/assets/scss/categorize_modal.scss +0 -45
  98. package/src/assets/scss/main.scss +0 -24
  99. package/src/components/DocumentAnnotations/ActionButtons.vue +0 -250
  100. package/src/components/DocumentAnnotations/CategorizeModal.vue +0 -219
  101. package/src/components/DocumentAnnotations/RejectedLabels.vue +0 -96
  102. package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +0 -253
@@ -1,253 +0,0 @@
1
- <template>
2
- <div
3
- class="multi-ann-table-popup"
4
- :style="{
5
- left: `${tablePosition.x}px`,
6
- top: `${tablePosition.y - 22}px`,
7
- width: `${tablePosition.width}px`,
8
- height: `${tablePosition.height}px`,
9
- maxWidth: `${pageSize.width}px`,
10
- maxHeight: `${pageSize.height}px`,
11
- }"
12
- >
13
- <b-table
14
- ref="table"
15
- class="full-height"
16
- detail-icon="faScissors"
17
- :data="rows"
18
- :columns="columns"
19
- :narrowed="true"
20
- :bordered="true"
21
- draggable-column
22
- @columndragstart="columndragstart"
23
- @columndrop="columndrop"
24
- @columndragover="columndragover"
25
- @columndragleave="columndragleave"
26
- >
27
- </b-table>
28
- </div>
29
- </template>
30
-
31
- <script>
32
- import { mapState } from "vuex";
33
-
34
- export default {
35
- name: "MultiAnnotationTablePopup",
36
-
37
- props: {
38
- tablePosition: {
39
- required: true,
40
- type: Object,
41
- default: null,
42
- },
43
- pageSize: {
44
- required: true,
45
- type: Object,
46
- default: null,
47
- },
48
- labelSet: {
49
- required: true,
50
- type: Object,
51
- default: null,
52
- },
53
- groupedEntities: {
54
- required: true,
55
- type: Object,
56
- default: null,
57
- },
58
- },
59
- data() {
60
- const columns = this.labelSet.labels.map((label) => {
61
- return {
62
- field: `${label.id}`,
63
- label: label.name,
64
- centered: true,
65
- };
66
- });
67
- return {
68
- rows: [],
69
- columns,
70
- counter: 0,
71
- draggingColumn: null,
72
- draggingColumnIndex: null,
73
- orderedEntities: [],
74
- };
75
- },
76
- computed: {
77
- ...mapState("document", ["documentId"]),
78
- },
79
- mounted() {
80
- this.handleRows();
81
- setTimeout(() => {
82
- // prevent click propagation when opening the popup
83
- document.body.addEventListener("click", this.clickOutside);
84
- this.$refs.table.$el.scrollIntoView({
85
- behavior: "smooth",
86
- block: "nearest",
87
- inline: "center",
88
- });
89
- }, 200);
90
-
91
- // show action bar
92
- this.$store.dispatch("display/showDocumentActionBar", {
93
- show: true,
94
- text: this.$t("drag_drop_columns_multi_ann"),
95
- icon: "drag",
96
- loading: false,
97
- action: () => {
98
- this.submitAnnotations();
99
- this.$emit("close");
100
- },
101
- });
102
- },
103
- destroyed() {
104
- this.$store.dispatch("display/showDocumentActionBar", { show: false });
105
- this.$store.dispatch("selection/disableSelection");
106
- document.body.removeEventListener("click", this.clickOutside);
107
- },
108
- methods: {
109
- handleRows() {
110
- this.rows = [];
111
- this.orderedEntities = []; // this will match the order of entities in the table so we have a way of tracking them once we submit
112
- let rowIndex = 0;
113
-
114
- Object.entries(this.groupedEntities).forEach(([key, groupedEntity]) => {
115
- let row = null;
116
- this.columns.forEach((column, index) => {
117
- let spans = [];
118
- if (
119
- Object.entries(groupedEntity)[index] &&
120
- Object.entries(groupedEntity)[index].length > 0
121
- ) {
122
- spans = Object.entries(groupedEntity)[index][1];
123
- }
124
- const entityExists = spans.length > 0;
125
-
126
- let textContent = "";
127
-
128
- spans.forEach((entity) => {
129
- textContent = `${textContent} ${entity.offset_string}`;
130
- });
131
-
132
- row = {
133
- ...row,
134
- [column.field]: textContent,
135
- };
136
- if (entityExists) {
137
- const customEntity = {
138
- spans: [...spans],
139
- label_id: column.field,
140
- row_index: rowIndex,
141
- };
142
-
143
- this.orderedEntities.push(customEntity);
144
- }
145
- });
146
- if (row !== null) {
147
- rowIndex++;
148
- }
149
- this.rows.push(row);
150
- });
151
- },
152
-
153
- clickOutside(event) {
154
- if (!(this.$el == event.target || this.$el.contains(event.target))) {
155
- this.$emit("close");
156
- }
157
- },
158
- async submitAnnotations() {
159
- let errorMessageShown = false;
160
- let previousAnnotationSetId = null;
161
- let previousRowIndex = 0;
162
-
163
- this.$store.dispatch("display/showDocumentActionBar", {
164
- show: true,
165
- loading: false,
166
- action: true,
167
- });
168
-
169
- // traditional for to await for every request
170
- for (let i = 0; i < this.orderedEntities.length; i++) {
171
- const groupedEntity = this.orderedEntities[i];
172
-
173
- const annotationToCreate = {
174
- document: this.documentId,
175
- span: groupedEntity.spans,
176
- label: groupedEntity.label_id,
177
- is_correct: true,
178
- revised: false,
179
- };
180
-
181
- if (groupedEntity.row_index !== previousRowIndex) {
182
- // if line changed then reset annotation set
183
- previousAnnotationSetId = null;
184
- }
185
- previousRowIndex = groupedEntity.row_index;
186
-
187
- if (previousAnnotationSetId) {
188
- annotationToCreate.annotation_set = previousAnnotationSetId;
189
- } else {
190
- annotationToCreate.label_set = this.labelSet.id;
191
- }
192
-
193
- await this.$store
194
- .dispatch("document/createAnnotation", annotationToCreate)
195
- .then((response) => {
196
- if (response) {
197
- // set ann set id to use on the next labels on the same row
198
- previousAnnotationSetId = response.data.annotation_set;
199
- }
200
- })
201
- .catch((error) => {
202
- if (!errorMessageShown) {
203
- this.$store.dispatch("document/createErrorMessage", {
204
- error,
205
- serverErrorMessage: this.$t("server_error"),
206
- defaultErrorMessage: this.$t("error_creating_multi_ann"),
207
- });
208
-
209
- // set to true to only show 1 error
210
- // the first time it appears
211
- errorMessageShown = true;
212
- }
213
- });
214
- }
215
- this.$emit("close");
216
- },
217
- deleteRow(index) {
218
- this.rows.splice(index, 1);
219
- },
220
-
221
- //#region Column Drag
222
- columndragstart(payload) {
223
- this.draggingColumn = payload.column;
224
- this.draggingColumnIndex = payload.index;
225
- payload.event.dataTransfer.effectAllowed = "copy";
226
- },
227
- columndragover(payload) {
228
- payload.event.dataTransfer.dropEffect = "copy";
229
- payload.event.target.closest("th").classList.add("is-selected");
230
- payload.event.preventDefault();
231
- },
232
- columndragleave(payload) {
233
- payload.event.target.closest("th").classList.remove("is-selected");
234
- payload.event.preventDefault();
235
- },
236
- columndrop(payload) {
237
- payload.event.target.closest("th").classList.remove("is-selected");
238
- const droppedOnColumnIndex = payload.index;
239
-
240
- const column = this.columns[this.draggingColumnIndex];
241
- this.columns.splice(this.draggingColumnIndex, 1);
242
- this.columns.splice(droppedOnColumnIndex, 0, column);
243
- this.handleRows();
244
- },
245
- //#endregion
246
- },
247
- };
248
- </script>
249
- <style
250
- scoped
251
- lang="scss"
252
- src="../../assets/scss/multi_ann_table_popup.scss"
253
- ></style>