diff --git a/src/components/Form/fields/FieldAffiliationsRorAutoSuggest.vue b/src/components/Form/fields/FieldAffiliationsRorAutoSuggest.vue
index e6776e0bb..2ad81d8dc 100644
--- a/src/components/Form/fields/FieldAffiliationsRorAutoSuggest.vue
+++ b/src/components/Form/fields/FieldAffiliationsRorAutoSuggest.vue
@@ -60,6 +60,13 @@ import Icon from '@/components/Icon/Icon.vue';
import {useFetch} from '@/composables/useFetch';
import {useId} from '@/composables/useId';
+const props = defineProps({
+ currentValue: {
+ type: Array,
+ default: () => [],
+ },
+});
+const currentValueIds = ref([]);
const {generateId} = useId();
const autosuggestContainerId = generateId();
const currentSelected = ref([]);
@@ -94,35 +101,49 @@ const autoSuggestProps = computed(() => ({
isLoading: isLoading.value,
}));
+watch(props.currentValue, (newValue) => {
+ currentValueIds.value = [];
+ newValue.forEach((item) => {
+ if (item['ror']) currentValueIds.value.push(item['ror']);
+ });
+});
+
const mappedSuggestions = computed(() => {
- return suggestions.value?.items.map((item) => {
- const displayLocale =
- item.names?.find((i) => i.types.includes('ror_display'))?.lang !== null
- ? item.names?.find((i) => i.types.includes('ror_display'))?.lang
- : noLangCode;
-
- let names = {};
- item.names?.forEach((name) => {
- if (name.types.includes('label') || name.types.includes('ror_display')) {
- const locale = name.lang !== null ? name.lang : noLangCode;
- names[locale] = name.value;
- }
- });
-
- return {
- value: {
- id: null,
- ror: item.id,
- displayLocale: displayLocale,
- isActive: item.status === 'active' ? 1 : 0,
- name: names,
- _href: null,
- },
- label: names[displayLocale],
- hasSlot: true,
- href: item.id,
- };
+ let newSuggestions = [];
+ suggestions.value?.items.map((item) => {
+ if (!currentValueIds.value?.includes(item.id)) {
+ const displayLocale =
+ item.names?.find((i) => i.types.includes('ror_display'))?.lang !== null
+ ? item.names?.find((i) => i.types.includes('ror_display'))?.lang
+ : noLangCode;
+
+ let names = {};
+ item.names?.forEach((name) => {
+ if (
+ name.types.includes('label') ||
+ name.types.includes('ror_display')
+ ) {
+ const locale = name.lang !== null ? name.lang : noLangCode;
+ names[locale] = name.value;
+ }
+ });
+
+ newSuggestions.push({
+ value: {
+ id: null,
+ ror: item.id,
+ displayLocale: displayLocale,
+ isActive: item.status === 'active' ? 1 : 0,
+ name: names,
+ _href: null,
+ },
+ label: names[displayLocale],
+ hasSlot: true,
+ href: item.id,
+ });
+ }
});
+ return newSuggestions;
});
watch(queryParams, () => {