Home.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { MenuItem } from '@mobile/components/CommonSectionMenu'
  4. import CommonSectionMenu from '@mobile/components/CommonSectionMenu/CommonSectionMenu.vue'
  5. import CommonInputSearch from '@shared/components/CommonInputSearch/CommonInputSearch.vue'
  6. import useSessionStore from '@shared/stores/session'
  7. import { computed } from 'vue'
  8. import { useTicketsOverviews } from '../stores/ticketOverviews'
  9. const IS_DEV = import.meta.env.DEV
  10. const session = useSessionStore()
  11. // TODO all menus should be generated on back-end
  12. const menu: MenuItem[] = [
  13. {
  14. type: 'link',
  15. link: '/tickets',
  16. title: __('Ticket Overviews'),
  17. icon: { name: 'stack', size: 'base' },
  18. iconBg: 'bg-pink',
  19. },
  20. // cannot inline import.meta here, Vite fails
  21. ...(IS_DEV
  22. ? [
  23. {
  24. type: 'link' as const,
  25. link: '/playground',
  26. title: 'Playground',
  27. icon: { name: 'cog', size: 'small' as const },
  28. iconBg: 'bg-orange',
  29. },
  30. ]
  31. : []),
  32. ]
  33. const overviews = useTicketsOverviews()
  34. const ticketOverview = computed<MenuItem[]>(() => {
  35. if (overviews.loading) return []
  36. return overviews.includedOverviews.map((overview) => {
  37. return {
  38. type: 'link',
  39. link: '/',
  40. title: overview.name,
  41. information: overview.ticketCount,
  42. }
  43. })
  44. })
  45. </script>
  46. <template>
  47. <div class="p-4">
  48. <div class="my-6 flex justify-end ltr:mr-4 rtl:ml-4">
  49. <CommonLink link="/#ticket/create">
  50. <CommonIcon name="plus" size="small" />
  51. </CommonLink>
  52. </div>
  53. <div
  54. class="mb-5 flex w-full items-center justify-center text-4xl font-bold"
  55. >
  56. {{ $t('Home') }}
  57. </div>
  58. <CommonLink link="/search">
  59. <CommonInputSearch wrapper-class="mb-4" no-border />
  60. </CommonLink>
  61. <CommonSectionMenu :items="menu" />
  62. <CommonSectionMenu
  63. :items="ticketOverview"
  64. :header-title="__('Ticket Overview')"
  65. :action-title="
  66. session.hasPermission(['ticket.agent', 'ticket.customer'])
  67. ? __('Edit')
  68. : undefined
  69. "
  70. action-link="/favorite/ticker-overviews/edit"
  71. >
  72. <template v-if="overviews.loading" #before-items>
  73. <div class="flex w-full justify-center">
  74. <CommonIcon name="loader" animation="spin" />
  75. </div>
  76. </template>
  77. </CommonSectionMenu>
  78. </div>
  79. </template>