mirror of https://github.com/interlegis/sapl.git
3 changed files with 111 additions and 1 deletions
@ -0,0 +1,98 @@ |
|||||
|
{% extends "crud/list.html" %} |
||||
|
{% load i18n %} |
||||
|
{% load i18n common_tags crispy_forms_tags%} |
||||
|
|
||||
|
{% block container_table_list %} |
||||
|
{% if not rows %} |
||||
|
<p>{{ NO_ENTRIES_MSG }}</p> |
||||
|
{% else %} |
||||
|
<div class="container-table"> |
||||
|
<div class="result-count">{% blocktrans with verbose_name_plural=view.verbose_name_plural %}Total de {{ verbose_name_plural }}: <strong>{{count}}</strong>{% endblocktrans %}</div> |
||||
|
<table class="table table-striped table-hover table-link-ordering"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
{% for name in headers %} |
||||
|
<th> |
||||
|
{% if view.ordered_list %} |
||||
|
<a title="{% trans 'Clique para alterar a ordem a listagem'%}" href="?o={% if 'o' not in request.GET and forloop.counter == 1 or 'o' in request.GET and forloop.counter|safe == request.GET.o %}-{%endif%}{{forloop.counter}}{{ordering_url}}"> |
||||
|
{{ name }} |
||||
|
{% if 'o' in request.GET or not view.ordering %} |
||||
|
{% if 'o' not in request.GET and forloop.counter == 1 or 'o' in request.GET and forloop.counter|safe == request.GET.o %} |
||||
|
<span class="caret top" title="{% trans 'Listado na Ordem Ascendente'%}"></span> |
||||
|
{% elif 'o' in request.GET and forloop.counter == request.GET.o|str2intabs %} |
||||
|
<span class="caret" title="{% trans 'Listado na Ordem Descendente'%}"></span> |
||||
|
{%endif%} |
||||
|
{%endif%} |
||||
|
</a> |
||||
|
{% else %} |
||||
|
{{ name }} |
||||
|
{% endif %} |
||||
|
</th> |
||||
|
{% endfor %} |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody id="sortable"> |
||||
|
{% for o in object_list %} |
||||
|
<tr data-value='{{o.id}}'> |
||||
|
<td> |
||||
|
<a href='/sistema/cronometro/{{o.id}}'>{{o}}</a> |
||||
|
</td> |
||||
|
<td> |
||||
|
{{o.duracao_cronometro}} |
||||
|
</td> |
||||
|
<td> |
||||
|
{% if o.ativo %}Sim{% else %}Não{% endif %} |
||||
|
</td> |
||||
|
<td> |
||||
|
<spam>{{o.ordenacao}}</spam> |
||||
|
</td> |
||||
|
</tr> |
||||
|
{% endfor %} |
||||
|
|
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
{% endif %} |
||||
|
|
||||
|
{% endblock container_table_list %} |
||||
|
|
||||
|
|
||||
|
{% block extra_js %} |
||||
|
<script src="https://code.jquery.com/jquery-1.12.4.js"></script> |
||||
|
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> |
||||
|
<script> |
||||
|
$(function() { |
||||
|
$( "#sortable" ).sortable({ |
||||
|
beforeStop: function( event, ui ) { |
||||
|
var order = [] |
||||
|
$("#sortable tr").each((index,obj) => { |
||||
|
if($(obj).data('value')){ |
||||
|
order.push($(obj).data('value')) |
||||
|
} |
||||
|
}) |
||||
|
console.log(order) |
||||
|
|
||||
|
$.ajax({ |
||||
|
data: {ordem:order}, |
||||
|
type: 'POST', |
||||
|
url: "{% url 'sapl.painel:ordena_cronometro' %}", |
||||
|
traditional: true, |
||||
|
headers: { |
||||
|
'X-CSRFToken': getCookie('csrftoken') |
||||
|
}, |
||||
|
success: function(data){ |
||||
|
var msg = data; |
||||
|
$( "#sortable tr td spam" ).each(function(index,obj) { |
||||
|
$(obj).text(index+1); |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
$( "#sortable" ).disableSelection(); |
||||
|
|
||||
|
|
||||
|
}); |
||||
|
</script> |
||||
|
{% endblock %} |
||||
Loading…
Reference in new issue