Fix user role selection when inviting new users [SCI-7338]

This commit is contained in:
Oleksii Kriuchykhin 2022-10-14 11:35:35 +02:00
parent 58acb94977
commit a5336608f8
3 changed files with 4 additions and 4 deletions

View file

@ -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()
};

View file

@ -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

View file

@ -114,7 +114,7 @@ invite_with_team_selector = type.in?(%w(invite_new_members invite_with_team_sele
</h4>
<div class="form-select">
<% 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] },