Doing a relayout of permissions to make it a bit easier to navigate

This commit is contained in:
Ian Roddis committed 2026-06-25 16:06:36 -03:00
1 parent 1549971a13
commit eba7896893
5 files changed
+138 -24

No files matched your search

+26 -1
View File
@@ -2,7 +2,32 @@
<td>{{ r.id }}</td>
<td>{{ r.name }}</td>
<td>{{ r.description or "" }}</td>
<td>{% for perm in r.permissions %}<span class="tag">{{ perm.name }}</span>{% endfor %}</td>
<td>
{% set role_perm_names = r.permissions | map(attribute='name') | list %}
<table class="perm-matrix">
<thead>
<tr>
<th></th>
{% for action in actions %}<th>{{ action }}</th>{% endfor %}
</tr>
</thead>
<tbody>
{% for scope in scopes %}
<tr>
<td class="perm-scope">{{ scope }}</td>
{% for action in actions %}
{% set key = scope ~ ':' ~ action %}
{% if key in perm_map %}
<td class="perm-cell">{{ '✓' if key in role_perm_names else '' }}</td>
{% else %}
<td class="perm-cell perm-na">—</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</td>
<td class="row-actions">
<button class="btn btn-ghost"
hx-get="/admin/roles/{{ r.id }}/edit"
+28 -6
View File
@@ -5,14 +5,36 @@
hx-swap="outerHTML"
class="inline-edit">
<span class="muted">#{{ r.id }} · {{ r.name }}</span>
{% set role_perm_ids = r.permissions | map(attribute='id') | list %}
<fieldset class="roles-field">
<legend>Permissions</legend>
{% for perm in permissions %}
<label class="check">
<input type="checkbox" name="permission_ids" value="{{ perm.id }}"
{{ "checked" if perm in r.permissions }}> {{ perm.name }}
</label>
{% endfor %}
<table class="perm-matrix">
<thead>
<tr>
<th></th>
{% for action in actions %}<th>{{ action }}</th>{% endfor %}
</tr>
</thead>
<tbody>
{% for scope in scopes %}
<tr>
<td class="perm-scope">{{ scope }}</td>
{% for action in actions %}
{% set key = scope ~ ':' ~ action %}
{% if key in perm_map %}
{% set p = perm_map[key] %}
<td class="perm-cell">
<input type="checkbox" name="permission_ids" value="{{ p.id }}"
{{ 'checked' if p.id in role_perm_ids }}>
</td>
{% else %}
<td class="perm-cell perm-na">—</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</fieldset>
<div class="row-actions">
<button type="submit" class="btn btn-primary">Save</button>
+26 -3
View File
@@ -12,11 +12,34 @@
<label>Description <input type="text" name="description"></label>
<fieldset class="roles-field">
<legend>Permissions</legend>
{% for perm in permissions %}
<label class="check"><input type="checkbox" name="permission_ids" value="{{ perm.id }}"> {{ perm.name }}</label>
{% if scopes %}
<table class="perm-matrix">
<thead>
<tr>
<th></th>
{% for action in actions %}<th>{{ action }}</th>{% endfor %}
</tr>
</thead>
<tbody>
{% for scope in scopes %}
<tr>
<td class="perm-scope">{{ scope }}</td>
{% for action in actions %}
{% set key = scope ~ ':' ~ action %}
{% if key in perm_map %}
{% set p = perm_map[key] %}
<td class="perm-cell"><input type="checkbox" name="permission_ids" value="{{ p.id }}"></td>
{% else %}
<td class="perm-cell perm-na">—</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<span class="muted">No permissions defined. Run the seed script.</span>
{% endfor %}
{% endif %}
</fieldset>
<button type="submit" class="btn btn-primary">Add role</button>
</form>