mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
Fix user invitation modal [SCI-7308]
This commit is contained in:
parent
c5fb97cb0c
commit
173e3b09cd
3 changed files with 15 additions and 7 deletions
|
@ -2,9 +2,7 @@
|
|||
|
||||
module UserRolesHelper
|
||||
def user_roles_collection
|
||||
Rails.cache.fetch([current_user, 'available_user_roles']) do
|
||||
@user_roles_collection ||= UserRole.order(id: :asc).pluck(:name, :id)
|
||||
end
|
||||
UserRole.order(id: :asc).pluck(:name, :id)
|
||||
end
|
||||
|
||||
def team_user_roles_collection
|
||||
|
@ -17,6 +15,10 @@ module UserRolesHelper
|
|||
.reverse!
|
||||
end
|
||||
|
||||
def team_user_roles_for_select
|
||||
team_user_roles_collection.pluck(:name, :id)
|
||||
end
|
||||
|
||||
def managing_team_user_roles_collection
|
||||
UserRole.where('permissions && ARRAY[?]::varchar[]', [TeamPermissions::USERS_MANAGE])
|
||||
end
|
||||
|
|
|
@ -53,6 +53,10 @@ class UserRole < ApplicationRecord
|
|||
predefined.find_by(name: UserRole.public_send('owner_role').name)
|
||||
end
|
||||
|
||||
def self.find_predefined_normal_user_role
|
||||
predefined.find_by(name: UserRole.public_send('normal_user_role').name)
|
||||
end
|
||||
|
||||
def owner?
|
||||
name == I18n.t('user_roles.predefined.owner')
|
||||
end
|
||||
|
|
|
@ -113,11 +113,13 @@ invite_with_team_selector = type.in?(%w(invite_new_members invite_with_team_sele
|
|||
<span><%= t('invite_users.select_team_role') %></span>
|
||||
</h4>
|
||||
<div class="form-select">
|
||||
<% normal_user_role = UserRole.find_predefined_normal_user_role %>
|
||||
<%= select_tag "role",
|
||||
options_for_select(UserTeam.roles.keys
|
||||
.map { |k| [k.humanize + (k == 'normal_user' ? " (#{t('invite_users.default')})" : ''), k] }, 'normal_user'),
|
||||
disabled: true, class: "role-input from-control"
|
||||
%>
|
||||
options_for_select(
|
||||
team_user_roles_for_select
|
||||
.map { |name, id| [id == normal_user_role.id ? "#{name} (#{t('invite_users.default')})" : name, id] },
|
||||
normal_user_role.id
|
||||
), disabled: true, class: "role-input from-control" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue