ExternalReferenceLink.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import { useTouchDevice } from '#shared/composables/useTouchDevice.ts'
  5. import CommonButton from '#desktop/components/CommonButton/CommonButton.vue'
  6. interface Props {
  7. id: number
  8. showId?: boolean
  9. title: string
  10. link: string
  11. isEditable: boolean
  12. tooltip: string
  13. }
  14. const props = defineProps<Props>()
  15. defineEmits<{
  16. remove: [{ id: number }]
  17. }>()
  18. const linkContent = computed(() => {
  19. if (props.showId) {
  20. return `#${props.id} ${props.title}`
  21. }
  22. return props.title
  23. })
  24. const { isTouchDevice } = useTouchDevice()
  25. </script>
  26. <template>
  27. <div class="flex gap-2">
  28. <CommonLink
  29. class="grow"
  30. size="medium"
  31. external
  32. open-in-new-tab
  33. :link="link"
  34. >
  35. {{ linkContent }}
  36. </CommonLink>
  37. <CommonButton
  38. v-if="isEditable"
  39. v-tooltip="tooltip"
  40. icon="x-lg"
  41. size="small"
  42. variant="remove"
  43. :class="{
  44. 'opacity-0 focus-visible:opacity-100 group-hover:opacity-100':
  45. !isTouchDevice,
  46. }"
  47. @click="$emit('remove', { id })"
  48. />
  49. </div>
  50. </template>