useEmailInboundMessagesForm.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { ShallowRef, Ref } from 'vue'
  3. import { shallowRef, reactive } from 'vue'
  4. import type { FormRef } from '#shared/components/Form/types.ts'
  5. import { markup } from '#shared/utils/markup.ts'
  6. import { i18n } from '#shared/i18n/index.ts'
  7. import type { EmailInboundMetaInformation } from '../types/email-inbound-outbound.ts'
  8. export const useEmailInboundMessagesForm = (
  9. metaInformationInbound: Ref<Maybe<EmailInboundMetaInformation>>,
  10. ) => {
  11. const formEmailInboundMessages: ShallowRef<FormRef | undefined> = shallowRef()
  12. const emailInboundMessageSchema = [
  13. {
  14. isLayout: true,
  15. element: 'div',
  16. attrs: {
  17. class: 'flex flex-col gap-y-2.5 gap-x-3',
  18. },
  19. children: [
  20. {
  21. isLayout: true,
  22. component: 'CommonLabel',
  23. children:
  24. '$t("%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.", $metaInformationInbound.contentMessages)',
  25. },
  26. {
  27. if: '$metaInformationInbound.archivePossible === true',
  28. isLayout: true,
  29. element: 'div',
  30. attrs: {
  31. class: 'flex flex-col gap-y-2.5 gap-x-3',
  32. },
  33. children: [
  34. {
  35. isLayout: true,
  36. component: 'CommonLabel',
  37. children:
  38. '$t(\'In addition, we have found emails in your mailbox that are older than %s weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.\', $metaInformationInbound.archiveWeekRange)',
  39. },
  40. {
  41. isLayout: true,
  42. component: 'CommonLabel',
  43. children:
  44. '$t("Should the emails from this mailbox be imported as an archive or as regular emails?")',
  45. },
  46. {
  47. isLayout: true,
  48. element: 'ul',
  49. attrs: {
  50. class:
  51. 'text-sm dark:text-neutral-400 text-gray-100 gap-1 list-disc ltr:ml-5 rtl:mr-5',
  52. },
  53. children: [
  54. {
  55. isLayout: true,
  56. element: 'li',
  57. attrs: {
  58. innerHTML: markup(
  59. i18n.t(
  60. 'Import as archive: |No notifications are sent|, the |tickets are closed|, and original timestamps are used. You can still find them in Zammad using the search.',
  61. ),
  62. ),
  63. },
  64. children: '',
  65. },
  66. {
  67. isLayout: true,
  68. element: 'li',
  69. attrs: {
  70. innerHTML: markup(
  71. i18n.t(
  72. 'Import as regular: |Notifications are sent| and the |tickets are open| - you can find the tickets in the overview of open tickets.',
  73. ),
  74. ),
  75. },
  76. children: '',
  77. },
  78. ],
  79. },
  80. {
  81. if: '$metaInformationInbound.archivePossible === true',
  82. name: 'importAs',
  83. label: __('Email import mode'),
  84. type: 'select',
  85. value: 'false',
  86. options: [
  87. {
  88. value: 'true',
  89. label: __('Import as archive'),
  90. },
  91. {
  92. value: 'false',
  93. label: __('Import as regular'),
  94. },
  95. ],
  96. },
  97. ],
  98. },
  99. ],
  100. },
  101. ]
  102. const emailInboundMessageSchemaData = reactive({
  103. metaInformationInbound,
  104. })
  105. return {
  106. formEmailInboundMessages,
  107. emailInboundMessageSchema,
  108. emailInboundMessageSchemaData,
  109. }
  110. }