ObjectAttributes.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import type { ObjectManagerFrontendAttribute } from '@shared/graphql/types'
  4. import type { ObjectLike } from '@shared/types/utils'
  5. import { objectAttributesConfig } from './config'
  6. import { useDisplayObjectAttributes } from './useDisplayObjectAttributes'
  7. export interface Props {
  8. object: ObjectLike
  9. attributes: ObjectManagerFrontendAttribute[]
  10. skipAttributes?: string[]
  11. accessors?: Record<string, string>
  12. }
  13. const props = defineProps<Props>()
  14. const { fields } = useDisplayObjectAttributes(props)
  15. </script>
  16. <template>
  17. <Component :is="objectAttributesConfig.outer" v-if="fields.length">
  18. <template v-for="field of fields" :key="field.attribute.name">
  19. <Component
  20. :is="objectAttributesConfig.wrapper"
  21. :label="field.attribute.display"
  22. >
  23. <CommonLink
  24. v-if="field.link"
  25. :link="field.link"
  26. :class="objectAttributesConfig.classes.link"
  27. >
  28. <Component
  29. :is="field.component"
  30. :attribute="field.attribute"
  31. :value="field.value"
  32. />
  33. </CommonLink>
  34. <Component
  35. :is="field.component"
  36. v-else
  37. :attribute="field.attribute"
  38. :value="field.value"
  39. />
  40. </Component>
  41. </template>
  42. <slot name="after-fields" />
  43. </Component>
  44. </template>