@konfuzio/document-validation-ui 0.1.30-dev.0 → 0.1.30-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/src/icons.js CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  faTrashArrowUp,
23
23
  faFloppyDisk,
24
24
  faCircleExclamation,
25
+ faLink,
25
26
  } from "@fortawesome/free-solid-svg-icons";
26
27
  import { FontAwesomeIcon as Icons } from "@fortawesome/vue-fontawesome";
27
28
 
@@ -47,7 +48,8 @@ library.add(
47
48
  faSearch,
48
49
  faTrashArrowUp,
49
50
  faFloppyDisk,
50
- faCircleExclamation
51
+ faCircleExclamation,
52
+ faLink
51
53
  );
52
54
 
53
55
  export default Icons;
@@ -157,5 +157,8 @@
157
157
  "human_feedback_needed": "Menschliches Feedback erforderlich",
158
158
  "label_missing_annotations": "Fehlende Annotationen",
159
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."
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.",
161
+ "annotation_deleted": "Diese Annotation wurde gelöscht.",
162
+ "annotation_link": "Kopieren Sie den permanenten Link zu dieser Annotationen",
163
+ "copied": "Kopiert"
161
164
  }
@@ -158,5 +158,8 @@
158
158
  "human_feedback_needed": "Human Feedback needed",
159
159
  "label_missing_annotations": "Missing Annotations",
160
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."
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.",
162
+ "annotation_deleted": "This annotation has been deleted.",
163
+ "annotation_link": "Copy the permanent link to this annotation",
164
+ "copied": "Copied"
162
165
  }
@@ -157,5 +157,8 @@
157
157
  "human_feedback_needed": "Necesita feedback humano",
158
158
  "label_missing_annotations": "Anotaciones faltantes",
159
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."
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.",
161
+ "annotation_deleted": "Esta anotación ha sido eliminada.",
162
+ "annotation_link": "Copia el enlace permanente a esta anotación.",
163
+ "copied": "Copiada"
161
164
  }
@@ -5,6 +5,7 @@ import {
5
5
  getURLQueryParam,
6
6
  navigateToNewDocumentURL,
7
7
  getURLPath,
8
+ setURLAnnotationHash,
8
9
  } from "../utils/utils";
9
10
 
10
11
  const HTTP = myImports.HTTP;
@@ -18,7 +19,8 @@ const state = {
18
19
  annotations: null,
19
20
  labels: [],
20
21
  documentId: process.env.VUE_APP_DOCUMENT_ID,
21
- sidebarAnnotationSelected: null,
22
+ annotationId: null,
23
+ annotationSetId: null,
22
24
  documentAnnotationSelected: null,
23
25
  selectedDocument: null,
24
26
  recalculatingAnnotations: false,
@@ -36,12 +38,22 @@ const state = {
36
38
  splittingSuggestions: null,
37
39
  enableGroupingFeature: true,
38
40
  annotationFilters: {
39
- showFeedbackNeeded: true,
40
- showEmpty: true,
41
- showAccepted: true,
41
+ showFeedbackNeeded:
42
+ window.location.hash === "#unrevised" ||
43
+ window.location.hash === "#possiblyIncorrect" ||
44
+ true,
45
+ showEmpty:
46
+ window.location.hash === "#unrevised" ||
47
+ window.location.hash === "#possiblyIncorrect"
48
+ ? false
49
+ : true,
50
+ showAccepted:
51
+ window.location.hash === "#unrevised" ||
52
+ window.location.hash === "#possiblyIncorrect"
53
+ ? false
54
+ : true,
42
55
  },
43
56
  };
44
-
45
57
  const getters = {
46
58
  /**
47
59
  * Get entities inside a box
@@ -253,12 +265,12 @@ const getters = {
253
265
  },
254
266
 
255
267
  /* Get annotation set for a given annotation */
256
- annotationSetOfAnnotation: (state) => (annotationToFind) => {
268
+ annotationSetOfAnnotation: (state) => (annotationIdToFind) => {
257
269
  let foundAnnotationSet = null;
258
270
  state.annotationSets.forEach((annotationSet) => {
259
271
  annotationSet.labels.forEach((label) => {
260
272
  label.annotations.forEach((annotation) => {
261
- if (annotation.id === annotationToFind.id) {
273
+ if (annotation.id === annotationIdToFind) {
262
274
  foundAnnotationSet = annotationSet;
263
275
  return;
264
276
  }
@@ -527,6 +539,28 @@ const getters = {
527
539
  }
528
540
  },
529
541
 
542
+ isAnnotationInAnnotationSet: (state) => (annotationSet, annotationId) => {
543
+ // Check if the annotation exists in the annotation set
544
+ let exists = false;
545
+ for (let i = 0; i < annotationSet.labels.length; i++) {
546
+ const label = annotationSet.labels[i];
547
+ for (let j = 0; j < label.annotations.length; j++) {
548
+ exists = label.annotations[j].id == annotationId;
549
+ if (exists) {
550
+ break;
551
+ }
552
+ }
553
+ if (exists) {
554
+ break;
555
+ }
556
+ }
557
+ return exists;
558
+ },
559
+
560
+ annotationById: (state) => (annotationId) => {
561
+ return state.annotations.find((ann) => ann.id == annotationId);
562
+ },
563
+
530
564
  // Check if document is ready to be finished
531
565
  isDocumentReadyToFinishReview: (state) => {
532
566
  // check if all annotations are correct
@@ -772,8 +806,12 @@ const actions = {
772
806
  commit("SET_PAGES", []);
773
807
  commit("SET_DOC_ID", id);
774
808
  },
775
- setSidebarAnnotationSelected: ({ commit }, annotation) => {
776
- commit("SET_ANNOTATION_SELECTED", annotation);
809
+ setAnnotationId: ({ commit }, id) => {
810
+ commit("SET_ANNOTATION_ID", id);
811
+ setURLAnnotationHash(id);
812
+ },
813
+ setAnnotationSetId: ({ commit }, id) => {
814
+ commit("SET_ANNOTATION_SET_ID", id);
777
815
  },
778
816
  setAnnotationSets: ({ commit }, annotationSets) => {
779
817
  commit("SET_ANNOTATION_SETS", annotationSets);
@@ -1018,6 +1056,9 @@ const actions = {
1018
1056
  }
1019
1057
  } else {
1020
1058
  commit("ADD_ANNOTATION", response.data);
1059
+ if (response.data && response.data.id) {
1060
+ dispatch("setAnnotationId", response.data.id);
1061
+ }
1021
1062
  if (negativeAnnotationId) {
1022
1063
  commit("DELETE_ANNOTATION", negativeAnnotationId);
1023
1064
  }
@@ -1318,6 +1359,12 @@ const mutations = {
1318
1359
  state.documentId = id;
1319
1360
  }
1320
1361
  },
1362
+ SET_ANNOTATION_ID: (state, id) => {
1363
+ state.annotationId = id;
1364
+ },
1365
+ SET_ANNOTATION_SET_ID: (state, id) => {
1366
+ state.annotationSetId = id;
1367
+ },
1321
1368
  ADD_ANNOTATION: (state, annotation) => {
1322
1369
  state.annotations.push(annotation);
1323
1370
  state.annotationSets.map((annotationSet) => {
@@ -1432,9 +1479,6 @@ const mutations = {
1432
1479
  SET_LABELS: (state, labels) => {
1433
1480
  state.labels = labels;
1434
1481
  },
1435
- SET_ANNOTATION_SELECTED: (state, annotation) => {
1436
- state.sidebarAnnotationSelected = annotation;
1437
- },
1438
1482
  SET_EDIT_ANNOTATION: (state, editAnnotation) => {
1439
1483
  state.editAnnotation = editAnnotation;
1440
1484
  },
@@ -24,6 +24,23 @@ export function getURLPath(value) {
24
24
  return id;
25
25
  }
26
26
 
27
+ export function getURLValueFromHash(value) {
28
+ const hash = window.location.hash;
29
+ if (!hash.includes(`#${value}`)) return;
30
+
31
+ const id = hash.split(`#${value}`)[1].replace("/", "");
32
+
33
+ if (id === "") return;
34
+
35
+ return id;
36
+ }
37
+
38
+ export function setURLAnnotationHash(annotationId) {
39
+ if (annotationId) {
40
+ window.location.hash = `ann${annotationId}`;
41
+ }
42
+ }
43
+
27
44
  export function navigateToNewDocumentURL(oldId, newId) {
28
45
  const url = window.location.href;
29
46
  const newUrl = url.replace(oldId, newId);