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.
47 lines
1.6 KiB
47 lines
1.6 KiB
{% extends "crud/form.html" %}
|
|
{% load i18n %}
|
|
{% load crispy_forms_tags %}
|
|
{% load common_tags %}
|
|
|
|
{% block extra_js %}
|
|
<script language="Javascript">
|
|
|
|
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_relativa").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 %}
|
|
|