CommonTicketStateIndicator.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import { TicketState } from '@shared/entities/ticket/types'
  5. // TODO: Add a test and story for this common component.
  6. export interface Props {
  7. status?: TicketState | string
  8. label: string
  9. pill?: boolean
  10. }
  11. const props = withDefaults(defineProps<Props>(), {
  12. pill: false,
  13. })
  14. const statusIndicator = computed(() => {
  15. switch (props.status) {
  16. case TicketState.Closed:
  17. return 'mobile-check-circle-outline'
  18. case TicketState.WaitingForClosure:
  19. return 'mobile-check-circle-outline-dashed'
  20. case TicketState.WaitingForReminder:
  21. return 'mobile-check-circle-outline-dashed'
  22. case TicketState.Escalated:
  23. return 'mobile-warning-triangle'
  24. case TicketState.New:
  25. case TicketState.Open:
  26. default:
  27. return 'mobile-check-circle-no'
  28. }
  29. })
  30. </script>
  31. <template>
  32. <div
  33. :class="{
  34. 'status-pill': pill,
  35. [`status-${status}`]: true,
  36. }"
  37. class="status flex select-none items-center"
  38. role="group"
  39. >
  40. <CommonIcon
  41. v-if="statusIndicator"
  42. :name="statusIndicator"
  43. :size="pill ? 'tiny' : 'base'"
  44. decorative
  45. />
  46. <div v-if="pill" class="ml-[2px] text-xs uppercase leading-[14px]">
  47. {{ label }}
  48. </div>
  49. </div>
  50. </template>
  51. <style scoped lang="scss">
  52. .status {
  53. @apply text-gray;
  54. &-pill {
  55. @apply rounded bg-gray-100 py-1 pr-1.5 pl-1 text-black;
  56. &.status-closed {
  57. @apply bg-green-highlight;
  58. }
  59. &.status-merged,
  60. &.status-removed,
  61. &.status-waiting-for-closure,
  62. &.status-waiting-for-reminder {
  63. @apply bg-gray-highlight;
  64. }
  65. &.status-new,
  66. &.status-open {
  67. @apply bg-yellow-highlight;
  68. }
  69. &.status-escalated {
  70. @apply bg-red-highlight;
  71. }
  72. }
  73. &-closed {
  74. @apply text-green;
  75. }
  76. &-waiting-for-closure,
  77. &-waiting-for-reminder {
  78. @apply text-gray;
  79. }
  80. &-new,
  81. &-open {
  82. @apply text-yellow;
  83. }
  84. &-escalated {
  85. @apply text-red;
  86. }
  87. }
  88. </style>