@konfuzio/document-validation-ui 0.1.48 → 0.1.49-dev.1

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.
@@ -429,7 +429,7 @@ const getters = {
429
429
  },
430
430
 
431
431
  /* Process annotations and extract labels and sets */
432
- processAnnotationSets: (_, getters) => (annotationSets) => {
432
+ processAnnotationSets: (state, getters, rootState) => (annotationSets) => {
433
433
  // group annotations for sidebar
434
434
  let annotations = [];
435
435
  let labels = [];
@@ -437,22 +437,30 @@ const getters = {
437
437
  let processedLabels = [];
438
438
 
439
439
  annotationSets.forEach((annotationSet) => {
440
- labels = [];
441
- annotationSet.labels.forEach((label) => {
442
- const labelAnnotations = [];
440
+ // check if empty label sets and env variable set as true
441
+ if (
442
+ !(
443
+ (rootState.display.hideEmptyLabelSets || state.publicView) &&
444
+ annotationSet.id === null
445
+ )
446
+ ) {
447
+ labels = [];
448
+ annotationSet.labels.forEach((label) => {
449
+ const labelAnnotations = [];
443
450
 
444
- // add annotations to the document array
445
- // remove negative annotations
446
- label.annotations.forEach((ann) => {
447
- if (!getters.isNegative(ann)) {
448
- labelAnnotations.push(ann);
449
- }
451
+ // add annotations to the document array
452
+ // remove negative annotations
453
+ label.annotations.forEach((ann) => {
454
+ if (!getters.isNegative(ann)) {
455
+ labelAnnotations.push(ann);
456
+ }
457
+ });
458
+ labels.push({ ...label, annotations: labelAnnotations });
459
+ processedLabels.push(label);
460
+ annotations.push(...labelAnnotations);
450
461
  });
451
- labels.push({ ...label, annotations: labelAnnotations });
452
- processedLabels.push(label);
453
- annotations.push(...labelAnnotations);
454
- });
455
- processedAnnotationSets.push({ ...annotationSet, labels });
462
+ processedAnnotationSets.push({ ...annotationSet, labels });
463
+ }
456
464
  });
457
465
  return {
458
466
  annotationSets: processedAnnotationSets,
@@ -1139,24 +1147,6 @@ const actions = {
1139
1147
  await dispatch("category/fetchCategories", projectId, {
1140
1148
  root: true,
1141
1149
  });
1142
-
1143
- // get list of documents not reviewed
1144
- await dispatch("project/fetchDocumentList", "is_reviewed=false", {
1145
- root: true,
1146
- });
1147
- }
1148
- if (categoryId && rootState.category.createAvailableListOfDocuments) {
1149
- await dispatch(
1150
- "category/createAvailableDocumentsList",
1151
- {
1152
- categoryId,
1153
- user: rootState.project.currentUser.username,
1154
- poll: false,
1155
- },
1156
- {
1157
- root: true,
1158
- }
1159
- );
1160
1150
  }
1161
1151
  }
1162
1152
  if (isRecalculatingAnnotations) {
@@ -6,7 +6,6 @@ const state = {
6
6
  labelSets: null,
7
7
  currentUser: null,
8
8
  documentsListPath: null,
9
- documentsInProject: null,
10
9
  showAnnotationTranslations: false,
11
10
  };
12
11
 
@@ -58,28 +57,41 @@ const actions = {
58
57
  commit("SET_DOCUMENTS_LIST_PATH", path);
59
58
  },
60
59
 
61
- setDocumentsInProject: ({ commit }, documents) => {
62
- commit("SET_DOCUMENTS_IN_PROJECT", documents);
63
- },
64
-
65
60
  setShowAnnotationTranslations: ({ commit }, show) => {
66
61
  commit("SET_SHOW_ANNOTATION_TRANSLATIONS", show);
67
62
  },
68
63
 
69
- fetchDocumentList: ({ commit, state }, parameters) => {
70
- return myImports
71
- .makeGetPaginatedRequest(
72
- `documents/?project=${state.projectId}&${parameters}`,
73
- true
74
- )
75
- .then((results) => {
76
- if (results) {
77
- commit("SET_DOCUMENTS_IN_PROJECT", results);
78
- }
79
- })
80
- .catch((error) => {
81
- console.log(error, "Could not fetch document list from the backend");
82
- });
64
+ fetchDocumentListWithParameters: ({ commit, state }, parameters) => {
65
+ return new Promise((resolve, reject) => {
66
+ myImports
67
+ .makeGetPaginatedRequest(
68
+ `documents/?project=${state.projectId}&${parameters}`,
69
+ true
70
+ )
71
+ .then((results) => {
72
+ resolve(results);
73
+ })
74
+ .catch((error) => {
75
+ reject();
76
+ console.log(error, "Could not fetch document list from the backend");
77
+ });
78
+ });
79
+ },
80
+ fetchDocumentListForNavigation: ({ commit, state }) => {
81
+ return new Promise((resolve, reject) => {
82
+ myImports
83
+ .makeGetPaginatedRequest(
84
+ `documents/?project=${state.projectId}&is_reviewed=false&fields=id`,
85
+ true
86
+ )
87
+ .then((results) => {
88
+ resolve(results);
89
+ })
90
+ .catch((error) => {
91
+ reject();
92
+ console.log(error, "Could not fetch document list from the backend");
93
+ });
94
+ });
83
95
  },
84
96
  };
85
97
 
@@ -96,9 +108,6 @@ const mutations = {
96
108
  SET_DOCUMENTS_LIST_PATH: (state, path) => {
97
109
  state.documentsListPath = path;
98
110
  },
99
- SET_DOCUMENTS_IN_PROJECT: (state, documents) => {
100
- state.documentsInProject = documents;
101
- },
102
111
  SET_SHOW_ANNOTATION_TRANSLATIONS: (state, show) => {
103
112
  state.showAnnotationTranslations = show;
104
113
  },