2026-01-02 13:41:09 +00:00
|
|
|
<!-- Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/ -->
|
2022-11-21 13:51:49 +00:00
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-01-19 09:35:47 +00:00
|
|
|
import { toRef } from 'vue'
|
2025-10-02 14:03:42 +00:00
|
|
|
|
2025-11-10 15:42:05 +00:00
|
|
|
import { isInlineAttributeEditable } from '#shared/components/ObjectAttributes/utils.ts'
|
2023-06-20 13:48:22 +00:00
|
|
|
import { useSharedVisualConfig } from '#shared/composables/useSharedVisualConfig.ts'
|
2024-11-12 21:13:22 +00:00
|
|
|
import type { ObjectAttribute } from '#shared/entities/object-attributes/types/store.ts'
|
2025-10-02 14:03:42 +00:00
|
|
|
import { useApplicationStore } from '#shared/stores/application.ts'
|
2023-04-24 12:50:55 +00:00
|
|
|
import type { ObjectLike } from '#shared/types/utils.ts'
|
2024-05-17 13:31:19 +00:00
|
|
|
|
2023-04-24 12:50:55 +00:00
|
|
|
import { useDisplayObjectAttributes } from './useDisplayObjectAttributes.ts'
|
2025-11-10 15:42:05 +00:00
|
|
|
import { useInlineEditable } from './useInlineEditable.ts'
|
2022-11-21 13:51:49 +00:00
|
|
|
|
2025-11-10 15:42:05 +00:00
|
|
|
import type { InlineEditable, OutputMode } from './types.ts'
|
2025-01-24 08:08:23 +00:00
|
|
|
|
2022-11-21 13:51:49 +00:00
|
|
|
export interface Props {
|
2025-01-24 08:08:23 +00:00
|
|
|
mode?: OutputMode
|
2022-11-21 13:51:49 +00:00
|
|
|
object: ObjectLike
|
2024-11-12 21:13:22 +00:00
|
|
|
attributes: ObjectAttribute[]
|
2022-11-21 13:51:49 +00:00
|
|
|
skipAttributes?: string[]
|
2025-11-10 15:42:05 +00:00
|
|
|
inlineEditable?: InlineEditable
|
2025-10-02 14:03:42 +00:00
|
|
|
includeStatic?: boolean
|
2023-04-18 06:57:31 +00:00
|
|
|
alwaysShowAfterFields?: boolean
|
2022-11-21 13:51:49 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-24 08:08:23 +00:00
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
|
mode: 'view',
|
|
|
|
|
})
|
2022-11-21 13:51:49 +00:00
|
|
|
|
|
|
|
|
const { fields } = useDisplayObjectAttributes(props)
|
2023-06-20 13:48:22 +00:00
|
|
|
const { objectAttributes: objectAttributesConfig } = useSharedVisualConfig()
|
2025-10-02 14:03:42 +00:00
|
|
|
|
2026-01-19 09:35:47 +00:00
|
|
|
const config = toRef(useApplicationStore(), 'config')
|
2025-10-02 14:03:42 +00:00
|
|
|
|
2025-11-10 15:42:05 +00:00
|
|
|
const getLabel = (attribute: ObjectAttribute) =>
|
2025-11-11 16:06:58 +00:00
|
|
|
attribute.dataOption?.display_config
|
|
|
|
|
? config.value[attribute.dataOption.display_config]
|
|
|
|
|
: attribute.display
|
2025-11-10 15:42:05 +00:00
|
|
|
|
|
|
|
|
const getDisplayLabel = (attribute: ObjectAttribute) => {
|
|
|
|
|
// If inline editable by default it shows then the field label
|
|
|
|
|
if (isInlineAttributeEditable(attribute.name, props.inlineEditable)) return null
|
|
|
|
|
|
|
|
|
|
return getLabel(attribute)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useInlineEditable(props, fields)
|
2022-11-21 13:51:49 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-06-11 17:45:28 +00:00
|
|
|
<Component :is="objectAttributesConfig.outer" v-if="fields.length || props.alwaysShowAfterFields">
|
2022-11-21 13:51:49 +00:00
|
|
|
<template v-for="field of fields" :key="field.attribute.name">
|
2025-11-20 09:02:37 +00:00
|
|
|
<Component
|
|
|
|
|
:is="objectAttributesConfig.wrapper"
|
|
|
|
|
:label="getDisplayLabel(field.attribute)"
|
|
|
|
|
:attribute="field.attribute"
|
|
|
|
|
>
|
2022-11-21 13:51:49 +00:00
|
|
|
<CommonLink
|
2022-12-14 09:58:49 +00:00
|
|
|
v-if="field.link"
|
|
|
|
|
:link="field.link"
|
2022-11-21 13:51:49 +00:00
|
|
|
:class="objectAttributesConfig.classes.link"
|
|
|
|
|
>
|
|
|
|
|
<Component
|
|
|
|
|
:is="field.component"
|
|
|
|
|
:attribute="field.attribute"
|
|
|
|
|
:value="field.value"
|
2024-12-12 09:24:27 +00:00
|
|
|
:config="objectAttributesConfig"
|
2025-01-24 08:08:23 +00:00
|
|
|
:mode="mode"
|
2025-11-10 15:42:05 +00:00
|
|
|
:inline-editable="inlineEditable"
|
2022-11-21 13:51:49 +00:00
|
|
|
/>
|
|
|
|
|
</CommonLink>
|
|
|
|
|
<Component
|
|
|
|
|
:is="field.component"
|
|
|
|
|
v-else
|
|
|
|
|
:attribute="field.attribute"
|
|
|
|
|
:value="field.value"
|
2024-12-12 09:24:27 +00:00
|
|
|
:config="objectAttributesConfig"
|
2025-01-24 08:08:23 +00:00
|
|
|
:mode="mode"
|
2025-11-10 15:42:05 +00:00
|
|
|
:inline-editable="inlineEditable"
|
2022-11-21 13:51:49 +00:00
|
|
|
/>
|
|
|
|
|
</Component>
|
|
|
|
|
</template>
|
|
|
|
|
<slot name="after-fields" />
|
|
|
|
|
</Component>
|
|
|
|
|
</template>
|