AttributeMultiSelect.vue 906 B

12345678910111213141516171819202122232425262728293031323334353637
  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 { ObjectAttributeMultiSelect } from './attributeMultiSelectTypes.ts'
  6. const props = defineProps<{
  7. attribute: ObjectAttributeMultiSelect
  8. value: string[]
  9. }>()
  10. const body = computed(() => {
  11. if (props.attribute.dataType === 'multi_tree_select') {
  12. return props.value
  13. .map((value) =>
  14. value
  15. .split('::')
  16. .map((option) => translateOption(props.attribute, option))
  17. .join('::'),
  18. )
  19. .join(', ')
  20. }
  21. return props.value
  22. .map((key) => {
  23. const option = props.attribute.dataOption.historical_options?.[key] ?? key
  24. return translateOption(props.attribute, option)
  25. })
  26. .join(', ')
  27. })
  28. </script>
  29. <template>
  30. {{ body }}
  31. </template>