From a5336608f8314504e4a41fa2ef6e400dc3760757 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Fri, 14 Oct 2022 11:35:35 +0200 Subject: [PATCH] Fix user role selection when inviting new users [SCI-7338] --- .../javascripts/users/settings/teams/invite_users_modal.js | 4 ++-- app/controllers/users/invitations_controller.rb | 2 +- app/views/shared/_invite_users_modal.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/users/settings/teams/invite_users_modal.js b/app/assets/javascripts/users/settings/teams/invite_users_modal.js index 0e642e40e..402238aa3 100644 --- a/app/assets/javascripts/users/settings/teams/invite_users_modal.js +++ b/app/assets/javascripts/users/settings/teams/invite_users_modal.js @@ -70,7 +70,7 @@ }); }); - dropdownSelector.init('#role', { + dropdownSelector.init(roleInput, { noEmptyOption: true, singleSelect: true, closeOnSelect: true, @@ -138,7 +138,7 @@ var data = { emails: dropdownSelector.getValues(emailsInput), team_ids: dropdownSelector.getValues(teamsInput), - role: dropdownSelector.getValues(roleInput), + role_id: dropdownSelector.getValues(roleInput), 'g-recaptcha-response': $('.g-recaptcha-response').val() }; diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb index c9cd54950..4b0b86cd6 100644 --- a/app/controllers/users/invitations_controller.rb +++ b/app/controllers/users/invitations_controller.rb @@ -93,7 +93,7 @@ module Users end if @teams.any? && user - @user_role ||= UserRole.find_by(name: UserRole.public_send('normal_user_role').name) + @user_role ||= UserRole.find_predefined_normal_user_role @teams.each do |team| if team.user_assignments.exists?(user: user) result[:status] = :user_exists_and_in_team diff --git a/app/views/shared/_invite_users_modal.html.erb b/app/views/shared/_invite_users_modal.html.erb index 4c94e2ed9..3c71d84ce 100644 --- a/app/views/shared/_invite_users_modal.html.erb +++ b/app/views/shared/_invite_users_modal.html.erb @@ -114,7 +114,7 @@ invite_with_team_selector = type.in?(%w(invite_new_members invite_with_team_sele
<% normal_user_role = UserRole.find_predefined_normal_user_role %> - <%= select_tag "role", + <%= select_tag "role-id", options_for_select( team_user_roles_for_select .map { |name, id| [id == normal_user_role.id ? "#{name} (#{t('invite_users.default')})" : name, id] },