@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
@@ -106,6 +106,7 @@
106
106
  <!-- save button -->
107
107
  <b-button
108
108
  v-if="showSave"
109
+ id="save-ann"
109
110
  :class="`button-action ${showText ? 'is-button-text' : 'is-button-icon'}`"
110
111
  :type="showText ? 'is-primary' : 'is-ghost'"
111
112
  @click.stop="save"
@@ -205,9 +206,7 @@ export default {
205
206
  data() {
206
207
  return {
207
208
  tooltipDelay: 700,
208
- showText:
209
- window.innerWidth >
210
- TEXT_BREAKPOINT_WIDTH(this.$i18n ? this.$i18n.locale : "en"),
209
+ showText: window.innerWidth > TEXT_BREAKPOINT_WIDTH,
211
210
  };
212
211
  },
213
212
  computed: {
@@ -227,13 +226,12 @@ export default {
227
226
  window.addEventListener("resize", this.resize);
228
227
  },
229
228
 
230
- destroyed() {
229
+ unmounted() {
231
230
  window.removeEventListener("resize", this.resize);
232
231
  },
233
232
  methods: {
234
233
  resize() {
235
- this.showText =
236
- window.innerWidth > TEXT_BREAKPOINT_WIDTH(this.$i18n.locale);
234
+ this.showText = window.innerWidth > TEXT_BREAKPOINT_WIDTH;
237
235
  },
238
236
  search() {
239
237
  this.$emit("search");
@@ -11,10 +11,10 @@
11
11
  editAnnotation &&
12
12
  editAnnotation.id === annotation.id &&
13
13
  'error-editing',
14
- isAnnotationBeingEdited && 'clicked-ann',
14
+ isSpanBeingEdited && 'clicked-ann',
15
15
  ]"
16
16
  role="textbox"
17
- :contenteditable="isAnnotationBeingEdited"
17
+ :contenteditable="isSpanBeingEdited"
18
18
  @click="handleEditAnnotation"
19
19
  @paste="handlePaste"
20
20
  @keypress.enter="saveAnnotationChanges"
@@ -61,11 +61,7 @@ export default {
61
61
  };
62
62
  },
63
63
  computed: {
64
- ...mapGetters("document", [
65
- "isAnnotationInEditMode",
66
- "pageAtIndex",
67
- "isDocumentReviewed",
68
- ]),
64
+ ...mapGetters("document", ["isAnnotationInEditMode", "isDocumentReviewed"]),
69
65
  ...mapGetters("display", ["bboxToRect"]),
70
66
  ...mapState("document", [
71
67
  "editAnnotation",
@@ -74,19 +70,17 @@ export default {
74
70
  "newAcceptedAnnotations",
75
71
  "showActionError",
76
72
  ]),
77
- isAnnotationBeingEdited() {
73
+ isSpanBeingEdited() {
78
74
  return this.isAnnotationInEditMode(this.annotation.id, this.spanIndex);
79
75
  },
76
+ isAnnotationBeingEdited() {
77
+ return (
78
+ this.editAnnotation && this.annotation.id === this.editAnnotation.id
79
+ );
80
+ },
80
81
  },
81
82
 
82
83
  watch: {
83
- isAnnotationBeingEdited(newState, oldState) {
84
- // verify if new annotation in edit mode is not this one and if this
85
- // one was selected before so we set the state to the previous one (like a cancel)
86
- if (!newState && oldState) {
87
- this.handleCancel();
88
- }
89
- },
90
84
  span() {
91
85
  // span content changed, ex. from click on entity
92
86
  this.setText(this.span.offset_string);
@@ -110,10 +104,15 @@ export default {
110
104
  if (
111
105
  !this.publicView &&
112
106
  !this.isDocumentReviewed &&
113
- !this.isAnnotationBeingEdited &&
107
+ !this.isSpanBeingEdited &&
114
108
  !this.isLoading
115
109
  ) {
116
- this.$store.dispatch("selection/selectElement", this.annotation.id);
110
+ if (!this.isAnnotationBeingEdited) {
111
+ this.$store.dispatch(
112
+ "selection/setSpanSelection",
113
+ this.annotation.span
114
+ );
115
+ }
117
116
 
118
117
  this.$store
119
118
  .dispatch("document/setEditAnnotation", {
@@ -125,44 +124,18 @@ export default {
125
124
  pageNumber: this.span.page_index + 1,
126
125
  })
127
126
  .then(() => {
128
- this.$refs.contentEditable.focus();
127
+ if (this.$refs.contentEditable) {
128
+ this.$refs.contentEditable.focus();
129
+ }
129
130
  })
130
131
  .catch((error) => {
131
132
  console.log(error);
132
133
  });
133
-
134
- const page = this.pageAtIndex(this.span.page_index);
135
- if (page) {
136
- const { x, y, width, height } = this.bboxToRect(page, this.span);
137
-
138
- const selection = {
139
- start: {
140
- x,
141
- y,
142
- },
143
- end: {
144
- x: x + width,
145
- y: y + height,
146
- },
147
- pageNumber: page.number,
148
- custom: false,
149
- };
150
-
151
- // check if this is part of a group of spans to show the whole bounding box as a placeholder
152
- if (
153
- this.annotation.selection_bbox &&
154
- this.annotation.span.length > 1
155
- ) {
156
- selection.placeholderBox = this.bboxToRect(
157
- page,
158
- this.annotation.selection_bbox
159
- );
160
- }
161
-
162
- this.$store.dispatch("selection/setSelection", {
163
- selection,
164
- span: this.span,
165
- });
134
+ // check if this is part of a group of spans to show the whole bounding box as a placeholder
135
+ if (this.annotation.selection_bbox && this.annotation.span.length > 1) {
136
+ this.$store.dispatch("selection/setPlaceholderSelection", [
137
+ this.annotation.selection_bbox,
138
+ ]);
166
139
  }
167
140
  }
168
141
  },
@@ -173,7 +146,7 @@ export default {
173
146
  this.$refs.contentEditable.blur();
174
147
  }
175
148
 
176
- this.$store.dispatch("selection/setSelectedEntities", null);
149
+ this.$store.dispatch("selection/setSpanSelection", null);
177
150
  },
178
151
  handlePaste(event) {
179
152
  // TODO: modify to only paste plain text
@@ -15,14 +15,13 @@
15
15
  >
16
16
  <div class="annotations-width-slider">
17
17
  <b-slider
18
- :value="labelWidth"
18
+ v-model="labelContainerWidth"
19
19
  type="is-move"
20
20
  :min="20"
21
21
  :max="80"
22
22
  :custom-formatter="(val) => `${$t('label_size')} ${val}%`"
23
23
  class="is-full-height show-hover show-line"
24
24
  :disabled="isAnnotationInEditMode()"
25
- @input="setLabelWidth"
26
25
  />
27
26
  </div>
28
27
  <div
@@ -98,7 +97,12 @@
98
97
 
99
98
  <div class="annotation-row-right" :style="`width:${annotationWidth}%`">
100
99
  <div class="annotation-content">
101
- <div v-if="annotation" class="annotation-items">
100
+ <div
101
+ v-if="isAnnotationInEditMode(currentAnnotationId()) && spanLoading"
102
+ >
103
+ <b-icon style="width: 16px" icon="spinner" class="fa-spin" />
104
+ </div>
105
+ <div v-else-if="annotation" class="annotation-items">
102
106
  <b-checkbox
103
107
  v-if="annotation.metadata && annotation.metadata.checkbox"
104
108
  v-model="isChecked"
@@ -129,7 +133,8 @@
129
133
  <div v-else>
130
134
  <div
131
135
  v-if="
132
- spanSelection && isAnnotationInEditMode(currentAnnotationId())
136
+ spanSelection.length > 0 &&
137
+ isAnnotationInEditMode(currentAnnotationId())
133
138
  "
134
139
  >
135
140
  <EmptyAnnotation
@@ -244,6 +249,7 @@ export default {
244
249
  checkboxDefaultValue: checkboxValue,
245
250
  isCheckboxAvailable: false,
246
251
  isChecked: checkboxValue,
252
+ labelContainerWidth: 0,
247
253
  };
248
254
  },
249
255
  computed: {
@@ -261,8 +267,8 @@ export default {
261
267
  ]),
262
268
  ...mapState("selection", [
263
269
  "spanSelection",
264
- "elementSelected",
265
270
  "selectedEntities",
271
+ "spanLoading",
266
272
  ]),
267
273
  ...mapState("display", ["labelWidth", "annotationWidth"]),
268
274
  ...mapState("project", ["showAnnotationTranslations"]),
@@ -319,6 +325,12 @@ export default {
319
325
  },
320
326
  },
321
327
  watch: {
328
+ labelWidth(width) {
329
+ this.labelContainerWidth = width;
330
+ },
331
+ labelContainerWidth(width) {
332
+ this.setLabelWidth(width);
333
+ },
322
334
  annotationId(newAnnotationId) {
323
335
  this.checkAnnotationSelection(newAnnotationId);
324
336
  },
@@ -383,6 +395,7 @@ export default {
383
395
  },
384
396
  mounted() {
385
397
  this.checkAnnotationSelection(this.annotationId);
398
+ this.labelContainerWidth = this.labelWidth;
386
399
  },
387
400
  methods: {
388
401
  ...mapActions("display", ["setLabelWidth"]),
@@ -438,9 +451,10 @@ export default {
438
451
 
439
452
  if (this.annotation && this.annotation.id) return this.annotation.id;
440
453
 
441
- const setId = this.annotationSet
442
- ? this.annotationSet.id
443
- : this.labelSet.id;
454
+ const setId =
455
+ this.annotationSet && this.annotationSet.id
456
+ ? this.annotationSet.id
457
+ : this.labelSet.id;
444
458
 
445
459
  return `${setId}_${this.label.id}`;
446
460
  },
@@ -573,11 +587,8 @@ export default {
573
587
  } else {
574
588
  if (!this.isAnnotationInEditMode(this.currentAnnotationId())) return;
575
589
 
576
- return (
577
- this.elementSelected === this.currentAnnotationId() &&
578
- this.spanSelection &&
579
- Array.isArray(this.spanSelection)
580
- );
590
+ // check if spans are selected
591
+ return this.spanSelection && this.spanSelection.length > 0;
581
592
  }
582
593
  },
583
594
  handleMissingAnnotation() {
@@ -678,44 +689,92 @@ export default {
678
689
  this.isLoading = true;
679
690
  }, 100);
680
691
 
681
- let updatedString; // what will be sent to the API
682
- let storeAction; // if it will be 'delete' or 'patch'
692
+ // check if annotation set was changed
693
+ if (
694
+ (this.editAnnotation.annotationSet &&
695
+ (this.editAnnotation.annotationSet.id !== this.annotationSet.id ||
696
+ (this.editAnnotation.annotationSet.id == null &&
697
+ this.labelSet.id !== this.editAnnotation.labelSet.id))) ||
698
+ (this.editAnnotation.label &&
699
+ this.editAnnotation.label.id !== this.label.id)
700
+ ) {
701
+ // first delete annotation, then create new one
702
+ this.$store
703
+ .dispatch("document/deleteAnnotation", {
704
+ annotationId: this.annotation.id,
705
+ })
706
+ .then(() => {
707
+ const annotationToCreate = {
708
+ document: this.documentId,
709
+ span: spans,
710
+ label: this.editAnnotation.label.id,
711
+ is_correct: true,
712
+ revised: false,
713
+ };
714
+
715
+ if (this.editAnnotation.annotationSet.id) {
716
+ annotationToCreate.annotation_set =
717
+ this.editAnnotation.annotationSet.id;
718
+ } else {
719
+ annotationToCreate.label_set = this.editAnnotation.labelSet.id;
720
+ }
683
721
 
684
- // Verify if we delete the entire Annotation or a part of the text
685
- if (isToDecline || spans.length === 0) {
686
- storeAction = "document/deleteAnnotation";
722
+ this.$store
723
+ .dispatch("document/createAnnotation", {
724
+ annotation: annotationToCreate,
725
+ })
726
+ .catch((error) => {
727
+ this.$store.dispatch("document/createErrorMessage", {
728
+ error,
729
+ serverErrorMessage: this.$t("server_error"),
730
+ defaultErrorMessage: this.$t("error_creating_annotation"),
731
+ });
732
+ })
733
+ .finally(() => {
734
+ this.$store.dispatch("document/resetEditAnnotation");
735
+ this.$store.dispatch("selection/disableSelection");
736
+ this.loading = false;
737
+ });
738
+ });
687
739
  } else {
688
- // Editing the Annotation
689
- // Deleting part of multi-line Annotation
690
- storeAction = "document/updateAnnotation";
740
+ let updatedString; // what will be sent to the API
741
+ let storeAction; // if it will be 'delete' or 'patch'
691
742
 
692
- updatedString = {
693
- is_correct: true,
694
- revised: true,
695
- span: spans,
696
- };
697
- }
743
+ // Verify if we delete the entire Annotation or a part of the text
744
+ if (isToDecline || spans.length === 0) {
745
+ storeAction = "document/deleteAnnotation";
746
+ } else {
747
+ // Editing the Annotation
748
+ // Deleting part of multi-line Annotation
749
+ storeAction = "document/updateAnnotation";
750
+
751
+ updatedString = {
752
+ is_correct: true,
753
+ revised: true,
754
+ span: spans,
755
+ };
756
+ }
698
757
 
699
- // Send to the store for the http patch/delete request
700
- this.$store
701
- .dispatch(storeAction, {
702
- updatedValues: updatedString,
703
- annotationId: this.annotation.id,
704
- annotationSet: this.annotationSet,
705
- })
706
- .catch((error) => {
707
- this.$store.dispatch("document/createErrorMessage", {
708
- error,
709
- serverErrorMessage: this.$t("server_error"),
710
- defaultErrorMessage: this.$t("edit_error"),
758
+ // Send to the store for the http patch/delete request
759
+ this.$store
760
+ .dispatch(storeAction, {
761
+ updatedValues: updatedString,
762
+ annotationId: this.annotation.id,
763
+ annotationSet: this.annotationSet,
764
+ })
765
+ .catch((error) => {
766
+ this.$store.dispatch("document/createErrorMessage", {
767
+ error,
768
+ serverErrorMessage: this.$t("server_error"),
769
+ defaultErrorMessage: this.$t("edit_error"),
770
+ });
771
+ })
772
+ .finally(() => {
773
+ this.$store.dispatch("document/resetEditAnnotation");
774
+ this.$store.dispatch("selection/disableSelection");
775
+ this.isLoading = false;
711
776
  });
712
- })
713
- .finally(() => {
714
- this.$store.dispatch("document/resetEditAnnotation");
715
- this.$store.dispatch("selection/disableSelection");
716
- this.$store.dispatch("selection/setSelectedEntities", null);
717
- this.isLoading = false;
718
- });
777
+ }
719
778
  },
720
779
  saveEmptyAnnotationChanges() {
721
780
  let annotationToCreate;
@@ -760,10 +819,7 @@ export default {
760
819
  },
761
820
  handleCancelButton() {
762
821
  this.$store.dispatch("document/resetEditAnnotation");
763
- if (this.elementSelected) {
764
- this.$store.dispatch("selection/disableSelection");
765
- this.$store.dispatch("selection/setSelectedEntities", null);
766
- }
822
+ this.$store.dispatch("selection/disableSelection");
767
823
  this.isLoading = false;
768
824
  },
769
825
  enableLoading(annotations) {
@@ -105,7 +105,10 @@
105
105
  </div>
106
106
  </div>
107
107
 
108
- <b-collapse :open="isAccordionOpen(annotationSet)">
108
+ <b-collapse
109
+ :model-value="isAccordionOpen(annotationSet)"
110
+ animation="slide"
111
+ >
109
112
  <div
110
113
  v-if="annotationSet.labels.length > 0"
111
114
  class="annotation-sets-list"
@@ -194,6 +197,7 @@ export default {
194
197
 
195
198
  computed: {
196
199
  ...mapState("display", ["showAnnSetTable", "showBranding"]),
200
+ ...mapState("edit", ["editMode"]),
197
201
  ...mapState("document", [
198
202
  "annotationSets",
199
203
  "documentId",
@@ -221,7 +225,7 @@ export default {
221
225
  return this.editAnnotation && this.editAnnotation.id;
222
226
  },
223
227
  isDocumentEditable() {
224
- return !this.publicView && !this.isDocumentReviewed;
228
+ return !this.publicView && !this.isDocumentReviewed && !this.editMode;
225
229
  },
226
230
  },
227
231
  watch: {
@@ -273,7 +277,7 @@ export default {
273
277
  this.loadAccordions(this.getAnnotationsFiltered.annotationSets);
274
278
  }
275
279
  },
276
- destroyed() {
280
+ unmounted() {
277
281
  window.removeEventListener("keydown", this.keyDownHandler);
278
282
  },
279
283
  methods: {
@@ -404,9 +408,11 @@ export default {
404
408
  },
405
409
 
406
410
  createArray(className) {
407
- return Array.from(
408
- this.$refs.annotationList.getElementsByClassName(className)
409
- );
411
+ if (this.$refs.annotationList) {
412
+ return Array.from(
413
+ this.$refs.annotationList.getElementsByClassName(className)
414
+ );
415
+ }
410
416
  },
411
417
 
412
418
  keyDownHandler(event) {
@@ -1,39 +1,33 @@
1
1
  <template>
2
- <div class="empty-annotation">
2
+ <div v-if="!publicView && !isDocumentReviewed" class="empty-annotation">
3
3
  <span
4
- v-if="!publicView && !isDocumentReviewed"
5
4
  :id="emptyAnnotationId()"
6
5
  ref="emptyAnnotation"
7
6
  :class="[
8
7
  'annotation-value',
9
- showActionError &&
10
- editAnnotation &&
11
- editAnnotation.id === emptyAnnotationId() &&
12
- 'error-editing',
13
- !isEmptyAnnotationEditable() && !isMissingAnnotation && 'label-empty',
8
+ showActionError && isAnnotationBeingEdited() && 'error-editing',
14
9
  isAnnotationBeingEdited() && 'clicked-ann',
15
10
  isMissingAnnotation && 'missing-annotation',
16
11
  !isMissingAnnotation && 'keyboard-nav',
17
12
  ]"
18
- :contenteditable="isEmptyAnnotationEditable()"
13
+ :contenteditable="isAnnotationBeingEdited()"
19
14
  @keypress.enter="saveEmptyAnnotationChanges"
20
15
  @click="handleEditEmptyAnnotation"
21
16
  @focus="handleEditEmptyAnnotation"
22
17
  ><!-- eslint-disable vue/no-v-html -->
23
18
  <span
24
19
  v-if="isFindingAnnotation"
20
+ class="label-empty-clicked"
25
21
  v-html="$t('draw_box_document', { label_name: label.name })"
26
22
  >
27
23
  </span>
28
24
  <span v-else-if="isMissingAnnotation" class="not-found-text">
29
25
  {{ $t("missing_from_document") }}
30
26
  </span>
31
- <span
32
- v-else-if="span && span.offset_string && isEmptyAnnotationEditable()"
33
- >
27
+ <span v-else-if="span && span.offset_string">
34
28
  {{ span.offset_string }}
35
29
  </span>
36
- <span v-else>
30
+ <span v-else class="label-empty">
37
31
  {{ $t("no_data_found") }}
38
32
  </span>
39
33
  <!--eslint-enable-->
@@ -42,7 +36,6 @@
42
36
  </template>
43
37
  <script>
44
38
  import { mapState, mapGetters } from "vuex";
45
- import { isElementArray } from "../../utils/utils";
46
39
 
47
40
  /**
48
41
  * This component is responsible for managing empty annotations (labels with no annotations).
@@ -80,7 +73,7 @@ export default {
80
73
  },
81
74
  computed: {
82
75
  ...mapGetters("document", ["isAnnotationInEditMode", "isDocumentReviewed"]),
83
- ...mapState("selection", ["spanSelection", "elementSelected"]),
76
+ ...mapState("selection", ["spanSelection"]),
84
77
  ...mapState("document", [
85
78
  "editAnnotation",
86
79
  "publicView",
@@ -97,17 +90,17 @@ export default {
97
90
 
98
91
  watch: {
99
92
  span(newValue) {
100
- if (this.elementSelected === this.emptyAnnotationId() && newValue) {
101
- if (isElementArray(newValue))
102
- newValue.map((span) => {
103
- if (span.offset_string) {
104
- span.offset_string =
105
- this.$refs.emptyAnnotation.textContent.trim();
106
- span.offset_string_original =
107
- this.$refs.emptyAnnotation.textContent.trim();
108
- }
109
- });
110
- }
93
+ // if (newValue) {
94
+ // if (isElementArray(newValue))
95
+ // newValue.map((span) => {
96
+ // if (span.offset_string) {
97
+ // span.offset_string =
98
+ // this.$refs.emptyAnnotation.textContent.trim();
99
+ // span.offset_string_original =
100
+ // this.$refs.emptyAnnotation.textContent.trim();
101
+ // }
102
+ // });
103
+ // }
111
104
  },
112
105
  spanSelection(newValue) {
113
106
  if (!newValue) return;
@@ -123,59 +116,27 @@ export default {
123
116
  methods: {
124
117
  emptyAnnotationId() {
125
118
  if ((!this.annotationSet && !this.labelSet) || !this.label) return;
126
-
127
- const id = this.annotationSet ? this.annotationSet.id : this.labelSet.id;
119
+ const id =
120
+ this.annotationSet && this.annotationSet.id != null
121
+ ? this.annotationSet.id
122
+ : this.labelSet.id;
128
123
  return `${id}_${this.label.id}`;
129
124
  },
130
125
  isAnnotationBeingEdited() {
131
126
  return this.isAnnotationInEditMode(this.emptyAnnotationId());
132
127
  },
133
128
  handleEditEmptyAnnotation() {
134
- if (
135
- this.publicView ||
136
- this.isDocumentReviewed ||
137
- this.isMissingAnnotation
138
- )
139
- return;
140
-
141
- if (
142
- !this.publicView &&
143
- !this.isDocumentReviewed &&
144
- this.elementSelected !== this.emptyAnnotationId()
145
- ) {
146
- this.$store.dispatch("selection/disableSelection");
147
- this.$store.dispatch("selection/setSelectedEntities", null);
148
- this.$store.dispatch(
149
- "selection/selectElement",
150
- this.emptyAnnotationId()
151
- );
152
- this.$store.dispatch("document/setEditAnnotation", {
153
- id: this.emptyAnnotationId(),
154
- index: this.spanIndex,
155
- label: this.label,
156
- labelSet: this.labelSet,
157
- annotationSet: this.annotationSet,
158
- });
159
- }
160
- },
161
- isEmptyAnnotationEditable() {
162
- if (
163
- (this.spanSelection && this.spanSelection[this.spanIndex] === 0) ||
164
- this.isMissingAnnotation
165
- ) {
166
- return false;
167
- } else {
168
- return (
169
- this.elementSelected === this.emptyAnnotationId() &&
170
- this.spanSelection &&
171
- this.spanSelection[this.spanIndex] &&
172
- this.spanSelection[this.spanIndex].offset_string != null
173
- );
174
- }
129
+ if (this.isMissingAnnotation) return;
130
+ this.$store.dispatch("selection/disableSelection");
131
+ this.$store.dispatch("document/setEditAnnotation", {
132
+ id: this.emptyAnnotationId(),
133
+ index: this.spanIndex,
134
+ label: this.label,
135
+ labelSet: this.labelSet,
136
+ annotationSet: this.annotationSet,
137
+ });
175
138
  },
176
139
  saveEmptyAnnotationChanges(event) {
177
- if (this.publicView || this.isDocumentReviewed) return;
178
-
179
140
  if (event) {
180
141
  event.preventDefault();
181
142
  }