ArticleBubbleMetaFields.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { toRef } from 'vue'
  4. import CommonLabel from '#shared/components/CommonLabel/CommonLabel.vue'
  5. import type { TicketArticle } from '#shared/entities/ticket/types.ts'
  6. import { useArticleMeta } from '#desktop/pages/ticket/components/TicketDetailView/ArticleMeta/useArticleMeta.ts'
  7. interface Props {
  8. article: TicketArticle
  9. }
  10. const props = defineProps<Props>()
  11. const { fields } = useArticleMeta(toRef(props, 'article'))
  12. </script>
  13. <template>
  14. <div
  15. class="grid grid-cols-[max-content_1fr] gap-x-3 gap-y-2 rounded-t-xl p-3"
  16. >
  17. <template v-for="(field, index) in fields" :key="`${field.label}-${index}`">
  18. <CommonLabel class="ltr:ml-auto rtl:mr-auto"
  19. >{{ $t(field.label) }}
  20. </CommonLabel>
  21. <div class="flex items-center gap-2">
  22. <Component
  23. :is="field.component || CommonLabel"
  24. :prefix-icon="field.icon && !field.component ? field.icon : undefined"
  25. v-bind="field.props || {}"
  26. :context="{ field, article }"
  27. class="text-black dark:text-white"
  28. >
  29. {{ field.value }}
  30. </Component>
  31. <template v-if="field.links?.length">
  32. <CommonLink
  33. v-for="{ url, api, label, target } of field.links"
  34. :key="url"
  35. :link="url"
  36. :rest-api="api"
  37. :target="target"
  38. class="text-sm text-white/75"
  39. >
  40. {{ $t(label) }}
  41. </CommonLink>
  42. </template>
  43. </div>
  44. </template>
  45. </div>
  46. </template>