mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 09:13:05 +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
|
module UserRolesHelper
|
||||||
def user_roles_collection
|
def user_roles_collection
|
||||||
Rails.cache.fetch([current_user, 'available_user_roles']) do
|
UserRole.order(id: :asc).pluck(:name, :id)
|
||||||
@user_roles_collection ||= UserRole.order(id: :asc).pluck(:name, :id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def team_user_roles_collection
|
def team_user_roles_collection
|
||||||
|
@ -17,6 +15,10 @@ module UserRolesHelper
|
||||||
.reverse!
|
.reverse!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def team_user_roles_for_select
|
||||||
|
team_user_roles_collection.pluck(:name, :id)
|
||||||
|
end
|
||||||
|
|
||||||
def managing_team_user_roles_collection
|
def managing_team_user_roles_collection
|
||||||
UserRole.where('permissions && ARRAY[?]::varchar[]', [TeamPermissions::USERS_MANAGE])
|
UserRole.where('permissions && ARRAY[?]::varchar[]', [TeamPermissions::USERS_MANAGE])
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,6 +53,10 @@ class UserRole < ApplicationRecord
|
||||||
predefined.find_by(name: UserRole.public_send('owner_role').name)
|
predefined.find_by(name: UserRole.public_send('owner_role').name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.find_predefined_normal_user_role
|
||||||
|
predefined.find_by(name: UserRole.public_send('normal_user_role').name)
|
||||||
|
end
|
||||||
|
|
||||||
def owner?
|
def owner?
|
||||||
name == I18n.t('user_roles.predefined.owner')
|
name == I18n.t('user_roles.predefined.owner')
|
||||||
end
|
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>
|
<span><%= t('invite_users.select_team_role') %></span>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="form-select">
|
<div class="form-select">
|
||||||
|
<% normal_user_role = UserRole.find_predefined_normal_user_role %>
|
||||||
<%= select_tag "role",
|
<%= select_tag "role",
|
||||||
options_for_select(UserTeam.roles.keys
|
options_for_select(
|
||||||
.map { |k| [k.humanize + (k == 'normal_user' ? " (#{t('invite_users.default')})" : ''), k] }, 'normal_user'),
|
team_user_roles_for_select
|
||||||
disabled: true, class: "role-input from-control"
|
.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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue