{# GET /permissions/grants — crate::pages::permissions::grants::ui::GrantsTemplate One matrix per profile: objects down the side, actions across the top. Every button on the page — a single cell, a whole row, a whole profile, everything — posts the same form to /permissions/grants/apply and differs only in the list of object|action pairs it carries. The lists are built in Rust (grants::state), so the page never asks the server to work out what "all" meant. #} {% extends "ui/base.html" %} {% block title %}Access{% endblock %} {% macro apply(role, mode, pairs, label, style, hint) %}
{% for pair in pairs %}{% endfor %}
{% endmacro %} {% block content %}

Permissions

Access

What a role may do with the data. Everyone holding the role gets exactly this.

{% include "pages/permissions/tabs.html" %} {% if page.updated %}

Access updated. It applies to the next request every holder of the role makes.

{% endif %} {% if page.roles.is_empty() %}

No role to edit

There is no role here you outrank. Create one first.

{% else %}

Role

{% if !page.selected_parent.is_empty() %} {{ page.selected_role }} inherits everything {{ page.selected_parent }} has. Inherited access shows below but is changed on the parent. {% else %} {{ page.selected_role }} inherits from nothing, so what you see below is all it has. {% endif %} {% if page.selected_is_structural %} This role designs the system and may never write row data, so only the read column is open. {% endif %}

Shortcuts

These grant the wildcard objects, so they keep covering profiles and tables created later.

{% call apply(page.selected_role, "grant", page.everything_read_pairs(), "Read everything", "secondary", "Read on every profile, journal and exchange rate") %}{% endcall %} {% call apply(page.selected_role, "grant", page.everything_pairs(), "Full access to everything", "secondary", "Every action the role may hold, on every profile") %}{% endcall %} {% if page.has_direct() %} {% call apply(page.selected_role, "revoke", page.direct_pairs(), "Remove all access", "danger", "Revoke every grant this role holds directly") %}{% endcall %} {% endif %}
{% for group in page.groups %}

{% if group.global %}Everything, everywhere{% else %}Profile: {{ group.title }}{% endif %}{{ group.rows.len() }}

{% if group.has_wildcards() %} {% call apply(page.selected_role, "grant", group.read_pairs(), "Read only", "secondary", "Read on everything in here") %}{% endcall %} {% call apply(page.selected_role, "grant", group.all_pairs(), "Full access", "secondary", "Every action the role may hold, on everything in here") %}{% endcall %} {% endif %} {% if group.has_direct() %} {% call apply(page.selected_role, "revoke", group.direct_pairs(), "Clear", "danger", "Revoke everything this role holds directly in here") %}{% endcall %} {% endif %}
{% for action in page.actions() %}{% endfor %} {% for row in group.rows %} {% for cell in row.cells %} {% endfor %} {% endfor %}
Object{{ action }}Row
{{ row.label }} {% if !row.note.is_empty() %}{{ row.note }}{% endif %} {{ row.object }} {% if !cell.allowed %} · {% else if cell.direct %} {% call apply(page.selected_role, "revoke", row.one_pair(cell.action.as_str()), "✓", "cell-on", "Held directly — click to revoke") %}{% endcall %} {% else if cell.inherited %} {% else %} {% call apply(page.selected_role, "grant", row.one_pair(cell.action.as_str()), "+", "cell-off", "Click to grant") %}{% endcall %} {% endif %}
{% call apply(page.selected_role, "grant", row.all_pairs(), "All", "secondary", "Grant every action available on this object") %}{% endcall %} {% if row.has_direct() %} {% call apply(page.selected_role, "revoke", row.direct_pairs(), "None", "danger", "Revoke this object's direct grants") %}{% endcall %} {% endif %}
{% endfor %} {% endif %}
{% endblock %}