Fixes #3541 - Opening user edit dialog with admin.user causes WebApp freeze for 10-20 sec. with 100+ roles.

This commit is contained in:
Martin Edenhofer 2021-05-04 14:39:25 +00:00
parent 6c9148b45b
commit 49e43aadc7

View file

@ -119,15 +119,21 @@ class App.UiElement.user_permission
if !confirm(App.i18n.translateInline('Role %s is conflicting with role %s, do you want to continue?', role.name, localRole.name, localRole.name)) if !confirm(App.i18n.translateInline('Role %s is conflicting with role %s, do you want to continue?', role.name, localRole.name, localRole.name))
item.find("[name=role_ids][value=#{role_id}]").prop('checked', false) item.find("[name=role_ids][value=#{role_id}]").prop('checked', false)
return return
item.find("[name=role_ids][value=#{localRole.id}]").prop('checked', false) item.localElement.prop('checked', false)
triggers.push item.find("[name=role_ids][value=#{localRole.id}]") triggers.push item.localElement
# if role with groups plugin is deselected, hide group selection # if role with groups plugin is deselected, hide group selection
if !checked if !checked
selectedRoleIds = []
item.find('input[name=role_ids]:checked').each( ->
selectedRoleIds.push($(@).val())
)
show = false show = false
for role_id, group of rolesWithGroupPlugin for role_id, group of rolesWithGroupPlugin
if item.find("[name=role_ids][value=#{role_id}]").prop('checked') if _.contains(selectedRoleIds, role_id.toString())
show = true show = true
break
if !show if !show
item.find('.js-groupList').addClass('hidden') item.find('.js-groupList').addClass('hidden')