Commit 1e9b08f8a4f3c47fd533e9f9e98a43b8ff5a6f2e
Exists in
master
Merge branch 'correcao-campo-inep-id-novo-cadastro-escola'
Showing
2 changed files
with
24 additions
and
10 deletions
Show diff stats
ieducar/modules/Cadastro/Assets/Javascripts/Escola.js
| 1 | -var $submitButton = $j('#btn_enviar'); | 1 | +var $submitButton = $j('#btn_enviar'); |
| 2 | +var $escolaInepIdField = $j('#escola_inep_id'); | ||
| 3 | +var $escolaIdField = $j('#cod_escola'); | ||
| 4 | + | ||
| 5 | +$escolaInepIdField.closest('tr').hide(); | ||
| 2 | 6 | ||
| 3 | var submitForm = function(){ | 7 | var submitForm = function(){ |
| 4 | - if (validationUtils.validatesFields()) | 8 | + var canSubmit = validationUtils.validatesFields(); |
| 9 | + | ||
| 10 | + // O campo escolaInepId somente é atualizado ao cadastrar escola, uma vez que este | ||
| 11 | + // é atualizado via ajax, e durante o (novo) cadastro a escola ainda não possui id. | ||
| 12 | + // | ||
| 13 | + // #TODO refatorar cadastro de escola para que todos campos sejam enviados via ajax, | ||
| 14 | + // podendo então definir o código escolaInepId ao cadastrar a escola. | ||
| 15 | + | ||
| 16 | + if (canSubmit && $escolaIdField.val()) | ||
| 5 | putEscola(); | 17 | putEscola(); |
| 18 | + else if (canSubmit) | ||
| 19 | + acao(); | ||
| 6 | } | 20 | } |
| 7 | 21 | ||
| 8 | var handleGetEscola = function(dataResponse) { | 22 | var handleGetEscola = function(dataResponse) { |
| 9 | handleMessages(dataResponse.msgs); | 23 | handleMessages(dataResponse.msgs); |
| 10 | 24 | ||
| 11 | - $j('#escola_inep_id').val(dataResponse.escola_inep_id); | 25 | + $escolaInepIdField.val(dataResponse.escola_inep_id); |
| 12 | } | 26 | } |
| 13 | 27 | ||
| 14 | var handlePutEscola = function(dataResponse) { | 28 | var handlePutEscola = function(dataResponse) { |
| @@ -35,8 +49,8 @@ var getEscola = function(escolaId) { | @@ -35,8 +49,8 @@ var getEscola = function(escolaId) { | ||
| 35 | 49 | ||
| 36 | var putEscola = function() { | 50 | var putEscola = function() { |
| 37 | var data = { | 51 | var data = { |
| 38 | - id : $j('#cod_escola').val(), | ||
| 39 | - escola_inep_id : $j('#escola_inep_id').val() | 52 | + id : $escolaIdField.val(), |
| 53 | + escola_inep_id : $escolaInepIdField.val() | ||
| 40 | }; | 54 | }; |
| 41 | 55 | ||
| 42 | var options = { | 56 | var options = { |
| @@ -49,10 +63,10 @@ var putEscola = function() { | @@ -49,10 +63,10 @@ var putEscola = function() { | ||
| 49 | putResource(options); | 63 | putResource(options); |
| 50 | } | 64 | } |
| 51 | 65 | ||
| 52 | -var escolaId = $j('#cod_escola').val(); | ||
| 53 | - | ||
| 54 | -if (escolaId) | ||
| 55 | - getEscola(escolaId); | 66 | +if ($escolaIdField.val()) { |
| 67 | + getEscola($escolaIdField.val()); | ||
| 68 | + $escolaInepIdField.closest('tr').show(); | ||
| 69 | +} | ||
| 56 | 70 | ||
| 57 | // unbind events | 71 | // unbind events |
| 58 | $submitButton.removeAttr('onclick'); | 72 | $submitButton.removeAttr('onclick'); |
ieducar/modules/Portabilis/Assets/Version.php
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | usado pelo metodos loadJavascript e loadStylesheet do helper Portabilis_View_Helper_Application */ | 4 | usado pelo metodos loadJavascript e loadStylesheet do helper Portabilis_View_Helper_Application */ |
| 5 | 5 | ||
| 6 | class Portabilis_Assets_Version { | 6 | class Portabilis_Assets_Version { |
| 7 | - const VERSION = "0_0_0_1007"; | 7 | + const VERSION = "0_0_0_1008"; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | ?> | 10 | ?> |