TableRowGroupBy.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!-- Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import ObjectAttributeContent from '#shared/components/ObjectAttributes/ObjectAttribute.vue'
  5. import type { ObjectAttribute } from '#shared/entities/object-attributes/types/store.ts'
  6. import CommonDivider from '#desktop/components/CommonDivider/CommonDivider.vue'
  7. import type { TableAttribute, TableItem } from './types'
  8. export interface Props {
  9. item: TableItem
  10. attribute: TableAttribute
  11. tableColumnLength: number
  12. groupByValueIndex: number
  13. groupByRowCounts: string[][] | undefined
  14. remainingItems: number
  15. }
  16. const props = defineProps<Props>()
  17. const groupByRowCount = computed(() => {
  18. return props.groupByRowCounts?.[props.groupByValueIndex].length
  19. })
  20. const completedGroup = computed(() => {
  21. if (props.remainingItems === 0) return true
  22. return props.groupByValueIndex !== (props.groupByRowCounts?.length || 0) - 1
  23. })
  24. </script>
  25. <template>
  26. <tr class="group">
  27. <td :colspan="tableColumnLength">
  28. <CommonDivider class="mb-1 mt-2 group-first:mt-0" />
  29. <div class="h-10 p-2.5">
  30. <CommonLabel
  31. class="cursor-default truncate text-stone-200 dark:text-neutral-500"
  32. >
  33. <ObjectAttributeContent
  34. mode="table"
  35. :attribute="attribute as unknown as ObjectAttribute"
  36. :object="item"
  37. />
  38. <CommonBadge
  39. class="ms-0.5 font-bold leading-snug"
  40. rounded
  41. size="xs"
  42. variant="info"
  43. >
  44. {{ groupByRowCount }}{{ completedGroup ? '' : '+' }}
  45. </CommonBadge>
  46. </CommonLabel>
  47. </div>
  48. </td>
  49. </tr>
  50. </template>