AttributeSingleSelect.vue 770 B

123456789101112131415161718192021222324252627282930
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import { translateOption } from '../../utils.ts'
  5. import type { ObjectAttributeSingleSelect } from './attributeSingleSelectTypes.ts'
  6. const props = defineProps<{
  7. attribute: ObjectAttributeSingleSelect
  8. value: string
  9. }>()
  10. const body = computed(() => {
  11. if (props.attribute.dataType === 'tree_select') {
  12. return props.value
  13. .split('::')
  14. .map((field) => translateOption(props.attribute, field))
  15. .join('::')
  16. }
  17. const value =
  18. props.attribute.dataOption.historical_options?.[props.value] ?? props.value
  19. return translateOption(props.attribute, value)
  20. })
  21. </script>
  22. <template>
  23. {{ body }}
  24. </template>