@konfuzio/document-validation-ui 0.1.42-dev.0 → 0.1.42

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.
@@ -125,7 +125,6 @@ const margin = 12;
125
125
  const widthOfPopup = 205;
126
126
 
127
127
  import { mapGetters, mapState } from "vuex";
128
- import { MULTI_ANN_TABLE_FEATURE } from "../../constants";
129
128
 
130
129
  export default {
131
130
  props: {
@@ -334,7 +333,6 @@ export default {
334
333
  openAnnotationSetCreation() {
335
334
  this.$store.dispatch("display/showChooseLabelSetModal", {
336
335
  show: true,
337
- isMultipleAnnotations: MULTI_ANN_TABLE_FEATURE,
338
336
  finish: this.chooseLabelSet,
339
337
  });
340
338
  },
@@ -11,6 +11,7 @@
11
11
  :class="[
12
12
  'annotation-dropdown',
13
13
  'no-padding-bottom',
14
+ 'no-padding-top',
14
15
  setsList.length === 0 ? 'no-padding-top' : '',
15
16
  ]"
16
17
  scrollable
@@ -25,7 +26,9 @@
25
26
  ? `${selectedSet.label_set.name} ${
26
27
  selectedSet.id
27
28
  ? numberOfAnnotationSetGroup(selectedSet)
28
- : `(${$t("new")})`
29
+ : `${numberOfLabelSetGroup(selectedSet.label_set)} (${$t(
30
+ "new"
31
+ )})`
29
32
  }`
30
33
  : $t("select_annotation_set")
31
34
  }}
@@ -34,6 +37,14 @@
34
37
  </span>
35
38
  </b-button>
36
39
  </template>
40
+ <b-button
41
+ type="is-ghost"
42
+ :class="['add-ann-set', 'dropdown-item', 'no-icon-margin']"
43
+ icon-left="plus"
44
+ @click="openAnnotationSetCreation"
45
+ >
46
+ {{ $t("new_ann_set_title") }}
47
+ </b-button>
37
48
  <b-dropdown-item
38
49
  v-for="(set, index) in setsList"
39
50
  :key="`${set.label_set.id}_${index}`"
@@ -42,23 +53,12 @@
42
53
  >
43
54
  <span>{{
44
55
  `${set.label_set.name} ${
45
- set.id ? numberOfAnnotationSetGroup(set) : `(${$t("new")})`
56
+ set.id
57
+ ? numberOfAnnotationSetGroup(set)
58
+ : `${numberOfLabelSetGroup(set.label_set)} (${$t("new")})`
46
59
  }`
47
60
  }}</span>
48
61
  </b-dropdown-item>
49
- <b-button
50
- type="is-ghost"
51
- :class="[
52
- 'add-ann-set',
53
- 'dropdown-item',
54
- 'no-icon-margin',
55
- setsList.length > 0 ? 'has-border' : '',
56
- ]"
57
- icon-left="plus"
58
- @click="openAnnotationSetCreation"
59
- >
60
- {{ $t("new_ann_set_title") }}
61
- </b-button>
62
62
  </b-dropdown>
63
63
  <b-tooltip
64
64
  multilined
@@ -133,7 +133,6 @@ const margin = 12;
133
133
  const widthOfPopup = 205;
134
134
 
135
135
  import { mapGetters, mapState } from "vuex";
136
- import { MULTI_ANN_TABLE_FEATURE } from "../../constants";
137
136
 
138
137
  export default {
139
138
  props: {
@@ -168,6 +167,7 @@ export default {
168
167
  ...mapState("document", ["annotationSets", "documentId"]),
169
168
  ...mapGetters("document", [
170
169
  "numberOfAnnotationSetGroup",
170
+ "numberOfLabelSetGroup",
171
171
  "labelsFilteredForAnnotationCreation",
172
172
  "isNegative",
173
173
  ]),
@@ -231,6 +231,9 @@ export default {
231
231
  selectedSet(newValue) {
232
232
  this.selectedLabel = null;
233
233
  this.labels = this.labelsFilteredForAnnotationCreation(newValue);
234
+ if (this.labels.length === 1) {
235
+ this.selectedLabel = this.labels[0];
236
+ }
234
237
  },
235
238
  },
236
239
  mounted() {
@@ -337,7 +340,6 @@ export default {
337
340
  openAnnotationSetCreation() {
338
341
  this.$store.dispatch("display/showChooseLabelSetModal", {
339
342
  show: true,
340
- isMultipleAnnotations: MULTI_ANN_TABLE_FEATURE,
341
343
  finish: this.chooseLabelSet,
342
344
  });
343
345
  },
package/src/constants.js CHANGED
@@ -9,4 +9,3 @@ export const TEXT_BREAKPOINT_WIDTH = (locale) => {
9
9
  return 1800;
10
10
  }
11
11
  };
12
- export const MULTI_ANN_TABLE_FEATURE = false;
@@ -1,5 +1,4 @@
1
1
  import myImports from "../api";
2
- import { MULTI_ANN_TABLE_FEATURE } from "../constants";
3
2
  import {
4
3
  sleep,
5
4
  getURLQueryParam,
@@ -181,41 +180,38 @@ const getters = {
181
180
  /* Get annotation sets created in table */
182
181
  annotationSetsInTable: (state) => () => {
183
182
  const annotationSetsList = {};
184
- if (MULTI_ANN_TABLE_FEATURE) {
185
- state.annotationSets.forEach((annotationSet) => {
186
- let addAnnotationSet = false;
187
- if (annotationSet.labels) {
188
- annotationSet.labels.forEach((label) => {
189
- if (
190
- label.annotations &&
191
- label.annotations.find(
192
- (annotation) =>
193
- annotation.origin && annotation.origin === table_reference_api
194
- )
195
- ) {
196
- addAnnotationSet = true;
197
- return;
198
- }
199
- });
200
- }
201
- if (addAnnotationSet) {
202
- // group by label set
203
- if (annotationSetsList[`${annotationSet.label_set.id}`]) {
204
- annotationSetsList[`${annotationSet.label_set.id}`].push(
205
- annotationSet
206
- );
207
- } else {
208
- annotationSetsList[`${annotationSet.label_set.id}`] = [
209
- annotationSet,
210
- ];
183
+ state.annotationSets.forEach((annotationSet) => {
184
+ let addAnnotationSet = false;
185
+ if (annotationSet.labels) {
186
+ annotationSet.labels.forEach((label) => {
187
+ if (
188
+ label.annotations &&
189
+ label.annotations.find(
190
+ (annotation) =>
191
+ annotation.origin && annotation.origin === table_reference_api
192
+ )
193
+ ) {
194
+ addAnnotationSet = true;
195
+ return;
211
196
  }
197
+ });
198
+ }
199
+ if (addAnnotationSet) {
200
+ // group by label set
201
+ if (annotationSetsList[`${annotationSet.label_set.id}`]) {
202
+ annotationSetsList[`${annotationSet.label_set.id}`].push(
203
+ annotationSet
204
+ );
205
+ } else {
206
+ annotationSetsList[`${annotationSet.label_set.id}`] = [annotationSet];
212
207
  }
213
- });
214
- }
208
+ }
209
+ });
210
+
215
211
  return annotationSetsList;
216
212
  },
217
213
 
218
- /* Get annotation sets without tables */
214
+ /* Get annotation sets */
219
215
  annotationSetsToShowInList: (state) => () => {
220
216
  const annotationSetsList = [];
221
217
  state.annotationSets.forEach((annotationSet) => {
@@ -223,7 +219,6 @@ const getters = {
223
219
  if (annotationSet.labels) {
224
220
  annotationSet.labels.forEach((label) => {
225
221
  if (
226
- MULTI_ANN_TABLE_FEATURE &&
227
222
  label.annotations &&
228
223
  label.annotations.find(
229
224
  (annotation) =>
@@ -442,17 +437,19 @@ const getters = {
442
437
  let processedLabels = [];
443
438
 
444
439
  annotationSets.forEach((annotationSet) => {
445
- labels = [];
446
- annotationSet.labels.forEach((label) => {
447
- const labelAnnotations = [];
440
+ if (annotationSet.id) {
441
+ labels = [];
442
+ annotationSet.labels.forEach((label) => {
443
+ const labelAnnotations = [];
448
444
 
449
- // add annotations to the document array
450
- labelAnnotations.push(...label.annotations);
451
- labels.push({ ...label, annotations: labelAnnotations });
452
- processedLabels.push(label);
453
- annotations.push(...labelAnnotations);
454
- });
455
- processedAnnotationSets.push({ ...annotationSet, labels });
445
+ // add annotations to the document array
446
+ labelAnnotations.push(...label.annotations);
447
+ labels.push({ ...label, annotations: labelAnnotations });
448
+ processedLabels.push(label);
449
+ annotations.push(...labelAnnotations);
450
+ });
451
+ processedAnnotationSets.push({ ...annotationSet, labels });
452
+ }
456
453
  });
457
454
  return {
458
455
  annotationSets: processedAnnotationSets,
@@ -489,7 +486,11 @@ const getters = {
489
486
  let value = 0;
490
487
  let index = 0;
491
488
  if (state.annotationSets) {
492
- state.annotationSets.map((annotationSetTemp) => {
489
+ let orderedAnnotationSets = [...state.annotationSets];
490
+ orderedAnnotationSets.sort((a, b) => {
491
+ return a.id - b.id || a.label_set.name.localeCompare(b.label_set.name);
492
+ });
493
+ orderedAnnotationSets.map((annotationSetTemp) => {
493
494
  if (
494
495
  annotationSetTemp.id !== annotationSet.id &&
495
496
  annotationSetTemp.label_set.id === annotationSet.label_set.id &&
@@ -508,6 +509,31 @@ const getters = {
508
509
  return "";
509
510
  },
510
511
 
512
+ /**
513
+ * Checks if theres a group of annotation sets with this label set
514
+ */
515
+ numberOfLabelSetGroup: (state) => (labelSet) => {
516
+ let found = false;
517
+ let index = 0;
518
+ if (state.annotationSets) {
519
+ let orderedAnnotationSets = [...state.annotationSets];
520
+ orderedAnnotationSets.sort((a, b) => {
521
+ return a.id - b.id || a.label_set.name.localeCompare(b.label_set.name);
522
+ });
523
+ orderedAnnotationSets.map((annotationSetTemp) => {
524
+ if (
525
+ annotationSetTemp.label_set.id === labelSet.id &&
526
+ annotationSetTemp.label_set.name === labelSet.name
527
+ ) {
528
+ found = true;
529
+ index++;
530
+ }
531
+ });
532
+ return found ? `${index + 1}` : "";
533
+ }
534
+ return "";
535
+ },
536
+
511
537
  /**
512
538
  * Get label with annotations filtered if the label supports multiple or not
513
539
  */