@konfuzio/document-validation-ui 0.1.59-dev.0 → 0.1.59-dev.3

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 (63) hide show
  1. package/cypress.config.js +6 -6
  2. package/dist/css/app.css +1 -1
  3. package/dist/index.html +1 -1
  4. package/dist/js/app.js +1 -1
  5. package/dist/js/app.js.map +1 -1
  6. package/dist/js/chunk-vendors.js +66 -23
  7. package/dist/js/chunk-vendors.js.map +1 -1
  8. package/jest.config.js +22 -2
  9. package/package.json +32 -38
  10. package/src/assets/scss/ann_set_table_options.scss +4 -4
  11. package/src/assets/scss/annotation_action_buttons.scss +7 -7
  12. package/src/assets/scss/annotation_details.scss +9 -9
  13. package/src/assets/scss/choose_label_set_modal.scss +5 -5
  14. package/src/assets/scss/document_action_bar.scss +3 -3
  15. package/src/assets/scss/document_annotations.scss +44 -43
  16. package/src/assets/scss/document_category.scss +8 -8
  17. package/src/assets/scss/document_dashboard.scss +1 -1
  18. package/src/assets/scss/document_edit.scss +30 -30
  19. package/src/assets/scss/document_error.scss +6 -6
  20. package/src/assets/scss/document_name.scss +6 -6
  21. package/src/assets/scss/document_page.scss +3 -3
  22. package/src/assets/scss/document_search_bar.scss +7 -7
  23. package/src/assets/scss/document_set_chooser.scss +3 -3
  24. package/src/assets/scss/document_thumbnails.scss +7 -7
  25. package/src/assets/scss/document_toolbar.scss +10 -10
  26. package/src/assets/scss/document_top_bar.scss +11 -11
  27. package/src/assets/scss/document_viewport_modal.scss +3 -3
  28. package/src/assets/scss/documents_list.scss +11 -12
  29. package/src/assets/scss/edit_page_thumbnail.scss +6 -6
  30. package/src/assets/scss/empty_state.scss +4 -4
  31. package/src/assets/scss/error_page.scss +2 -2
  32. package/src/assets/scss/extracting_data.scss +3 -3
  33. package/src/assets/scss/multi_ann_table_overlay.scss +3 -3
  34. package/src/assets/scss/multi_ann_table_popup.scss +1 -1
  35. package/src/assets/scss/new_annotation.scss +25 -19
  36. package/src/assets/scss/scrolling_document.scss +1 -1
  37. package/src/assets/scss/theme.scss +64 -52
  38. package/src/assets/scss/variables.scss +2 -0
  39. package/src/components/App.vue +9 -14
  40. package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +4 -6
  41. package/src/components/DocumentAnnotations/AnnotationContent.vue +25 -52
  42. package/src/components/DocumentAnnotations/AnnotationRow.vue +106 -50
  43. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +12 -6
  44. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +31 -70
  45. package/src/components/DocumentDashboard.vue +12 -17
  46. package/src/components/DocumentEdit/EditPages.vue +51 -46
  47. package/src/components/DocumentPage/{NewAnnotation.vue → AnnotationPopup.vue} +122 -94
  48. package/src/components/DocumentPage/BoxSelection.vue +16 -49
  49. package/src/components/DocumentPage/DocumentPage.vue +56 -153
  50. package/src/components/DocumentPage/DocumentToolbar.vue +0 -1
  51. package/src/components/DocumentPage/PlaceholderSelection.vue +51 -0
  52. package/src/components/DocumentPage/SpanSelection.vue +259 -0
  53. package/src/components/DocumentThumbnails/LoadingThumbnail.vue +3 -6
  54. package/src/components/DocumentTopBar/DocumentTopBar.vue +4 -2
  55. package/src/constants.js +1 -7
  56. package/src/i18n.js +2 -5
  57. package/src/main.js +14 -16
  58. package/src/store/display.js +33 -22
  59. package/src/store/document.js +1 -0
  60. package/src/store/index.js +5 -8
  61. package/src/store/selection.js +152 -76
  62. package/src/assets/scss/imports.scss +0 -1
  63. package/src/components/DocumentPage/EditAnnotation.vue +0 -372
@@ -1,372 +0,0 @@
1
- <!-- eslint-disable vue/no-v-html -->
2
- <template>
3
- <div
4
- v-if="annotation && !hide"
5
- class="annotation-popup small"
6
- :style="{ left: `${left}px`, top: `${top}px` }"
7
- >
8
- <b-dropdown
9
- v-model="selectedSet"
10
- aria-role="list"
11
- :class="[
12
- 'annotation-dropdown',
13
- 'no-padding-bottom',
14
- 'dropdown-full-width',
15
- setsList.length === 0 ? 'no-padding-top' : '',
16
- ]"
17
- scrollable
18
- >
19
- <template #trigger>
20
- <b-button
21
- :class="[
22
- 'popup-input',
23
- selectedSet ? '' : 'not-selected',
24
- 'has-right-icon',
25
- ]"
26
- type="is-text"
27
- >
28
- {{
29
- selectedSet
30
- ? `${selectedSet.label_set.name} ${
31
- selectedSet.id
32
- ? numberOfAnnotationSetGroup(selectedSet)
33
- : `${numberOfLabelSetGroup(selectedSet.label_set)} (${$t(
34
- "new"
35
- )})`
36
- }`
37
- : $t("select_annotation_set")
38
- }}
39
- <span class="caret-icon">
40
- <b-icon icon="angle-down" size="is-small" class="caret" />
41
- </span>
42
- </b-button>
43
- </template>
44
- <b-button
45
- type="is-ghost"
46
- :class="['add-ann-set', 'dropdown-item', 'no-icon-margin']"
47
- icon-left="plus"
48
- @click="openAnnotationSetCreation"
49
- >
50
- {{ $t("new_ann_set_title") }}
51
- </b-button>
52
- <b-dropdown-item
53
- v-for="(set, index) in setsList"
54
- :key="`${set.label_set.id}_${index}`"
55
- aria-role="listitem"
56
- :value="set"
57
- >
58
- <span>{{
59
- `${set.label_set.name} ${
60
- set.id
61
- ? numberOfAnnotationSetGroup(set)
62
- : `${numberOfLabelSetGroup(set.label_set)} (${$t("new")})`
63
- }`
64
- }}</span>
65
- </b-dropdown-item>
66
- </b-dropdown>
67
- <b-tooltip
68
- multilined
69
- :active="selectedSet && (!labelsFiltered || labelsFiltered.length === 0)"
70
- size="is-large"
71
- position="is-bottom"
72
- class="bottom-aligned"
73
- :close-delay="5000"
74
- >
75
- <template #content>
76
- <div
77
- v-html="
78
- `${$t('no_labels_available')} ${
79
- showBranding ? $t('no_labels_available_link') : ''
80
- }`
81
- "
82
- ></div>
83
- </template>
84
- <b-dropdown
85
- v-if="selectedLabel"
86
- v-model="selectedLabel"
87
- aria-role="list"
88
- :disabled="!labelsFiltered || labelsFiltered.length === 0"
89
- scrollable
90
- class="label-dropdown annotation-dropdown dropdown-full-width"
91
- >
92
- <template #trigger>
93
- <b-button
94
- class="popup-input has-right-icon"
95
- :disabled="!labelsFiltered"
96
- type="is-text"
97
- >
98
- {{ selectedLabel.name }}
99
- <span class="caret-icon">
100
- <b-icon icon="angle-down" size="is-small" class="caret" />
101
- </span>
102
- </b-button>
103
- </template>
104
- <b-dropdown-item
105
- v-for="label in labelsFiltered"
106
- :key="label.id"
107
- aria-role="listitem"
108
- :value="label"
109
- >
110
- <span>{{ label.name }}</span>
111
- </b-dropdown-item>
112
- </b-dropdown>
113
- </b-tooltip>
114
- <div class="annotation-buttons">
115
- <b-button
116
- type="is-text"
117
- class="cancel-button popup-button primary-button"
118
- :label="$t('hide')"
119
- :disabled="loading"
120
- @click.prevent="hide = true"
121
- />
122
- <b-button
123
- type="is-primary"
124
- class="popup-button primary-button"
125
- :label="$t('save')"
126
- :disabled="loading || !spanSelection || !selectedLabel || !wasChanged"
127
- @click.prevent="save"
128
- />
129
- </div>
130
- </div>
131
- </template>
132
- <script>
133
- /**
134
- * This component is used to show a popup
135
- * for editing an annotation.
136
- */
137
- const heightOfPopup = 142;
138
- const margin = 12;
139
- const widthOfPopup = 205;
140
-
141
- import { mapGetters, mapState } from "vuex";
142
-
143
- export default {
144
- props: {
145
- editAnnotation: {
146
- required: true,
147
- type: Object,
148
- },
149
- page: {
150
- required: true,
151
- type: Object,
152
- },
153
- containerWidth: {
154
- type: Number,
155
- required: true,
156
- },
157
- containerHeight: {
158
- type: Number,
159
- required: true,
160
- },
161
- },
162
- data() {
163
- return {
164
- annotation: null,
165
- selectedLabel: null,
166
- selectedSet: null,
167
- labelsFiltered: null,
168
- loading: false,
169
- isAnnSetModalShowing: false,
170
- setsList: [],
171
- hide: false,
172
- };
173
- },
174
- computed: {
175
- ...mapState("document", [
176
- "annotationSets",
177
- "annotations",
178
- "labels",
179
- "documentId",
180
- ]),
181
- ...mapGetters("document", [
182
- "numberOfAnnotationSetGroup",
183
- "numberOfLabelSetGroup",
184
- "labelsFilteredForAnnotationCreation",
185
- ]),
186
- ...mapState("display", ["showBranding"]),
187
- ...mapGetters("display", ["bboxToRect"]),
188
- ...mapState("selection", ["selection", "spanSelection"]),
189
- top() {
190
- if (this.selection && this.selection.start && this.selection.end) {
191
- const top = this.selection.start.y - heightOfPopup; // subtract the height of the popup plus some margin
192
-
193
- const height = this.selection.end.y - this.selection.start.y;
194
-
195
- //check if the popup will not go off the container on the top
196
- return this.selection.start.y > heightOfPopup
197
- ? top - margin
198
- : this.selection.start.y + height + margin;
199
- }
200
- return 0;
201
- },
202
- left() {
203
- if (this.selection && this.selection.start && this.selection.end) {
204
- const width = this.selection.end.x - this.selection.start.x;
205
-
206
- const left = this.selection.start.x + width / 2 - widthOfPopup / 2; // add the entity half width to be centered and then subtract half the width of the popup
207
-
208
- //check if the popup will not go off the container
209
- if (left + widthOfPopup > this.containerWidth) {
210
- // on the right side
211
- return this.containerWidth - widthOfPopup;
212
- } else {
213
- // on the left side
214
- return left > 0 ? left : 0;
215
- }
216
- }
217
- return 0;
218
- },
219
- wasChanged() {
220
- return (
221
- this.editAnnotation.annotationSet.id !== this.selectedSet.id ||
222
- this.editAnnotation.label.id !== this.selectedLabel.id
223
- );
224
- },
225
- },
226
- watch: {
227
- selectedSet(newValue) {
228
- this.labelsFiltered = this.labelsFilteredForAnnotationCreation(newValue);
229
- },
230
- editAnnotation() {
231
- this.hide = false;
232
- this.loadInfo();
233
- },
234
- },
235
- mounted() {
236
- this.loadInfo();
237
-
238
- setTimeout(() => {
239
- // prevent click propagation when opening the popup
240
- document.body.addEventListener("click", this.clickOutside);
241
- }, 200);
242
- },
243
- destroyed() {
244
- document.body.removeEventListener("click", this.clickOutside);
245
- },
246
- methods: {
247
- orderedSetList(setsList) {
248
- setsList.sort((a, b) => {
249
- const nameA = a.label_set.name;
250
- const nameB = b.label_set.name;
251
- if (nameA < nameB) {
252
- return -1;
253
- }
254
- if (nameA > nameB) {
255
- return 1;
256
- }
257
-
258
- // names must be equal
259
- return 0;
260
- });
261
- return setsList;
262
- },
263
- loadInfo() {
264
- this.setsList = this.orderedSetList([...this.annotationSets]);
265
-
266
- this.selectedSet = this.annotationSets.find(
267
- (annSet) => annSet.id === this.editAnnotation.annotationSet.id
268
- );
269
-
270
- this.labelsFiltered = this.labelsFilteredForAnnotationCreation(
271
- this.selectedSet
272
- );
273
-
274
- // if existing label is not able to be chosen we add it manually
275
- if (!this.labelsFiltered.includes(this.editAnnotation.label)) {
276
- this.labelsFiltered.push(this.editAnnotation.label);
277
- }
278
-
279
- this.selectedLabel = this.editAnnotation.label;
280
-
281
- this.annotation = this.annotations.find(
282
- (ann) => ann.id === this.editAnnotation.id
283
- );
284
- },
285
- close() {
286
- this.$store.dispatch("document/resetEditAnnotation");
287
- this.$store.dispatch("selection/disableSelection");
288
- this.$store.dispatch("selection/setSelectedEntities", null);
289
- this.$emit("close");
290
- },
291
- async save() {
292
- this.loading = true;
293
-
294
- if (this.wasChanged) {
295
- // first delete annotation, then create new one
296
- await this.$store
297
- .dispatch("document/deleteAnnotation", {
298
- annotationId: this.annotation.id,
299
- })
300
- .catch((error) => {
301
- this.$store.dispatch("document/createErrorMessage", {
302
- error,
303
- serverErrorMessage: this.$t("server_error"),
304
- defaultErrorMessage: this.$t("edit_error"),
305
- });
306
- });
307
-
308
- const spans = this.annotation.span;
309
- spans[this.editAnnotation.index] = this.spanSelection;
310
-
311
- const annotationToCreate = {
312
- document: this.documentId,
313
- span: spans,
314
- label: this.selectedLabel.id,
315
- is_correct: true,
316
- revised: false,
317
- };
318
-
319
- if (this.selectedSet.id) {
320
- annotationToCreate.annotation_set = this.selectedSet.id;
321
- } else {
322
- annotationToCreate.label_set = this.selectedSet.label_set.id;
323
- }
324
-
325
- this.$store
326
- .dispatch("document/createAnnotation", {
327
- annotation: annotationToCreate,
328
- })
329
- .catch((error) => {
330
- this.$store.dispatch("document/createErrorMessage", {
331
- error,
332
- serverErrorMessage: this.$t("server_error"),
333
- defaultErrorMessage: this.$t("error_creating_annotation"),
334
- });
335
- })
336
- .finally(() => {
337
- this.close();
338
- this.loading = false;
339
- });
340
- } else {
341
- this.close();
342
- }
343
- },
344
- chooseLabelSet(labelSet) {
345
- // check if there's already a new entry for that label set to be created
346
- const existsIndex = this.setsList.findIndex((set) => {
347
- return set.id === null && set.label_set.id === labelSet.id;
348
- });
349
-
350
- const newSet = {
351
- label_set: labelSet,
352
- labels: labelSet.labels,
353
- id: null,
354
- };
355
- if (existsIndex >= 0) {
356
- this.setsList[existsIndex] = newSet;
357
- } else {
358
- this.setsList.unshift(newSet);
359
- }
360
- this.selectedSet = newSet;
361
- },
362
- openAnnotationSetCreation() {
363
- this.$store.dispatch("display/showChooseLabelSetModal", {
364
- show: true,
365
- finish: this.chooseLabelSet,
366
- });
367
- },
368
- },
369
- };
370
- </script>
371
-
372
- <style scoped lang="scss" src="../../assets/scss/new_annotation.scss"></style>