@konfuzio/document-validation-ui 0.1.25-dev.0 → 0.1.25-dev.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.1.25-dev.0",
3
+ "version": "0.1.25-dev.2",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -198,6 +198,7 @@ export default {
198
198
  y1: this.span.y1,
199
199
  start_offset: this.span.start_offset,
200
200
  end_offset: this.span.end_offset,
201
+ is_custom: this.span.offset_string !== annotationText,
201
202
  };
202
203
  },
203
204
  },
@@ -527,6 +527,7 @@ export default {
527
527
  ))
528
528
  ) {
529
529
  let spans = [];
530
+ let showAiWarning = false;
530
531
 
531
532
  if (!decline) {
532
533
  Object.keys(this.$refs).forEach((ref) => {
@@ -539,13 +540,24 @@ export default {
539
540
 
540
541
  // only add span if it's not null (offset_string not empty)
541
542
  if (span) {
543
+ showAiWarning = span.is_custom;
542
544
  spans.push(span);
543
545
  }
544
546
  }
545
547
  });
546
548
  }
547
549
 
548
- this.saveAnnotationChanges(spans, decline);
550
+ if (showAiWarning) {
551
+ this.$buefy.dialog.confirm({
552
+ container: "#app .dv-ui-app-container",
553
+ canCancel: "button",
554
+ message: this.$t("edit_ann_content_warning"),
555
+ onConfirm: () => this.saveAnnotationChanges(spans, decline),
556
+ onCancel: () => this.handleCancelButton(),
557
+ });
558
+ } else {
559
+ this.saveAnnotationChanges(spans, decline);
560
+ }
549
561
  } else if (
550
562
  (!this.annotation || this.isNegative(this.annotation)) &&
551
563
  this.isAnnotationInEditMode(this.annotationId())
@@ -191,7 +191,6 @@ export default {
191
191
  "splittingSuggestions",
192
192
  "sidebarAnnotationSelected",
193
193
  ]),
194
- ...mapGetters("category", ["category"]),
195
194
  ...mapGetters("document", [
196
195
  "numberOfAnnotationSetGroup",
197
196
  "emptyLabels",
@@ -81,7 +81,7 @@
81
81
  :key="'ann' + annotation.id + '-' + index"
82
82
  :config="annotationRect(bbox, annotation.id)"
83
83
  @click="handleFocusedAnnotation(annotation)"
84
- @mouseenter="onElementEnter"
84
+ @mouseenter="onElementEnter(annotation, bbox)"
85
85
  @mouseleave="onElementLeave"
86
86
  />
87
87
  </template>
@@ -310,6 +310,7 @@ export default {
310
310
  "isDocumentReadyToBeReviewed",
311
311
  "entitiesOnSelection",
312
312
  "isDocumentReviewed",
313
+ "labelOfAnnotation",
313
314
  ]),
314
315
  },
315
316
  watch: {
@@ -477,7 +478,7 @@ export default {
477
478
  }
478
479
  },
479
480
 
480
- onElementEnter() {
481
+ onElementEnter(annotation = null, span = null) {
481
482
  if (
482
483
  !this.categorizeModalIsActive &&
483
484
  !this.publicView &&
@@ -486,10 +487,23 @@ export default {
486
487
  ) {
487
488
  this.$refs.stage.$el.style.cursor = "pointer";
488
489
  }
490
+
491
+ if (annotation) {
492
+ const label = this.labelOfAnnotation(annotation);
493
+ if (label) {
494
+ this.$store.dispatch("document/setDocumentAnnotationSelected", {
495
+ annotation,
496
+ label,
497
+ span,
498
+ scrollTo: false,
499
+ });
500
+ }
501
+ }
489
502
  },
490
503
 
491
504
  onElementLeave() {
492
505
  this.$refs.stage.$el.style.cursor = "inherit";
506
+ this.$store.dispatch("document/disableDocumentAnnotationSelected");
493
507
  },
494
508
 
495
509
  /**
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div
3
- v-if="annotation"
3
+ v-if="annotation && !hide"
4
4
  class="annotation-popup small"
5
5
  :style="{ left: `${left}px`, top: `${top}px` }"
6
6
  >
@@ -101,15 +101,15 @@
101
101
  <b-button
102
102
  type="is-text"
103
103
  class="cancel-button popup-button primary-button"
104
- :label="$t('cancel')"
104
+ :label="$t('hide')"
105
105
  :disabled="loading"
106
- @click.prevent="close"
106
+ @click.prevent="hide = true"
107
107
  />
108
108
  <b-button
109
109
  type="is-primary"
110
110
  class="popup-button primary-button"
111
111
  :label="$t('save')"
112
- :disabled="loading || !spanSelection || !selectedLabel"
112
+ :disabled="loading || !spanSelection || !selectedLabel || !wasChanged"
113
113
  @click.prevent="save"
114
114
  />
115
115
  </div>
@@ -155,6 +155,7 @@ export default {
155
155
  loading: false,
156
156
  isAnnSetModalShowing: false,
157
157
  setsList: [],
158
+ hide: false,
158
159
  };
159
160
  },
160
161
  computed: {
@@ -195,12 +196,19 @@ export default {
195
196
  return left > 0 ? left : 0;
196
197
  }
197
198
  },
199
+ wasChanged() {
200
+ return (
201
+ this.editAnnotation.annotationSet.id !== this.selectedSet.id ||
202
+ this.editAnnotation.label.id !== this.selectedLabel.id
203
+ );
204
+ },
198
205
  },
199
206
  watch: {
200
207
  selectedSet(newValue) {
201
208
  this.labelsFiltered = this.labelsFilteredForAnnotationCreation(newValue);
202
209
  },
203
210
  editAnnotation() {
211
+ this.hide = false;
204
212
  this.loadInfo();
205
213
  },
206
214
  },
@@ -247,10 +255,7 @@ export default {
247
255
  async save() {
248
256
  this.loading = true;
249
257
 
250
- if (
251
- this.editAnnotation.labelSet.id !== this.selectedSet.id ||
252
- this.editAnnotation.label.id !== this.selectedLabel.id
253
- ) {
258
+ if (this.wasChanged) {
254
259
  // first delete annotation, then create new one
255
260
  await this.$store
256
261
  .dispatch("document/deleteAnnotation", {
@@ -20,6 +20,7 @@
20
20
  "save": "Speichern",
21
21
  "autosaving": "Automatisches Speichern...",
22
22
  "saved": "Gespeichert",
23
+ "hide": "Verstecken",
23
24
  "not_saved": "Konnte nicht gespeichert werden. Versuchen Sie es noch einmal",
24
25
  "handover": "Übergeben",
25
26
  "handover_document": "Übergabedokument",
@@ -155,5 +156,6 @@
155
156
  "document_details": "Einzelheiten",
156
157
  "human_feedback_needed": "Menschliches Feedback erforderlich",
157
158
  "label_missing_annotations": "Fehlende Annotationen",
158
- "accepted_annotations": "Akzeptierte Annotationen"
159
+ "accepted_annotations": "Akzeptierte Annotationen",
160
+ "edit_ann_content_warning": "Wenn Sie den Text ändern, kann die KI diese Annotation nicht verwenden. Dadurch werden auch die Trainingsdaten ungültig. Versuchen Sie, die Auswahl zu verändern, um den Text zu erfassen,bevor Sie ihn manuell hinzufügen, oder drücken Sie OK, um trotzdem fortzufahren."
159
161
  }
@@ -21,6 +21,7 @@
21
21
  "details": "Details",
22
22
  "autosaving": "Auto saving...",
23
23
  "saved": "Saved",
24
+ "hide": "Hide",
24
25
  "not_saved": "Could not save. Try again",
25
26
  "handover": "Handover",
26
27
  "handover_document": "Handover document",
@@ -156,5 +157,6 @@
156
157
  "document_details": "Details",
157
158
  "human_feedback_needed": "Human Feedback needed",
158
159
  "label_missing_annotations": "Missing Annotations",
159
- "accepted_annotations": "Accepted Annotations"
160
+ "accepted_annotations": "Accepted Annotations",
161
+ "edit_ann_content_warning": "If you change the text, the AI cannot use this annotation. You will also invalidate the training data. Try to change the selection to capture the text before adding it manually, or press OK to continue anyway."
160
162
  }
@@ -20,6 +20,7 @@
20
20
  "save": "Guardar",
21
21
  "autosaving": "Auto guardando...",
22
22
  "saved": "Guardado",
23
+ "hide": "Ocultar",
23
24
  "not_saved": "No se pudo guardar. Inténtelo de nuevo.",
24
25
  "handover": "Asignar",
25
26
  "handover_document": "Asignar documento",
@@ -155,5 +156,6 @@
155
156
  "document_details": "Detalles",
156
157
  "human_feedback_needed": "Necesita feedback humano",
157
158
  "label_missing_annotations": "Anotaciones faltantes",
158
- "accepted_annotations": "Anotaciones aceptadas"
159
+ "accepted_annotations": "Anotaciones aceptadas",
160
+ "edit_ann_content_warning": "Si cambia el texto, la IA no puede utilizar esta anotación. También invalidarás los datos del entrenamiento. Intente cambiar la selección para capturar el texto antes de agregarlo manualmente, o presione OK para continuar de todos modos."
159
161
  }
@@ -269,6 +269,28 @@ const getters = {
269
269
  return foundAnnotationSet;
270
270
  },
271
271
 
272
+ /* Get label for a given annotation */
273
+ labelOfAnnotation: (state) => (annotationToFind) => {
274
+ let foundLabel = null;
275
+ state.annotationSets.forEach((annotationSet) => {
276
+ annotationSet.labels.forEach((label) => {
277
+ label.annotations.forEach((annotation) => {
278
+ if (annotation.id === annotationToFind.id) {
279
+ foundLabel = label;
280
+ return;
281
+ }
282
+ });
283
+ if (foundLabel) {
284
+ return;
285
+ }
286
+ });
287
+ if (foundLabel) {
288
+ return;
289
+ }
290
+ });
291
+ return foundLabel;
292
+ },
293
+
272
294
  /* Process annotations and extract labels and sets */
273
295
  processAnnotationSets:
274
296
  (state, getters) =>