mirror of https://github.com/interlegis/sapl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
{% extends "crud/form.html" %}
|
|
{% load i18n %}
|
|
{% load crispy_forms_tags %}
|
|
{% load common_tags %}
|
|
|
|
{% block extra_js %}
|
|
<script language="Javascript">
|
|
$(document).ready(function() {
|
|
function atualiza_select_autor() {
|
|
var tipo_selecionado = $("#id_tipo_autor").val();
|
|
var autor_selecionado = $("#id_autor").val();
|
|
$("#id_autor option").remove()
|
|
if (tipo_selecionado !== undefined && tipo_selecionado !== null) {
|
|
var json_data = {
|
|
tipo : tipo_selecionado,
|
|
data_relativa : $("#id_data_relativa").val(),
|
|
legislatura_anterior: $('#id_legislatura_anterior').is(':checked'),
|
|
o: 'nome',
|
|
get_all: true
|
|
}
|
|
$.getJSON("{% url 'sapl.api:autor-possiveis' %}", json_data, function(data){
|
|
if (data) {
|
|
if (data.length > 1) {
|
|
$("#id_autor").append("<option>-----</option>");
|
|
}
|
|
$.each(data, function(idx, obj) {
|
|
$("#id_autor")
|
|
.append($("<option></option>")
|
|
.attr("value", obj.id)
|
|
.text(obj.nome));
|
|
});
|
|
$("#id_autor").val(autor_selecionado);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
$("#id_legislatura_anterior").change(function() {
|
|
atualiza_select_autor();
|
|
});
|
|
|
|
$("#id_tipo_autor").change(function() {
|
|
atualiza_select_autor();
|
|
});
|
|
$("#id_tipo_autor").trigger('change');
|
|
});
|
|
</script>
|
|
{% endblock %}
|