@konfuzio/document-validation-ui 0.1.10-dev.9 → 0.1.11-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 (38) hide show
  1. package/dist/css/app.css +1 -1
  2. package/dist/index.html +1 -1
  3. package/dist/js/app.js +1 -1
  4. package/dist/js/app.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/assets/scss/document_edit.scss +2 -0
  7. package/src/assets/scss/document_name.scss +0 -2
  8. package/src/assets/scss/document_top_bar.scss +22 -0
  9. package/src/assets/scss/new_annotation.scss +3 -0
  10. package/src/assets/scss/theme.scss +533 -523
  11. package/src/components/App.vue +23 -8
  12. package/src/components/DocumentAnnotations/AnnotationContent.vue +33 -18
  13. package/src/components/DocumentAnnotations/AnnotationRow.vue +21 -60
  14. package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +3 -2
  15. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +1 -5
  16. package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +1 -1
  17. package/src/components/DocumentDashboard.vue +8 -0
  18. package/src/components/DocumentEdit/DocumentEdit.vue +20 -11
  19. package/src/components/DocumentEdit/EditConfirmationModal.vue +1 -0
  20. package/src/components/DocumentEdit/EditPageThumbnail.vue +1 -3
  21. package/src/components/DocumentEdit/EditSidebar.vue +8 -3
  22. package/src/components/DocumentPage/DocumentPage.vue +0 -18
  23. package/src/components/DocumentPage/DocumentToolbar.vue +1 -0
  24. package/src/components/DocumentPage/MultiAnnSelection.vue +4 -26
  25. package/src/components/DocumentPage/NewAnnotation.vue +4 -22
  26. package/src/components/DocumentTopBar/DocumentName.vue +3 -1
  27. package/src/components/DocumentTopBar/DocumentTopBar.vue +81 -2
  28. package/src/components/DocumentsList/DocumentsList.vue +1 -6
  29. package/src/locales/de.json +3 -2
  30. package/src/locales/en.json +2 -1
  31. package/src/locales/es.json +2 -1
  32. package/src/store/category.js +19 -35
  33. package/src/store/display.js +7 -0
  34. package/src/store/document.js +29 -5
  35. package/src/store/edit.js +27 -15
  36. package/src/store/project.js +31 -1
  37. package/src/utils/utils.js +18 -1
  38. package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +0 -226
@@ -1,226 +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
- this.$store.dispatch("display/showDocumentActionBar", {
160
- show: true,
161
- loading: false,
162
- action: true,
163
- });
164
-
165
- this.orderedEntities.forEach((orderedEntity) => {
166
- annotations.push({
167
- document: this.documentId,
168
- span: orderedEntity.spans,
169
- label: orderedEntity.label_id,
170
- is_correct: true,
171
- revised: false,
172
- label_set: labelSet.id,
173
- set_reference: orderedEntity.row_index,
174
- });
175
- });
176
-
177
- this.$store
178
- .dispatch("document/createAnnotation", annotations)
179
- .then(() => {
180
- this.$emit("close");
181
- })
182
- .catch((error) => {
183
- this.$store.dispatch("document/createErrorMessage", {
184
- error,
185
- serverErrorMessage: this.$t("server_error"),
186
- defaultErrorMessage: this.$t("error_creating_multi_ann"),
187
- });
188
- });
189
- },
190
- deleteRow(index) {
191
- this.rows.splice(index, 1);
192
- },
193
-
194
- //#region Column Drag
195
- columndragstart(payload) {
196
- this.draggingColumn = payload.column;
197
- this.draggingColumnIndex = payload.index;
198
- payload.event.dataTransfer.effectAllowed = "copy";
199
- },
200
- columndragover(payload) {
201
- payload.event.dataTransfer.dropEffect = "copy";
202
- payload.event.target.closest("th").classList.add("is-selected");
203
- payload.event.preventDefault();
204
- },
205
- columndragleave(payload) {
206
- payload.event.target.closest("th").classList.remove("is-selected");
207
- payload.event.preventDefault();
208
- },
209
- columndrop(payload) {
210
- payload.event.target.closest("th").classList.remove("is-selected");
211
- const droppedOnColumnIndex = payload.index;
212
-
213
- const column = this.columns[this.draggingColumnIndex];
214
- this.columns.splice(this.draggingColumnIndex, 1);
215
- this.columns.splice(droppedOnColumnIndex, 0, column);
216
- this.handleRows();
217
- },
218
- //#endregion
219
- },
220
- };
221
- </script>
222
- <style
223
- scoped
224
- lang="scss"
225
- src="../../assets/scss/multi_ann_table_popup.scss"
226
- ></style>