Home.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import CommonInputSearch from '@shared/components/CommonInputSearch/CommonInputSearch.vue'
  5. import { useSessionStore } from '@shared/stores/session'
  6. import type { MenuItem } from '@mobile/components/CommonSectionMenu'
  7. import CommonSectionMenu from '@mobile/components/CommonSectionMenu/CommonSectionMenu.vue'
  8. import { useTicketOverviewsStore } from '@mobile/entities/ticket/stores/ticketOverviews'
  9. const IS_DEV = import.meta.env.DEV
  10. const session = useSessionStore()
  11. const menu: MenuItem[] = [
  12. {
  13. type: 'link',
  14. link: '/tickets/view',
  15. label: __('Ticket Overviews'),
  16. icon: { name: 'mobile-all-tickets', size: 'base' },
  17. iconBg: 'bg-pink',
  18. permission: ['ticket.agent', 'ticket.customer'],
  19. },
  20. // Cannot inline import.meta here, Vite fails
  21. ...(IS_DEV
  22. ? [
  23. {
  24. type: 'link' as const,
  25. link: '/playground',
  26. label: 'Playground',
  27. icon: { name: 'mobile-settings', size: 'small' as const },
  28. iconBg: 'bg-orange',
  29. },
  30. ]
  31. : []),
  32. ]
  33. const overviews = useTicketOverviewsStore()
  34. const ticketOverview = computed<MenuItem[]>(() => {
  35. if (overviews.loading) return []
  36. return overviews.includedOverviews.map((overview) => {
  37. return {
  38. type: 'link',
  39. link: `/tickets/view/${overview.link}`,
  40. label: overview.name,
  41. information: overview.ticketCount,
  42. }
  43. })
  44. })
  45. </script>
  46. <template>
  47. <div class="p-4">
  48. <div class="mt-1.5 mb-3 flex justify-end ltr:mr-1.5 rtl:ml-1.5">
  49. <CommonLink link="/tickets/create" :title="__('Create new ticket')">
  50. <CommonIcon name="mobile-add" size="small" />
  51. </CommonLink>
  52. </div>
  53. <h1 class="mb-5 flex w-full items-center justify-center text-4xl font-bold">
  54. {{ $t('Home') }}
  55. </h1>
  56. <CommonLink :aria-label="$t('Search…')" link="/search">
  57. <CommonInputSearch
  58. aria-hidden="true"
  59. tabindex="-1"
  60. wrapper-class="mb-4"
  61. no-border
  62. />
  63. </CommonLink>
  64. <CommonSectionMenu :items="menu" />
  65. <CommonSectionMenu
  66. v-if="session.hasPermission(['ticket.agent', 'ticket.customer'])"
  67. :items="ticketOverview"
  68. :header-label="__('Ticket Overview')"
  69. :action-label="__('Edit')"
  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="mobile-loading" animation="spin" />
  75. </div>
  76. </template>
  77. </CommonSectionMenu>
  78. </div>
  79. </template>