ObjectAttributes.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 { ObjectAttribute } from '#shared/entities/object-attributes/types/store.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: ObjectAttribute[]
  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. :config="objectAttributesConfig"
  38. />
  39. </CommonLink>
  40. <Component
  41. :is="field.component"
  42. v-else
  43. :attribute="field.attribute"
  44. :value="field.value"
  45. :config="objectAttributesConfig"
  46. />
  47. </Component>
  48. </template>
  49. <slot name="after-fields" />
  50. </Component>
  51. </template>