useEmailInboundMessagesForm.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. import { useDateFormat } from '@vueuse/shared'
  3. import { shallowRef, reactive } from 'vue'
  4. import type { FormRef } from '#shared/components/Form/types.ts'
  5. import type { EmailInboundMetaInformation } from '../types/email-inbound-outbound.ts'
  6. import type { ShallowRef, Ref } from 'vue'
  7. export const useEmailInboundMessagesForm = (
  8. metaInformationInbound: Ref<Maybe<EmailInboundMetaInformation>>,
  9. ) => {
  10. const formEmailInboundMessages: ShallowRef<FormRef | undefined> = shallowRef()
  11. const emailInboundMessageSchema = [
  12. {
  13. isLayout: true,
  14. element: 'div',
  15. attrs: {
  16. class: 'flex flex-col gap-y-2.5 gap-x-3',
  17. },
  18. children: [
  19. {
  20. isLayout: true,
  21. component: 'CommonLabel',
  22. children:
  23. '$t("%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.", $metaInformationInbound.contentMessages)',
  24. },
  25. {
  26. isLayout: true,
  27. component: 'CommonLabel',
  28. children:
  29. '$t(\'You can import some of your emails as an "archive", which means that no notifications are sent and the tickets will be in a target state that you define.\')',
  30. },
  31. {
  32. isLayout: true,
  33. component: 'CommonLabel',
  34. children:
  35. '$t("You can find archived emails in Zammad anytime using the search function, like for any other ticket.")',
  36. },
  37. {
  38. name: 'archive',
  39. label: __('Archive emails'),
  40. type: 'toggle',
  41. value: true,
  42. props: {
  43. variants: {
  44. true: __('yes'),
  45. false: __('no'),
  46. },
  47. },
  48. },
  49. {
  50. name: 'archive_before',
  51. if: '$values.archive',
  52. type: 'datetime',
  53. label: __('Archive cut-off time'),
  54. required: true,
  55. help: __(
  56. 'Emails before the cut-off time are imported as archived tickets. Emails after the cut-off time are imported as regular tickets.',
  57. ),
  58. props: {
  59. // With an extra hour on top, so the current selection works.
  60. maxDate: useDateFormat(
  61. new Date(new Date().getTime() + 60 * 60 * 1000),
  62. 'YYYY-MM-DDTHH:mm',
  63. ).value,
  64. },
  65. },
  66. {
  67. name: 'archive_state_id',
  68. if: '$values.archive',
  69. label: __('Archive ticket target state'),
  70. type: 'select',
  71. },
  72. ],
  73. },
  74. ]
  75. const emailInboundMessageSchemaData = reactive({
  76. metaInformationInbound,
  77. })
  78. return {
  79. formEmailInboundMessages,
  80. emailInboundMessageSchema,
  81. emailInboundMessageSchemaData,
  82. }
  83. }