From 0c72dc9e4cd0c9461c1c6c04de563c3bd87c774f Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 28 Oct 2024 08:19:32 +0100 Subject: [PATCH] use clusters in user roles --- templates/admin/user/index.html.tera | 37 ++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) 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 %}