Просмотр исходного кода

Fixes #5464 - Introduce/Enhance archive mode in all e-mail-style channels.

Co-authored-by: Dusan Vuckovic <dv@zammad.com>
Co-authored-by: Mantas Masalskis <mm@zammad.com>
Dusan Vuckovic 1 месяц назад
Родитель
Сommit
85ec12a330

+ 84 - 57
app/assets/javascripts/app/controllers/_channel/email.coffee

@@ -571,9 +571,8 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
             for key, value of data.setting
               @account[key] = value
 
-          if data.content_messages && data.content_messages > 0 && (!@account['inbound']['options'] || @account['inbound']['options']['keep_on_server'] isnt true)
-            @probeInboundMessagesFound(data, true)
-            @probeInboundArchive(data)
+          if data.content_messages
+            @probeInboundArchive(data, true)
           else
             @verify(@account)
 
@@ -629,8 +628,7 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
           # remember account settings
           @account.inbound = params
 
-          if data.content_messages && data.content_messages > 0 && (!@account['inbound']['options'] || @account['inbound']['options']['keep_on_server'] isnt true)
-            @probeInboundMessagesFound(data)
+          if data.content_messages or @channel
             @probeInboundArchive(data)
           else
             @showSlide('js-outbound')
@@ -658,68 +656,89 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
         @enable(e)
     )
 
-  probeInboundMessagesFound: (data, verify) =>
-    message = App.i18n.translateContent('%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.', data.content_messages)
-    @$('.js-inbound-acknowledge .js-messageFound').html(message)
-
-    if !verify
-      @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound')
-      @$('.js-inbound-acknowledge .js-next').off('click.verify')
+  probeInboundArchive: (data, verify = false) =>
+    if data.content_messages
+      message = App.i18n.translateContent('%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.', data.content_messages)
+      @$('.js-inbound-acknowledge .js-messageFound').html(message)
     else
-      @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
-      @$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
-      @$('.js-inbound-acknowledge .js-next').off('click.verify').on('click.verify', (e) =>
-        e.preventDefault()
-        @verify(@account)
-      )
+      @$('.js-inbound-acknowledge .js-messageFound').remove()
+
     @showSlide('js-inbound-acknowledge')
 
-  probeInboundArchive: (data) =>
-    if data.archive_possible isnt true
-      @$('.js-archiveMessage').addClass('hide')
-      return
+    targetStateTypeIds = _.map(
+      App.TicketStateType.search(filter:
+        name: ['closed', 'open', 'new']
+      ),
+      (stateType) -> stateType.id
+    )
 
-    @$('.js-archiveMessage').removeClass('hide')
+    targetStateOptions = _.map(
+      App.TicketState.search(filter:
+        state_type_id: targetStateTypeIds
+        active: true
+      ),
+      (targetState) ->
+        value: targetState.id
+        name: targetState.name
+    )
 
-    if data.archive_possible_is_fallback is true
-      message = App.i18n.translateContent('Since the mail server does not support sorting messages by date, it was not possible to detect if there is any mail older than %s weeks in the connected mailbox. 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.', data.archive_week_range)
-    else
-      message = App.i18n.translateContent('In addition, emails were found 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.', data.archive_week_range)
-    @$('.js-inbound-acknowledge .js-archiveMessageCount').html(message)
+    stateTypeClosed = App.TicketStateType.findByAttribute('name', 'closed')
+    targetStateDefault = App.TicketState.findByAttribute('state_type_id', stateTypeClosed.id)
 
     configureAttributesAcknowledge = [
-      {
-        name: 'archive'
-        tag: 'boolean'
-        null: true
-        default: no
-        options: {
-          true: 'archive'
-          false: 'regular'
-        }
-        translate: true
-      },
+      { name: 'archive', display: __('Archive emails'), tag: 'switch', label_class: 'hidden', default: true },
+      { name: 'archive_before', display: __('Archive cut-off time'), tag: 'datetime', null: false, help: __('Emails before the cut-off time are imported as archived tickets. Emails after the cut-off time are imported as regular tickets.') },
+      { name: 'archive_state_id', display: __('Archive ticket target state'), tag: 'select', null: true, options: targetStateOptions, default: targetStateDefault.id },
     ]
 
-    new App.ControllerForm(
-      elReplace: @$('.js-importTypeSelect'),
+    options =
+      archive_before: @channel?.options.inbound.options.archive_before
+      archive_state_id: parseInt(@channel?.options.inbound.options.archive_state_id, 10)
+
+    if not _.isUndefined(@channel?.options.inbound.options.archive)
+      options.archive = @channel.options.inbound.options.archive
+
+    form = new App.ControllerForm(
+      elReplace: @$('.js-archiveSettings'),
       model:
         configure_attributes: configureAttributesAcknowledge
         className: ''
-      noFieldset: true
+      handlers: [
+        App.FormHandlerChannelAccountArchiveMode.run
+      ]
+      params: options
     )
-    @$('.js-importTypeSelect select[name=archive]').on('change', (e) =>
-      value                      = $(e.target).val()
+
+    @$('.js-inbound-acknowledge .js-next').off('click.continue').on('click.continue', (e) =>
+      e.preventDefault()
+
+      # get params
+      params = @formParam(e.target)
+
+      # validate form
+      errors = form.validate(params)
+
+      # show errors in form
+      if errors
+        @log 'error', errors
+        @formValidate(form: @$('.js-archiveSettings'), errors: errors)
+        return false
+
       @account.inbound         ||= {}
       @account.inbound.options ||= {}
-      if value is 'true'
-        @account.inbound.options.archive        = true
-        @account.inbound.options.archive_before = (new Date()).toISOString()
+      @account.inbound.options = _.extend(@account.inbound.options, params)
+
+      if !verify
+        @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound')
+        @$('.js-inbound-acknowledge .js-next').off('click.verify')
       else
-        delete @account.inbound.options.archive
-        delete @account.inbound.options.archive_before
+        @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
+        @$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
+        @$('.js-inbound-acknowledge .js-next').off('click.verify').on('click.verify', (e) =>
+          e.preventDefault()
+          @verify(@account)
+        )
     )
-    @$('.js-importTypeSelect select[name=archive]').trigger('change')
 
   probleOutbound: (e) =>
     e.preventDefault()
@@ -778,25 +797,33 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
   verify: (account, count = 0) =>
     @showSlide('js-verify')
 
+    # use jquery instead of ._clone() because we need a deep copy of the obj
+    params = $.extend({}, account)
+
     # let backend know about the channel
     if @channel
-      account.channel_id = @channel.id
+      params.channel_id = @channel.id
 
-    if account.meta.group_id
-      account.group_id = account.meta.group_id
+    if params.meta.group_id
+      params.group_id = params.meta.group_id
     else if @channel.group_id
-      account.group_id = @channel.group_id
+      params.group_id = @channel.group_id
 
-    if !account.email && @channel
+    if !params.email && @channel
       email_addresses = App.EmailAddress.search(filter: { channel_id: @channel.id })
       if email_addresses && email_addresses[0]
-        account.email = email_addresses[0].email
+        params.email = email_addresses[0].email
+
+    if params.inbound?.options?.password is @passwordPlaceholder
+      params.inbound.options.password = @inboundPassword
+    if params.outbound?.options?.password is @passwordPlaceholder
+      params.outbound.options.password = @outboundPassword
 
     @ajax(
       id:   'email_verify'
       type: 'POST'
       url:  "#{@apiPath}/channels_email_verify"
-      data: JSON.stringify(account)
+      data: JSON.stringify(params)
       processData: true
       success: (data, status, xhr) =>
         if data.result is 'ok'

+ 77 - 0
app/assets/javascripts/app/controllers/_channel/email_archive.coffee

@@ -0,0 +1,77 @@
+# Currently used only by cloud email channels, like: Google, Microsoft, etc.
+class App.ChannelInboundEmailArchive extends App.ControllerModal
+  buttonClose: true
+  buttonCancel: true
+  buttonSubmit: true
+  head: __('Archive Emails')
+  small: true
+
+  content: ->
+    content = $( App.view('channel/email_archive')(content_messages: @content_messages) )
+
+    targetStateTypeIds = _.map(
+      App.TicketStateType.search(filter:
+        name: ['closed', 'open', 'new']
+      ),
+      (stateType) -> stateType.id
+    )
+
+    targetStateOptions = _.map(
+      App.TicketState.search(filter:
+        state_type_id: targetStateTypeIds
+        active: true
+      ),
+      (targetState) ->
+        value: targetState.id
+        name: targetState.name
+    )
+
+    stateTypeClosed = App.TicketStateType.findByAttribute('name', 'closed')
+    targetStateDefault = App.TicketState.findByAttribute('state_type_id', stateTypeClosed.id)
+
+    configureAttributesAcknowledge = [
+      { name: 'options::archive', display: __('Archive emails'), tag: 'switch', label_class: 'hidden', default: true },
+      { name: 'options::archive_before', display: __('Archive cut-off time'), tag: 'datetime', null: false, help: __('Emails before the cut-off time are imported as archived tickets. Emails after the cut-off time are imported as regular tickets.') },
+      { name: 'options::archive_state_id', display: __('Archive ticket target state'), tag: 'select', null: true, options: targetStateOptions, default: targetStateDefault.id },
+    ]
+
+    options =
+      archive_before: @item.options.inbound.options.archive_before
+      archive_state_id: parseInt(@item.options.inbound.options.archive_state_id, 10)
+
+    if not _.isUndefined(@item.options.inbound.options.archive)
+      options.archive = @item.options.inbound.options.archive
+
+    @form = new App.ControllerForm(
+      el: content.find('.js-archiveSettings')
+      model:
+        configure_attributes: configureAttributesAcknowledge
+        className: ''
+      handlers: [
+        App.FormHandlerChannelAccountArchiveMode.run
+      ]
+      attributePrefix: 'options::'
+      params:
+        options: options
+    )
+
+    content
+
+  onSubmit: (e) =>
+    # get params
+    params = @formParam(e.target)
+
+    # validate form
+    errors = @form.validate(params)
+
+    # show errors in form
+    if errors
+      @log 'error', errors
+      @formValidate(form: @form.form, errors: errors)
+      return false
+
+    # use jQuery's extend for deep extending
+    $.extend(true, params, @inboundParams)
+
+    @callback(params)
+    @close()

+ 26 - 0
app/assets/javascripts/app/controllers/_channel/form_handler_channel_account_archive_mode.coffee

@@ -0,0 +1,26 @@
+class App.FormHandlerChannelAccountArchiveMode
+  @run: (params, attribute, attributes, classname, form, ui) ->
+    attributePrefix = ui.attributePrefix || ''
+    return if attribute.name isnt "#{attributePrefix}archive"
+
+    return if ui.FormHandlerChannelAccountArchiveModeDone
+    ui.FormHandlerChannelAccountArchiveModeDone = true
+
+    archiveField = $(form).find("input[name='#{attributePrefix}archive']")
+
+    toggleCallback = (field) ->
+      archive = field.is(':checked')
+      for attr in attributes
+        continue if attr.name isnt "#{attributePrefix}archive_before" and attr.name isnt "#{attributePrefix}archive_state_id"
+        attr.hide = !archive
+        attr.null = !archive
+        newElement = ui.formGenItem(attr, classname, form)
+        form.find('div.form-group[data-attribute-name="' + attr.name + '"]').replaceWith(newElement)
+
+    archiveField
+      .off('change.archive_mode')
+      .on('change.archive_mode', (e) ->
+        toggleCallback($(e.target))
+      )
+
+    toggleCallback(archiveField)

+ 36 - 9
app/assets/javascripts/app/controllers/_channel/google.coffee

@@ -200,7 +200,7 @@ class ChannelAccountOverview extends App.ControllerSubContent
       container: @el.closest('.content')
       item: item
       callback: @load
-      set_active: set_active,
+      set_active: set_active
     )
 
   rollbackMigration: (e) =>
@@ -305,27 +305,54 @@ class ChannelInboundEdit extends App.ControllerModal
     # disable form
     @formDisable(e)
 
+    # probe
+    @ajax(
+      id:   'channel_email_inbound'
+      type: 'POST'
+      url:  "#{@apiPath}/channels_google_inbound/#{@item.id}"
+      data: JSON.stringify(params)
+      processData: true
+      success: (data, status, xhr) =>
+        if data.content_messages or not @set_active
+          new App.ChannelInboundEmailArchive(
+            container: @el.closest('.content')
+            item: @item
+            content_messages: data.content_messages
+            inboundParams: params
+            callback: @verify
+          )
+          @close()
+          return
+
+        @verify(params)
+
+      error: (xhr) =>
+        data = JSON.parse(xhr.responseText)
+        @stopLoading()
+        @formEnable(e)
+        @el.find('.alert--danger').removeClass('hide').text(data.error_human || data.error || __('The changes could not be saved.'))
+    )
+
+  verify: (params = {}) =>
+    @startLoading()
+
     if @set_active
       params['active'] = true
 
     # update
     @ajax(
-      id:   'channel_email_inbound'
+      id:   'channel_email_verify'
       type: 'POST'
-      url:  "#{@apiPath}/channels_google_inbound/#{@item.id}"
+      url:  "#{@apiPath}/channels_google_verify/#{@item.id}"
       data: JSON.stringify(params)
       processData: true
       success: (data, status, xhr) =>
         @callback(true)
         @close()
       error: (xhr) =>
+        data = JSON.parse(xhr.responseText)
         @stopLoading()
-        @formEnable(e)
-        details = xhr.responseJSON || {}
-        @notify
-          type:    'error'
-          msg:     details.error_human || details.error || __('The changes could not be saved.')
-          timeout: 6000
+        @el.find('.alert--danger').removeClass('hide').text(data.error_human || data.error || __('The changes could not be saved.'))
     )
 
 class ChannelGroupEdit extends App.ControllerModal

+ 35 - 5
app/assets/javascripts/app/controllers/_channel/microsoft365.coffee

@@ -216,8 +216,8 @@ class ChannelAccountOverview extends App.ControllerSubContent
       container: @el.closest('.content')
       item: item
       callback: @load
-      set_active: set_active,
-      redirect: redirect,
+      set_active: set_active
+      redirect: redirect
     )
 
   rollbackMigration: (e) =>
@@ -322,14 +322,45 @@ class ChannelInboundEdit extends App.ControllerModal
     # disable form
     @formDisable(e)
 
+    # probe
+    @ajax(
+      id:   'channel_email_inbound'
+      type: 'POST'
+      url:  "#{@apiPath}/channels_microsoft365_inbound/#{@item.id}"
+      data: JSON.stringify(params)
+      processData: true
+      success: (data, status, xhr) =>
+        if data.content_messages or not @set_active
+          new App.ChannelInboundEmailArchive(
+            container: @el.closest('.content')
+            item: @item
+            content_messages: data.content_messages
+            inboundParams: params
+            callback: @verify
+          )
+          @close()
+          return
+
+        @verify(params)
+
+      error: (xhr) =>
+        data = JSON.parse(xhr.responseText)
+        @stopLoading()
+        @formEnable(e)
+        @el.find('.alert--danger').removeClass('hide').text(data.error_human || data.error || __('The changes could not be saved.'))
+    )
+
+  verify: (params = {}) =>
+    @startLoading()
+
     if @set_active
       params['active'] = true
 
     # update
     @ajax(
-      id:   'channel_email_inbound'
+      id:   'channel_email_verify'
       type: 'POST'
-      url:  "#{@apiPath}/channels_microsoft365_inbound/#{@item.id}"
+      url:  "#{@apiPath}/channels_microsoft365_verify/#{@item.id}"
       data: JSON.stringify(params)
       processData: true
       success: (data, status, xhr) =>
@@ -338,7 +369,6 @@ class ChannelInboundEdit extends App.ControllerModal
       error: (xhr) =>
         data = JSON.parse(xhr.responseText)
         @stopLoading()
-        @formEnable(e)
         @el.find('.alert--danger').removeClass('hide').text(data.error_human || data.error || __('The changes could not be saved.'))
     )
 

+ 34 - 4
app/assets/javascripts/app/controllers/_channel/microsoft_graph.coffee

@@ -253,7 +253,7 @@ class ChannelAccountOverview extends App.ControllerSubContent
       container: @el.closest('.content')
       item: item
       callback: @load
-      set_active: set_active,
+      set_active: set_active
       redirect: redirect
     )
 
@@ -503,14 +503,45 @@ class ChannelInboundEdit extends App.ControllerModal
 
     @startLoading()
 
+    # probe
+    @ajax(
+      id:   'channel_email_inbound'
+      type: 'POST'
+      url:  "#{@apiPath}/channels/admin/microsoft_graph/inbound/#{@item.id}"
+      data: JSON.stringify(params)
+      processData: true
+      success: (data, status, xhr) =>
+        if data.content_messages or not @set_active
+          new App.ChannelInboundEmailArchive(
+            container: @el.closest('.content')
+            item: @item
+            content_messages: data.content_messages
+            inboundParams: params
+            callback: @verify
+          )
+          @close()
+          return
+
+        @verify(params)
+
+      error: (xhr) =>
+        data = JSON.parse(xhr.responseText)
+        @stopLoading()
+        @formEnable(e)
+        @el.find('.alert--danger').removeClass('hide').text(data.error_human || data.error || __('The changes could not be saved.'))
+    )
+
+  verify: (params = {}) =>
+    @startLoading()
+
     if @set_active
       params['active'] = true
 
     # update
     @ajax(
-      id:   'channel_email_inbound'
+      id:   'channel_email_verify'
       type: 'POST'
-      url:  "#{@apiPath}/channels/admin/microsoft_graph/inbound/#{@item.id}"
+      url:  "#{@apiPath}/channels/admin/microsoft_graph/verify/#{@item.id}"
       data: JSON.stringify(params)
       processData: true
       success: (data, status, xhr) =>
@@ -519,7 +550,6 @@ class ChannelInboundEdit extends App.ControllerModal
       error: (xhr) =>
         data = JSON.parse(xhr.responseText)
         @stopLoading()
-        @formEnable(e)
         @el.find('.alert--danger').removeClass('hide').text(data.error_human || data.error || __('The changes could not be saved.'))
     )
 

+ 65 - 48
app/assets/javascripts/app/controllers/getting_started/channel_email.coffee

@@ -187,9 +187,8 @@ class GettingStartedChannelEmail extends App.ControllerWizardFullScreen
             for key, value of data.setting
               @account[key] = value
 
-          if data.content_messages && data.content_messages > 0 && (!@account['inbound']['options'] || @account['inbound']['options']['keep_on_server'] isnt true)
-            @probeInboundMessagesFound(data, true)
-            @probeInboundArchive(data)
+          if data.content_messages
+            @probeInboundArchive(data, true)
           else
             @verify(@account)
 
@@ -229,8 +228,7 @@ class GettingStartedChannelEmail extends App.ControllerWizardFullScreen
           # remember account settings
           @account.inbound = params
 
-          if data.content_messages && data.content_messages > 0 && (!@account['inbound']['options'] || @account['inbound']['options']['keep_on_server'] isnt true)
-            @probeInboundMessagesFound(data, false)
+          if data.content_messages
             @probeInboundArchive(data)
           else
             @showSlide('js-outbound')
@@ -257,68 +255,87 @@ class GettingStartedChannelEmail extends App.ControllerWizardFullScreen
         @enable(e)
     )
 
-  probeInboundMessagesFound: (data, verify) =>
-    message = App.i18n.translateContent('%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.', data.content_messages)
-    @$('.js-inbound-acknowledge .js-messageFound').html(message)
-
-    if !verify
-      @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound')
-      @$('.js-inbound-acknowledge .js-next').off('click.verify')
+  probeInboundArchive: (data, verify) =>
+    if data.content_messages
+      message = App.i18n.translateContent('%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.', data.content_messages)
+      @$('.js-inbound-acknowledge .js-messageFound').html(message)
     else
-      @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
-      @$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
-      @$('.js-inbound-acknowledge .js-next').off('click.verify').on('click.verify', (e) =>
-        e.preventDefault()
-        @verify(@account)
-      )
+      @$('.js-inbound-acknowledge .js-messageFound').remove()
+
     @showSlide('js-inbound-acknowledge')
 
-  probeInboundArchive: (data) =>
-    if data.archive_possible isnt true
-      @$('.js-archiveMessage').addClass('hide')
-      return
+    targetStateTypeIds = _.map(
+      App.TicketStateType.search(filter:
+        name: ['closed', 'open', 'new']
+      ),
+      (stateType) -> stateType.id
+    )
 
-    @$('.js-archiveMessage').removeClass('hide')
+    targetStateOptions = _.map(
+      App.TicketState.search(filter:
+        state_type_id: targetStateTypeIds
+        active: true
+      ),
+      (targetState) ->
+        value: targetState.id
+        name: targetState.name
+    )
 
-    if data.archive_possible_is_fallback is true
-      message = App.i18n.translateContent('Since the mail server does not support sorting messages by date, it was not possible to detect if there is any mail older than %s weeks in the connected mailbox. 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.', data.archive_week_range)
-    else
-      message = App.i18n.translateContent('In addition, emails were found 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.', data.archive_week_range)
-    @$('.js-inbound-acknowledge .js-archiveMessageCount').html(message)
+    stateTypeClosed = App.TicketStateType.findByAttribute('name', 'closed')
+    targetStateDefault = App.TicketState.findByAttribute('state_type_id', stateTypeClosed.id)
 
     configureAttributesAcknowledge = [
-      {
-        name: 'archive'
-        tag: 'boolean'
-        null: true
-        default: no
-        options: {
-          true: 'archive'
-          false: 'regular'
-        }
-        translate: true
-      },
+      { name: 'archive', display: __('Archive emails'), tag: 'switch', label_class: 'hidden', default: true },
+      { name: 'archive_before', display: __('Archive cut-off time'), tag: 'datetime', null: false, help: __('Emails before the cut-off time are imported as archived tickets. Emails after the cut-off time are imported as regular tickets.') },
+      { name: 'archive_state_id', display: __('Archive ticket target state'), tag: 'select', null: true, options: targetStateOptions, default: targetStateDefault.id },
     ]
 
-    new App.ControllerForm(
-      elReplace: @$('.js-importTypeSelect'),
+    form = new App.ControllerForm(
+      elReplace: @$('.js-archiveSettings'),
       model:
         configure_attributes: configureAttributesAcknowledge
         className: ''
-      noFieldset: true
+      handlers: [
+        App.FormHandlerChannelAccountArchiveMode.run
+      ]
     )
-    @$('.js-importTypeSelect select[name=archive]').on('change', (e) =>
-      value                      = $(e.target).val()
+
+    @$('.js-inbound-acknowledge .js-next').off('click.continue').on('click.continue', (e) =>
+      e.preventDefault()
+
+      # get params
+      params = @formParam(e.target)
+
+      # validate form
+      errors = form.validate(params)
+
+      # show errors in form
+      if errors
+        @log 'error', errors
+        @formValidate(form: @$('.js-archiveSettings'), errors: errors)
+        return false
+
       @account.inbound         ||= {}
       @account.inbound.options ||= {}
-      if value is 'true'
-        @account.inbound.options.archive        = true
-        @account.inbound.options.archive_before = (new Date()).toISOString()
+
+      if params.archive
+        @account.inbound.options = _.extend(@account.inbound.options, params)
       else
         delete @account.inbound.options.archive
         delete @account.inbound.options.archive_before
+        delete @account.inbound.options.archive_state_id
+
+      if !verify
+        @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound')
+        @$('.js-inbound-acknowledge .js-next').off('click.verify')
+      else
+        @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
+        @$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
+        @$('.js-inbound-acknowledge .js-next').off('click.verify').on('click.verify', (e) =>
+          e.preventDefault()
+          @verify(@account)
+        )
     )
-    @$('.js-importTypeSelect select[name=archive]').trigger('change')
 
   probleOutbound: (e) =>
     e.preventDefault()

+ 5 - 17
app/assets/javascripts/app/views/channel/email_account_wizard.jst.eco

@@ -106,27 +106,15 @@
       <div class="modal-close js-close">
         <%- @Icon('diagonal-cross') %>
       </div>
-      <h1 class="modal-title"><%- @T('Email Inbound') %></h1>
+      <h1 class="modal-title"><%- @T('Archive Emails') %></h1>
     </div>
     <div class="modal-body">
       <div class="wizard-body vertical justified">
         <div class="alert alert--danger hide" role="alert"></div>
-        <p class="js-messageFound"><%- @T('%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.', 'x') %></p>
-
-        <div class="js-archiveMessage">
-          <p class="js-archiveMessageCount"><%- @T('In addition, emails were found 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.', 'x') %></p>
-
-          <p><%- @T('Should the emails from this mailbox be imported as an archive or as regular emails?') %></p>
-
-          <ul>
-            <li><%- @T('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.') %></li>
-            <li><%- @T('Import as regular: |Notifications are sent| and the |tickets are open| - you can find the tickets in the overview of open tickets.') %></li>
-          </ul>
-
-          <p class="js-importType">
-            Import as: <span class="js-importTypeSelect"></span>
-          </p>
-        </div>
+        <p class="js-messageFound"></p>
+        <p><%- @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.') %></p>
+        <p><%- @T('You can find archived emails in Zammad anytime using the search function, like for any other ticket.') %></p>
+        <div class="js-archiveSettings"></div>
         <div class="inbound-acknowledge-settings"></div>
       </div>
     </div>

+ 9 - 0
app/assets/javascripts/app/views/channel/email_archive.jst.eco

@@ -0,0 +1,9 @@
+<div>
+  <div class="alert alert--danger hide" role="alert"></div>
+  <% if @content_messages: %>
+    <p><%- @T('%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.', @content_messages) %></p>
+  <% end %>
+  <p><%- @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.') %></p>
+  <p><%- @T('You can find archived emails in Zammad anytime using the search function, like for any other ticket.') %></p>
+  <div class="js-archiveSettings"></div>
+</div>

+ 5 - 17
app/assets/javascripts/app/views/getting_started/email.jst.eco

@@ -81,28 +81,16 @@
 
   <form class="setup wizard hide js-inbound-acknowledge">
     <div class="wizard-slide">
-      <h2><%- @T('Email Inbound') %></h2>
+      <h2><%- @T('Archive Emails') %></h2>
       <div class="wizard-body vertical justified">
         <div class="alert alert--danger hide" role="alert"></div>
         <div class="alert alert--warning js-sslVerifyAlert hide" role="alert">
           <%- @T('Turning off SSL verification is a security risk and should be used only temporary. Use this option at your own risk!') %>
         </div>
-        <p class="js-messageFound"><%- @T('%s email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.', 'x') %></p>
-
-        <div class="js-archiveMessage">
-          <p class="js-archiveMessageCount"><%- @T('In addition, emails were found 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.', 'x') %></p>
-
-          <p><%- @T('Should the emails from this mailbox be imported as an archive or as regular emails?') %></p>
-
-          <ul>
-            <li><%- @T('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.') %></li>
-            <li><%- @T('Import as regular: |Notifications are sent| and the |tickets are open| - you can find the tickets in the overview of open tickets.') %></li>
-          </ul>
-
-          <p class="js-importType">
-            Import as: <span class="js-importTypeSelect"></span>
-          </p>
-        </div>
+        <p class="js-messageFound"></p>
+        <p><%- @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.') %></p>
+        <p><%- @T('You can find archived emails in Zammad anytime using the search function, like for any other ticket.') %></p>
+        <div class="js-archiveSettings"></div>
         <div class="inbound-acknowledge-settings"></div>
       </div>
       <div class="wizard-controls center">

Некоторые файлы не были показаны из-за большого количества измененных файлов