{% extends "admin_app.html" %}
{% from "library.j2" import action_button, custom_form_button, form_button, circle_name %}
{% block content %}
<h1>{% trans %}Manage circles{% endtrans %}</h1>
<p>{% trans %}<em>Circles</em> aim to help people who are in the same social circle find each other on your service.{% endtrans %}</p>
<p>{% trans %}Users who are in the same circle will see each other in their contact list. In addition, each circle has a group chat where the circle members are included.{% endtrans %}</p>
{%- if circles -%}
<form method="POST" action="{{ url_for(".create_invite") }}">
{{- invite_form.csrf_token -}}
<div class="elevated el-2"><table>
	<thead>
		<tr>
			<th>{% trans %}Circle name{% endtrans %}</th>
			<th class="collapsible">{% trans %}Members{% endtrans %}</th>
			<th>{% trans %}Actions{% endtrans %}</th>
		</tr>
	</thead>
	<tbody>
{% for circle in circles %}
		<tr>
			<td>{{ circle | circle_name }}</td>
			<td class="collapsible">{{ circle.members | length }}</td>
			<td class="nowrap">
				{%- call custom_form_button("create_link", invite_form.circles.name, circle.id_, slim=True, class="secondary accent") -%}
					{% trans circle_name=(circle | circle_name) %}Create invitation to circle {{ circle_name }}{% endtrans %}
				{%- endcall -%}
				{%- call action_button("people", url_for(".edit_circle", id_=circle.id_) + "#members", class="secondary") -%}
					{% trans circle_name=(circle | circle_name) %}Manage members of {{ circle_name }}{% endtrans %}
				{%- endcall -%}
				{%- call action_button("edit", url_for(".edit_circle", id_=circle.id_), class="primary") -%}
					{% trans circle_name=(circle | circle_name) %}Edit circle {{ circle_name }}{% endtrans %}
				{%- endcall -%}
			</td>
		</tr>
{% endfor %}
	</tbody>
</table></div></form>
{%- else -%}
<div class="box primary">
	<header>{% trans %}No circles{% endtrans %}</header>
	<p>{% trans %}Currently, there are no circles on this service. Use the form below to create one.{% endtrans %}</p>
</div>
{%- endif -%}
<h2>{% trans %}New circle{% endtrans %}</h2>
<form method="POST" action="{{ url_for(".create_circle") }}"><div class="form layout-expanded">
{{- create_form.csrf_token -}}
	<h2 class="form-title">{% trans %}Create circle{% endtrans %}</h2>
	<div class="f-ebox">
		{{- create_form.name.label(class="required") -}}
		{{- create_form.name -}}
	</div>
	<div class="f-bbox">
		{%- call form_button("create_group", create_form.action_create, class="primary") -%}{%- endcall -%}
	</div>
</div></form>
{% endblock %}
