diff --git a/src/components/DocumentPage/EditAnnotation.vue b/src/components/DocumentPage/EditAnnotation.vue index d06ccc9e..8335a7b1 100644 --- a/src/components/DocumentPage/EditAnnotation.vue +++ b/src/components/DocumentPage/EditAnnotation.vue @@ -24,7 +24,9 @@ ? `${selectedSet.label_set.name} ${ selectedSet.id ? numberOfAnnotationSetGroup(selectedSet) - : `(${$t("new")})` + : `${numberOfLabelSetGroup(selectedSet.label_set)} (${$t( + "new" + )})` }` : $t("select_annotation_set") }} @@ -33,6 +35,14 @@ + + {{ $t("new_ann_set_title") }} + {{ `${set.label_set.name} ${ - set.id ? numberOfAnnotationSetGroup(set) : `(${$t("new")})` + set.id + ? numberOfAnnotationSetGroup(set) + : `${numberOfLabelSetGroup(set.label_set)} (${$t("new")})` }` }} - - {{ $t("new_ann_set_title") }} - { + return set.id === null && set.label_set.id === labelSet.id; + }); + const newSet = { label_set: labelSet, labels: labelSet.labels, id: null, }; - this.setsList.push(newSet); + if (existsIndex >= 0) { + this.setsList[existsIndex] = newSet; + } else { + this.setsList.unshift(newSet); + } this.selectedSet = newSet; }, openAnnotationSetCreation() { diff --git a/src/components/DocumentPage/NewAnnotation.vue b/src/components/DocumentPage/NewAnnotation.vue index 50323654..c87b570e 100644 --- a/src/components/DocumentPage/NewAnnotation.vue +++ b/src/components/DocumentPage/NewAnnotation.vue @@ -323,7 +323,7 @@ export default { if (existsIndex >= 0) { this.setsList[existsIndex] = newSet; } else { - this.setsList.push(newSet); + this.setsList.unshift(newSet); } this.selectedSet = newSet; }, diff --git a/src/store/document.js b/src/store/document.js index 6cac27a2..ae922947 100644 --- a/src/store/document.js +++ b/src/store/document.js @@ -558,9 +558,13 @@ const getters = { let returnLabelSets = []; if (state.annotationSets) { state.annotationSets.forEach((annotationSet) => { + // last validation checks if the label set is already present in list if ( - annotationSet.id == null || - annotationSet.label_set.has_multiple_annotation_sets + (annotationSet.id == null || + annotationSet.label_set.has_multiple_annotation_sets) && + !returnLabelSets.find( + (set) => set.id !== null && set.id === annotationSet.label_set.id + ) ) { const labelSet = { ...annotationSet.label_set }; labelSet.labels = [...annotationSet.labels];