ObjectAttributes.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!-- Copyright (C) 2012-2025 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. import type { OutputMode } from './types.ts'
  8. export interface Props {
  9. mode?: OutputMode
  10. object: ObjectLike
  11. attributes: ObjectAttribute[]
  12. skipAttributes?: string[]
  13. alwaysShowAfterFields?: boolean
  14. }
  15. const props = withDefaults(defineProps<Props>(), {
  16. mode: 'view',
  17. })
  18. const { fields } = useDisplayObjectAttributes(props)
  19. const { objectAttributes: objectAttributesConfig } = useSharedVisualConfig()
  20. </script>
  21. <template>
  22. <Component
  23. :is="objectAttributesConfig.outer"
  24. v-if="fields.length || props.alwaysShowAfterFields"
  25. >
  26. <template v-for="field of fields" :key="field.attribute.name">
  27. <Component
  28. :is="objectAttributesConfig.wrapper"
  29. :label="field.attribute.display"
  30. >
  31. <CommonLink
  32. v-if="field.link"
  33. :link="field.link"
  34. :class="objectAttributesConfig.classes.link"
  35. >
  36. <Component
  37. :is="field.component"
  38. :attribute="field.attribute"
  39. :value="field.value"
  40. :config="objectAttributesConfig"
  41. :mode="mode"
  42. />
  43. </CommonLink>
  44. <Component
  45. :is="field.component"
  46. v-else
  47. :attribute="field.attribute"
  48. :value="field.value"
  49. :config="objectAttributesConfig"
  50. :mode="mode"
  51. />
  52. </Component>
  53. </template>
  54. <slot name="after-fields" />
  55. </Component>
  56. </template>