diff --git a/media/js/diagnosticos/diagnosticos_categoria_form.js b/media/js/diagnosticos/diagnosticos_categoria_form.js index 4835726..71cc7cf 100644 --- a/media/js/diagnosticos/diagnosticos_categoria_form.js +++ b/media/js/diagnosticos/diagnosticos_categoria_form.js @@ -12,12 +12,12 @@ $.ajaxSetup({ dataType: "text", beforeSend: function() { nun_ajax++ - $('#working').show() + $.mobile.showPageLoadingMsg(); }, success: function() { nun_ajax-- if (nun_ajax == 0) { - $('#working').hide() + $.mobile.hidePageLoadingMsg(); } }, error: function(msg) { @@ -35,10 +35,7 @@ $(document).ready(function() { // ao modificar o campo $("div.ui-field-contain input").change(function () { $.ajax({ - data: { - schema: this.name, - value: this.value - } + data: $('#diagnostico').serializeArray() }) }) }); diff --git a/sigi/apps/diagnosticos/forms.py b/sigi/apps/diagnosticos/forms.py index 36c4bcd..1bf15df 100644 --- a/sigi/apps/diagnosticos/forms.py +++ b/sigi/apps/diagnosticos/forms.py @@ -28,9 +28,10 @@ class DiagnosticoMobileForm(BaseDynamicEntityForm): self._build_dynamics_fields(category) def __iter__(self): - fields_by_label = [ (field.label, field) for field in self.fields.values()] - for label, field in sorted(fields_by_label): - yield BoundField(self, field, field.label) + # ordena os campos do formulario usando o atributo label + fields_by_label = [(field.label, name, field) for name, field in self.fields.items()] + for label, name, field in sorted(fields_by_label): + yield BoundField(self, field, name) def _build_dynamics_fields(self, category): """Método da classe ``BaseDynamicEntityForm`` sobrescrita, diff --git a/sigi/apps/diagnosticos/views.py b/sigi/apps/diagnosticos/views.py index 8b83861..8a02a1b 100644 --- a/sigi/apps/diagnosticos/views.py +++ b/sigi/apps/diagnosticos/views.py @@ -43,9 +43,12 @@ def categoria_detalhes(request, id_diagnostico, id_categoria): context = RequestContext(request) return render_to_response('mobile/404.html', {}) - # Criando o formulário e passando o diagnóstico selecionado - # para ser editado pelo form. - form = DiagnosticoMobileForm(instance=diagnostico, category=id_categoria) + if request.POST: + form = DiagnosticoMobileForm(request.POST, instance=diagnostico, category=id_categoria) + if form.is_valid(): + form.save() + else: + form = DiagnosticoMobileForm(instance=diagnostico, category=id_categoria) context = RequestContext(request, {'form': form, 'categoria': categoria}) return render_to_response('diagnosticos/diagnosticos_categorias_form.html', diff --git a/sigi/templates/diagnosticos/diagnosticos_categorias_form.html b/sigi/templates/diagnosticos/diagnosticos_categorias_form.html index 466a261..6e08f51 100644 --- a/sigi/templates/diagnosticos/diagnosticos_categorias_form.html +++ b/sigi/templates/diagnosticos/diagnosticos_categorias_form.html @@ -1,5 +1,10 @@ {% extends "base_mobile.html" %} +{% block media %} + {{ block.super }} + +{% endblock %} + {% block cabecalho %}