AttributeMultiSelect.vue 964 B

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