ObjectAttributes.vue 1.6 KB

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