diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index 05cd9e5..978dd3e 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -79,12 +79,39 @@
- {# for cluster, r in roles | group_by(attribute="cluster") #} - {# cluster #} - {% for role in roles %} - {{ macros::checkbox(label=role.name, name="roles[" ~ role.id ~ "]", id=loop.index , checked=role.name in user.roles, disabled=allowed_to_edit == false) }} + {% for cluster, cluster_roles in roles | group_by(attribute="cluster") %} + + {# Determine the initially selected role within the cluster #} + {% set_global selected_role_id = "none" %} + {% for role in cluster_roles %} + {% if selected_role_id == "none" and role.name in user.roles %} + {% set_global selected_role_id = role.id %} + {% endif %} + {% endfor %} + {# Set default name to the selected role ID or first role if none selected #} + + {% endfor %} + {% for role in roles %} + {% if not role.cluster %} + {{ macros::checkbox(label=role.name, name="roles[" ~ role.id ~ "]", id=loop.index , checked=role.name in user.roles, disabled=allowed_to_edit == false) }} + {% endif %} {% endfor %} - {# endfor #}
{% if user.membership_pdf %}