55 lines
2.9 KiB
HTML
55 lines
2.9 KiB
HTML
{% extends "base.html" %}
|
||
{% block title %}{{ _('Groups') }} · {{ appearance.name }}{% endblock %}
|
||
|
||
{% macro parent_select(choices, selected, required) %}
|
||
<label for="parent">{{ _('Parent group') }}</label>
|
||
<select id="parent" name="parent" {% if required %}required{% endif %}>
|
||
{% if not required %}<option value="">{{ _('none (top level)') }}</option>{% else %}<option value="">{{ _('Please choose') }}</option>{% endif %}
|
||
{% for g, depth in choices %}
|
||
<option value="{{ g.public_id }}" {% if selected == g.public_id | string %}selected{% endif %}>{{ '– ' * depth }}{{ g.name }}</option>
|
||
{% endfor %}
|
||
</select>
|
||
{% endmacro %}
|
||
|
||
{% block content %}
|
||
<h1>{{ _('Groups') }}</h1>
|
||
<p class="hint">{{ _('Groups bundle users, for example a department. Subgroups inherit: administrators and creators of a group also act in its subgroups, and a form shared with a group reaches the members of its subgroups.') }}</p>
|
||
<section class="card">
|
||
<table class="table">
|
||
<thead><tr><th>{{ _('Name') }}</th><th>{{ _('Description') }}</th><th>{{ _('User types') }}</th><th>{{ _('Members') }}</th></tr></thead>
|
||
<tbody>
|
||
{% for group, depth, count in tree %}
|
||
<tr>
|
||
<td class="tree-cell depth-{{ [depth, 6] | min }}">{% if depth %}<span class="tree-mark" aria-hidden="true">└</span>{% endif %}<a href="/admin/groups/{{ group.public_id }}">{{ group.name }}</a></td>
|
||
<td>{{ group.description or '' }}</td>
|
||
<td>{% if group.roles %}{% for r in group.roles %}{{ _(role_names[r]) }}{% if not loop.last %}, {% endif %}{% endfor %}{% else %}{{ _('all') }}{% endif %}</td>
|
||
<td>{{ count }}</td>
|
||
</tr>
|
||
{% else %}
|
||
<tr><td colspan="4">{{ _('No groups yet.') }}</td></tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</section>
|
||
<section class="card narrow">
|
||
<h2>{{ _('New group') }}</h2>
|
||
{% if error %}<p class="alert error" role="alert">{{ _(error) }}</p>{% endif %}
|
||
<form method="post" action="/admin/groups" class="form">
|
||
{{ csrf_field(request) }}
|
||
<label for="name">{{ _('Name') }}</label>
|
||
<input id="name" name="name" type="text" required maxlength="80" value="{{ form.name or '' }}">
|
||
<label for="description">{{ _('Description') }}</label>
|
||
<textarea id="description" name="description" rows="3" maxlength="500">{{ form.description or '' }}</textarea>
|
||
{{ parent_select(parent_choices, form.parent, parent_required) }}
|
||
<fieldset class="options-editor">
|
||
<legend>{{ _('Suitable for these user types') }}</legend>
|
||
{% for value, label in role_names.items() %}
|
||
<label class="check"><input type="checkbox" name="roles" value="{{ value }}" {% if value in (form.roles or []) %}checked{% endif %}> {{ _(label) }}</label>
|
||
{% endfor %}
|
||
<p class="hint">{{ _('Shown when creating a user of that type. None or all checked: suitable for everyone.') }}</p>
|
||
</fieldset>
|
||
<button type="submit">{{ _('Create group') }}</button>
|
||
</form>
|
||
</section>
|
||
{% endblock %}
|