{% load i18n %}

{% if templates %}
<p>{% translate 'Select a template to create a new message:' %}</p>
<table id="ajax_table_managed" class="table table-hover table-sm">
	<thead>
		<tr>
			<th>{% translate 'Title' %}</th>
			<th>{% translate 'Category' %}</th>
			<th>{% translate 'Severity' %}</th>
			<th>{% translate 'Hint' %}</th>
		</tr>
	</thead>
	<tbody>
		{% for template in templates %}
		<tr style="cursor: pointer;" onclick="window.location='{% url 'app_sirene:new_message' template.id %}';">
			<td>{{ template.title }}</td>
			<td>{{ template.category }}</td>
			<td>{{ template.severity }}</td>
			<td>{{ template.hint }}</td>
		</tr>
		{% endfor %}
	</tbody>
</table>

<script>
	$(document).ready( function () {
	  $('#ajax_table_managed').DataTable({
		"pageLength": 500,
		"autoWidth": false,
		order: [[0, 'asc']],
		"lengthMenu": [ [50, 500, 5000, -1], [50, 500, 5000, "All"] ]
  
	  })
	 });
  </script>


{% else %}
<p class="text-muted">{% translate 'No templates available' %}</p>
{% endif %}
