Browse Source

Ajusta regração em JS de base/autor_form

pull/752/head
LeandroRoberto 8 years ago
parent
commit
1097ffaeaa
  1. 5
      sapl/base/forms.py
  2. 10
      sapl/templates/base/autor_form.html

5
sapl/base/forms.py

@ -225,7 +225,10 @@ class AutorForm(ModelForm):
self.fields['autor_related'].choices = [
(self.instance.autor_related.pk,
self.instance.autor_related)]
self.fields['q'].initial = self.instance.nome
self.fields['q'].initial = ''
self.fields[
'autor_related'].initial = self.instance.autor_related
if self.instance.user:
self.fields['username'].initial = self.instance.user.username

10
sapl/templates/base/autor_form.html

@ -1,3 +1,4 @@
{% extends "crud/form.html" %}
{% load i18n %}
{% block extra_js %}
@ -40,6 +41,7 @@ $(document).ready(function(){
if (atualizar) {
var radios = $("#div_id_autor_related .controls").html('');
data.models.forEach(function (val, index) {
var html_radio = '<div class="radio"><label><span class="icons"><span class="first-icon"></span><span class="second-icon"></span></span><input type="radio" name="autor_related" id="id_autor_related_'+index+'" value="'+val.value+'" style="display:none;">'+val.text+'</label></div>';
radios.append(html_radio);
});
@ -63,6 +65,11 @@ $(document).ready(function(){
}
else{
$('#id_nome, #id_q').val('');
if ($('input[name=autor_related]').length == 1 ) {
$('input[name=autor_related]').prop('checked', 'checked');
$('input[name=autor_related]').closest('.radio').addClass('checked');
}
}
}).fail(function(data) {
active('nome', atualizar);
@ -132,7 +139,8 @@ $(document).ready(function(){
});
$('input[name=action_user]:checked').trigger('change');
$('input[name=autor_related]').closest('.radio').remove();
if (flag_create)
$('input[name=autor_related]').closest('.radio').remove();
var pk = $('#id_tipo').val();
if (pk)

Loading…
Cancel
Save