diff --git a/app/assets/javascripts/app/controllers/_channel/email.coffee b/app/assets/javascripts/app/controllers/_channel/email.coffee index a7ada3b61..7c0e1af85 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.coffee @@ -428,20 +428,7 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal ui.hide('options::folder') ui.hide('options::keep_on_server') - handlePort = (params, attribute, attributes, classname, form, ui) -> - return if !params - return if !params.options - currentPort = @$('[name="options::port"]').val() - if params.options.ssl is true - if !currentPort || currentPort is '143' - @$('[name="options::port"]').val('993') - return - if params.options.ssl is false - if !currentPort || currentPort is '993' - @$('[name="options::port"]').val('143') - return - - new App.ControllerForm( + form = new App.ControllerForm( el: @$('.base-inbound-settings'), model: configure_attributes: configureAttributesInbound @@ -449,10 +436,16 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal params: @account.inbound handlers: [ showHideFolder, - handlePort, ] ) + form.el.find("select[name='options::ssl']").off('change').on('change', (e) -> + if $(e.target).val() is 'true' + form.el.find("[name='options::port']").val('993') + else + form.el.find("[name='options::port']").val('143') + ) + toggleOutboundAdapter: => # fill user / password based on intro info diff --git a/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee b/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee index 48548d553..dc94ac661 100644 --- a/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee +++ b/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee @@ -91,20 +91,7 @@ class GettingStartedChannelEmail extends App.ControllerWizardFullScreen ui.hide('options::folder') ui.hide('options::keep_on_server') - handlePort = (params, attribute, attributes, classname, form, ui) -> - return if !params - return if !params.options - currentPort = @$('.base-inbound-settings [name="options::port"]').val() - if params.options.ssl is true - if !currentPort - @$('.base-inbound-settings [name="options::port"]').val('993') - return - if params.options.ssl is false - if !currentPort || currentPort is '993' - @$('.base-inbound-settings [name="options::port"]').val('143') - return - - new App.ControllerForm( + form = new App.ControllerForm( el: @$('.base-inbound-settings') model: configure_attributes: configureAttributesInbound @@ -112,10 +99,16 @@ class GettingStartedChannelEmail extends App.ControllerWizardFullScreen params: @account.inbound handlers: [ showHideFolder, - handlePort, ] ) + form.el.find("select[name='options::ssl']").off('change').on('change', (e) -> + if $(e.target).val() is 'true' + form.el.find("[name='options::port']").val('993') + else + form.el.find("[name='options::port']").val('143') + ) + toggleOutboundAdapter: => # fill user / password based on intro info diff --git a/spec/system/channels/email_spec.rb b/spec/system/channels/email_spec.rb index 61e52b813..d5dff5963 100644 --- a/spec/system/channels/email_spec.rb +++ b/spec/system/channels/email_spec.rb @@ -161,8 +161,9 @@ RSpec.describe 'Manage > Channels > Email', type: :system do expect(find('input[name="options::port"]').value).to eq('143') port = '4242' fill_in 'options::port', with: port + field.click expect(find('input[name="options::port"]').value).to eq(port) - option_yes.select_option + fill_in 'options::folder', with: 'testabc' expect(find('input[name="options::port"]').value).to eq(port) click '.js-close' end