@konfuzio/document-validation-ui 0.1.48-dev.1 → 0.1.48-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.48-dev.1",
3
+ "version": "0.1.48-dev.2",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -24,7 +24,9 @@
24
24
  ? `${selectedSet.label_set.name} ${
25
25
  selectedSet.id
26
26
  ? numberOfAnnotationSetGroup(selectedSet)
27
- : `(${$t("new")})`
27
+ : `${numberOfLabelSetGroup(selectedSet.label_set)} (${$t(
28
+ "new"
29
+ )})`
28
30
  }`
29
31
  : $t("select_annotation_set")
30
32
  }}
@@ -33,6 +35,14 @@
33
35
  </span>
34
36
  </b-button>
35
37
  </template>
38
+ <b-button
39
+ type="is-ghost"
40
+ :class="['add-ann-set', 'dropdown-item', 'no-icon-margin']"
41
+ icon-left="plus"
42
+ @click="openAnnotationSetCreation"
43
+ >
44
+ {{ $t("new_ann_set_title") }}
45
+ </b-button>
36
46
  <b-dropdown-item
37
47
  v-for="(set, index) in setsList"
38
48
  :key="`${set.label_set.id}_${index}`"
@@ -41,23 +51,12 @@
41
51
  >
42
52
  <span>{{
43
53
  `${set.label_set.name} ${
44
- set.id ? numberOfAnnotationSetGroup(set) : `(${$t("new")})`
54
+ set.id
55
+ ? numberOfAnnotationSetGroup(set)
56
+ : `${numberOfLabelSetGroup(set.label_set)} (${$t("new")})`
45
57
  }`
46
58
  }}</span>
47
59
  </b-dropdown-item>
48
- <b-button
49
- type="is-ghost"
50
- :class="[
51
- 'add-ann-set',
52
- 'dropdown-item',
53
- 'no-icon-margin',
54
- setsList.length > 0 ? 'has-border' : '',
55
- ]"
56
- icon-left="plus"
57
- @click="openAnnotationSetCreation"
58
- >
59
- {{ $t("new_ann_set_title") }}
60
- </b-button>
61
60
  </b-dropdown>
62
61
  <b-tooltip
63
62
  multilined
@@ -166,6 +165,7 @@ export default {
166
165
  ]),
167
166
  ...mapGetters("document", [
168
167
  "numberOfAnnotationSetGroup",
168
+ "numberOfLabelSetGroup",
169
169
  "labelsFilteredForAnnotationCreation",
170
170
  ]),
171
171
  ...mapGetters("display", ["bboxToRect"]),
@@ -304,12 +304,21 @@ export default {
304
304
  }
305
305
  },
306
306
  chooseLabelSet(labelSet) {
307
+ // check if there's already a new entry for that label set to be created
308
+ const existsIndex = this.setsList.findIndex((set) => {
309
+ return set.id === null && set.label_set.id === labelSet.id;
310
+ });
311
+
307
312
  const newSet = {
308
313
  label_set: labelSet,
309
314
  labels: labelSet.labels,
310
315
  id: null,
311
316
  };
312
- this.setsList.push(newSet);
317
+ if (existsIndex >= 0) {
318
+ this.setsList[existsIndex] = newSet;
319
+ } else {
320
+ this.setsList.unshift(newSet);
321
+ }
313
322
  this.selectedSet = newSet;
314
323
  },
315
324
  openAnnotationSetCreation() {
@@ -323,7 +323,7 @@ export default {
323
323
  if (existsIndex >= 0) {
324
324
  this.setsList[existsIndex] = newSet;
325
325
  } else {
326
- this.setsList.push(newSet);
326
+ this.setsList.unshift(newSet);
327
327
  }
328
328
  this.selectedSet = newSet;
329
329
  },
@@ -563,9 +563,13 @@ const getters = {
563
563
  let returnLabelSets = [];
564
564
  if (state.annotationSets) {
565
565
  state.annotationSets.forEach((annotationSet) => {
566
+ // last validation checks if the label set is already present in list
566
567
  if (
567
- annotationSet.id == null ||
568
- annotationSet.label_set.has_multiple_annotation_sets
568
+ (annotationSet.id == null ||
569
+ annotationSet.label_set.has_multiple_annotation_sets) &&
570
+ !returnLabelSets.find(
571
+ (set) => set.id !== null && set.id === annotationSet.label_set.id
572
+ )
569
573
  ) {
570
574
  const labelSet = { ...annotationSet.label_set };
571
575
  labelSet.labels = [...annotationSet.labels];