function updateModalEditConnectionState(e) {
  let v_e_target = e.target;
  let v_e_target_id = v_e_target.getAttribute('id');
  let v_e_value = e.target.value;
	// IDs of elements that should be disabled.
  let v_disable_list = [];
	// IDs of elements that should be enabled.
  let v_enable_list = [];
	// IDs of elements that should be required.
	let v_form_cases = ['conn_form_type'];
	let v_technology = document.getElementById('conn_form_type').value;
	let v_allow_tunnel = document.getElementById('conn_form_use_tunnel').checked;
	let v_use_connection_string = document.getElementById('conn_form_connstring').value;
	let v_has_ssh_key_file = document.getElementById('conn_form_ssh_key_input').value;

	// Case where technology is terminal.
	if (v_technology === 'terminal') {
		v_allow_tunnel = true;
		document.getElementById('conn_form_use_tunnel').checked = true;
		document.getElementById('conn_form_use_tunnel').setAttribute('disabled', true);
	}
	else {
		document.getElementById('conn_form_use_tunnel').removeAttribute('disabled');
	}

	// Checking connection string.
	if (typeof v_use_connection_string === 'string') {
		v_use_connection_string = v_use_connection_string.trim();
	}
	// Case where technology is terminal.
	if (v_technology === 'terminal') {
		v_disable_list.push('conn_form_connstring');
		v_disable_list.push('conn_form_server');
		v_disable_list.push('conn_form_port');
		v_disable_list.push('conn_form_database');
		v_disable_list.push('conn_form_user');
		v_disable_list.push('conn_form_user_pass');
	}
	// Case where technology is sqlite.
	else if (v_technology === 'sqlite') {
		// Disabled fields
		v_disable_list.push('conn_form_connstring');
		v_disable_list.push('conn_form_server');
		v_disable_list.push('conn_form_port');
		v_disable_list.push('conn_form_user');
		v_disable_list.push('conn_form_user_pass');
		// Enabled fields
		v_enable_list.push('conn_form_database');
		// Form cases will check for database.
		v_form_cases.push('conn_form_database');
	}
	// Case where connection string has value.
	else if (v_use_connection_string !== '' && v_use_connection_string !== null) {
		v_disable_list.push('conn_form_server');
		v_disable_list.push('conn_form_port');
		v_disable_list.push('conn_form_database');
		v_disable_list.push('conn_form_user');
		v_disable_list.push('conn_form_user_pass');
		// Form cases will check the connection string.
		v_form_cases.push('conn_form_connstring');
	}
	// Case where connection string is empty.
	else {
		v_enable_list.push('conn_form_server');
		v_enable_list.push('conn_form_port');
		v_enable_list.push('conn_form_database');
		v_enable_list.push('conn_form_user');
		v_enable_list.push('conn_form_user_pass');
		// Form cases will check for single connection inputs, except password.
		v_form_cases.push('conn_form_server');
		v_form_cases.push('conn_form_port');
		v_form_cases.push('conn_form_database');
		v_form_cases.push('conn_form_user');

		let v_block_conn_string = false;
		let v_check_inputs = [
      'conn_form_server',
      'conn_form_port',
      'conn_form_database',
      'conn_form_user',
      'conn_form_user_pass'
    ];
    let v_check_inputs_empty = true;
    for (let i = 0; i < v_check_inputs.length; i++) {
      var v_check_input_value = document.getElementById(v_check_inputs[i]).value;
      if (typeof v_check_input_value === 'string') {
        v_check_input_value = v_check_input_value.trim();
      }
      if (v_check_input_value !== '' && v_check_input_value !== null) {
        v_check_inputs_empty = false;
      }
    }
		// Case where at least one server single input is being type.
    if (!v_check_inputs_empty) {
			v_block_conn_string = true;
		}
		if (v_block_conn_string) {
			v_disable_list.push('conn_form_connstring');
		}
		// Case where connection string is avaiable.
    else {
      v_enable_list.push('conn_form_connstring');
			// Form cases will check the connection string.
			v_form_cases.push('conn_form_connstring');
    }
	}



	if (v_allow_tunnel) {
		v_enable_list.push('conn_form_ssh_server');
		v_enable_list.push('conn_form_ssh_port');
		v_enable_list.push('conn_form_ssh_user');
		v_enable_list.push('conn_form_ssh_password');
		v_enable_list.push('conn_form_ssh_key');
		v_enable_list.push('conn_form_ssh_key_input');
		v_form_cases.push('conn_form_ssh_server');
		v_form_cases.push('conn_form_ssh_port');
		v_form_cases.push('conn_form_ssh_user');
	}
	else {
		v_disable_list.push('conn_form_ssh_server');
		v_disable_list.push('conn_form_ssh_port');
		v_disable_list.push('conn_form_ssh_user');
		v_disable_list.push('conn_form_ssh_password');
		v_disable_list.push('conn_form_ssh_key');
		v_disable_list.push('conn_form_ssh_key_input');
	}




	if (v_e_target_id === 'conn_form_type') {
		// Case where the user picked a terminal needs to lock all server config inputs.
    if (v_e_value === 'terminal') {
      v_disable_list = [
        'conn_form_connstring',
        'conn_form_server',
        'conn_form_port',
        'conn_form_database',
        'conn_form_user',
        'conn_form_user_pass'
      ];
      v_enable_list = [
        'conn_form_ssh_server',
        'conn_form_ssh_port',
        'conn_form_ssh_user',
        'conn_form_ssh_password',
        'conn_form_ssh_key',
				'conn_form_ssh_key_input'
      ];
			document.getElementById('conn_form_use_tunnel').checked = true;
			document.getElementById('conn_form_use_tunnel').setAttribute('disabled', true);
			v_form_cases.push('conn_form_ssh_server');
			v_form_cases.push('conn_form_ssh_port');
			v_form_cases.push('conn_form_ssh_user');
    }
  }

	// Updating the fields.
	updateModalEditConnectionFields(v_disable_list, v_enable_list, v_form_cases);
}
## updateModalEditConnectionState
@desc Constructs a set of string arrays containing connection inputs that should be validated, enabled and disabled.
These arrays are constructed based on a set of rules, ex:
- conn_form_type as 'Terminal' makes:
	- required: 'conn_form_server', 'conn_form_port', 'conn_form_database'
 - enabled: 'conn_form_ssh_server', 'conn_form_ssh_port', 'conn_form_ssh_database', 'conn_form_ssh_password', 'conn_form_ssh_key', 'conn_form_ssh_key_input'
 - disabled: 'conn_form_server', 'conn_form_port', 'conn_form_database', 'conn_form_password', 'conn_form_key', 'conn_form_ssh_input'

@param  {Object} e Event.