From e8d0b3d42a70af27a024af69dc979843a24bec84 Mon Sep 17 00:00:00 2001
From: Konrad Mohrfeldt <konrad.mohrfeldt@farbdev.org>
Date: Mon, 27 May 2024 13:52:12 +0200
Subject: [PATCH] fix: inform user if links cannot be added and are empty

---
 src/components/generic/ALinkCollectionEditor.vue | 5 ++++-
 src/i18n/de.js                                   | 1 +
 src/i18n/en.js                                   | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/components/generic/ALinkCollectionEditor.vue b/src/components/generic/ALinkCollectionEditor.vue
index f1538125..a708eff7 100644
--- a/src/components/generic/ALinkCollectionEditor.vue
+++ b/src/components/generic/ALinkCollectionEditor.vue
@@ -1,6 +1,6 @@
 <template>
   <fieldset>
-    <ul class="tw-flex tw-flex-col tw-gap-3 tw-p-0 tw-m-0 *:tw-block">
+    <ul class="tw-flex tw-flex-col tw-gap-3 tw-p-0 tw-m-0 *:tw-block empty:tw-hidden">
       <li v-for="(link, index) in links" :key="index">
         <ALinkEditor
           v-model="links[index]"
@@ -15,6 +15,7 @@
         <ALinkEditor v-model="newLink" @check="maybeAddLink" />
       </li>
     </ul>
+    <p v-if="disabled && links.length === 0">{{ t('link.noneSet') }}</p>
   </fieldset>
 </template>
 
@@ -23,6 +24,7 @@ import { MappedErrorDetail } from '@rokoli/bnb'
 import { DefaultArray, ErrorDetailArray } from '@rokoli/bnb/drf'
 import { nextTick, ref } from 'vue'
 
+import { useI18n } from '@/i18n'
 import { Link } from '@/types'
 import ALinkEditor from '@/components/generic/ALinkEditor.vue'
 
@@ -34,6 +36,7 @@ const props = defineProps<{
 }>()
 const emit = defineEmits<{ save: [] }>()
 
+const { t } = useI18n()
 const newLink = ref<Link>({ typeId: null, url: '' })
 
 async function maybeAddLink() {
diff --git a/src/i18n/de.js b/src/i18n/de.js
index 61b24d8b..68a9759f 100644
--- a/src/i18n/de.js
+++ b/src/i18n/de.js
@@ -350,6 +350,7 @@ export default {
 
   link: {
     urlExample: 'z.B. https://aura.radio',
+    noneSet: 'Es wurden keine Links zugewiesen.',
     fields: {
       typeId: 'Linktyp',
       url: 'Web Adresse',
diff --git a/src/i18n/en.js b/src/i18n/en.js
index 976ffe9a..e4ac7217 100644
--- a/src/i18n/en.js
+++ b/src/i18n/en.js
@@ -351,6 +351,7 @@ export default {
 
   link: {
     urlExample: 'i.e. https://aura.radio',
+    noneSet: 'No links have been assigned.',
     fields: {
       typeId: 'Link type',
       url: 'Web Address',
-- 
GitLab