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.
65 lines
2.1 KiB
65 lines
2.1 KiB
|
|
{% extends "crud/form.html" %}
|
|
{% load i18n %}
|
|
{% load crispy_forms_tags %}
|
|
{% load common_tags %}
|
|
|
|
{% block extra_js %}
|
|
|
|
<script language="Javascript">
|
|
|
|
function recuperar_numero_ano() {
|
|
var tipo = $("#id_tipo").val()
|
|
var ano = $("#id_ano").val()
|
|
|
|
if (tipo) {
|
|
$.get("/materia/recuperar-materia",{tipo: tipo, ano: ano},
|
|
function(data, status) {
|
|
$("#id_numero").val(data.numero);
|
|
$("#id_ano").val(data.ano);
|
|
console.log(data)
|
|
});
|
|
}
|
|
}
|
|
$("#id_tipo, #id_ano").change(recuperar_numero_ano);
|
|
|
|
function compare(a, b) {
|
|
if (a.text < b.text)
|
|
return -1;
|
|
if (a.text > b.text)
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$("#id_tipo_autor").change(function() {
|
|
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_apresentacao").val()
|
|
}
|
|
$.getJSON("/api/autor/possiveis", json_data, function(data){
|
|
if (data) {
|
|
var results = data.sort(compare);
|
|
if (results.length > 1) {
|
|
$("#id_autor").append("<option>-----</option>");
|
|
}
|
|
$.each(results, function(idx, obj) {
|
|
$("#id_autor")
|
|
.append($("<option></option>")
|
|
.attr("value", obj.value)
|
|
.text(obj.text));
|
|
});
|
|
$("#id_autor").val(autor_selecionado);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$("#id_tipo_autor").trigger('change');
|
|
});
|
|
</script>
|
|
|
|
{% endblock %}
|
|
|