AttributeSingleSelect.vue 828 B

1234567891011121314151617181920212223242526272829
  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. import type { ObjectAttributeProps } from '../../types.ts'
  7. const props =
  8. defineProps<ObjectAttributeProps<ObjectAttributeSingleSelect, string>>()
  9. const body = computed(() => {
  10. if (props.attribute.dataType === 'tree_select') {
  11. return props.value
  12. .split('::')
  13. .map((field) => translateOption(props.attribute, field))
  14. .join('::')
  15. }
  16. const value =
  17. props.attribute.dataOption.historical_options?.[props.value] ?? props.value
  18. return translateOption(props.attribute, value)
  19. })
  20. </script>
  21. <template>
  22. {{ body }}
  23. </template>