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

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.48",
3
+ "version": "0.1.49-dev.0",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -117,6 +117,12 @@ export default {
117
117
  required: false,
118
118
  default: "",
119
119
  },
120
+ // eslint-disable-next-line vue/prop-name-casing
121
+ hide_empty_label_sets: {
122
+ type: String,
123
+ required: false,
124
+ default: "false",
125
+ },
120
126
  },
121
127
  computed: {
122
128
  ...mapState("display", ["pageError"]),
@@ -232,6 +238,13 @@ export default {
232
238
  return null;
233
239
  }
234
240
  },
241
+ hideEmptyLabelSets() {
242
+ if (process.env.VUE_APP_HIDE_EMPTY_LABEL_SETS) {
243
+ return process.env.VUE_APP_HIDE_EMPTY_LABEL_SETS === "true";
244
+ } else {
245
+ return this.hide_empty_label_sets === "true";
246
+ }
247
+ },
235
248
  },
236
249
  async created() {
237
250
  // Sentry config
@@ -279,6 +292,10 @@ export default {
279
292
  // document and project config
280
293
  Promise.all([
281
294
  this.$store.dispatch("display/setDetailsUrl", this.detailsUrl),
295
+ this.$store.dispatch(
296
+ "display/hideEmptyLabelSets",
297
+ this.hideEmptyLabelSets
298
+ ),
282
299
  this.$store.dispatch("document/setDocId", this.documentId),
283
300
  this.$store.dispatch("document/setPublicView", this.isPublicView),
284
301
  this.$store.dispatch("document/setAnnotationId", this.annotationId),
@@ -27,6 +27,7 @@ const state = {
27
27
  pageChangedFromThumbnail: false,
28
28
  showAnnSetTable: null,
29
29
  showChooseLabelSetModal: null,
30
+ hideEmptyLabelSets: false,
30
31
  currentSearch: "",
31
32
  searchEnabled: false,
32
33
  searchResults: [],
@@ -322,6 +323,10 @@ const actions = {
322
323
  commit("SET_SEARCH_LOADING", true);
323
324
  },
324
325
 
326
+ hideEmptyLabelSets({ commit }, value) {
327
+ commit("HIDE_EMPTY_LABEL_SETS", value);
328
+ },
329
+
325
330
  search({ commit, rootState }, query) {
326
331
  // only allow queries that are at least 3 characters long
327
332
  if (query.length >= 3) {
@@ -399,6 +404,9 @@ const mutations = {
399
404
  SET_ANN_SET_TABLE: (state, tableSet) => {
400
405
  state.showAnnSetTable = tableSet;
401
406
  },
407
+ HIDE_EMPTY_LABEL_SETS: (state, hide) => {
408
+ state.hideEmptyLabelSets = hide;
409
+ },
402
410
 
403
411
  TOGGLE_ANN_SET_TABLE: (state, tableSet) => {
404
412
  if (state.showAnnSetTable) {
@@ -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,