Commit 87ed2fe7d923304cfaa52555db24e165eecded44
1 parent
4e1a0585
Exists in
2.9
and in
9 other branches
Ajustado campos condicionais do registro 00
Refs #3515
Showing
2 changed files
with
48 additions
and
1 deletions
Show diff stats
ieducar/modules/Cadastro/Assets/Javascripts/Escola.js
... | ... | @@ -312,6 +312,53 @@ $j(document).ready(function() { |
312 | 312 | |
313 | 313 | // fix checkboxs |
314 | 314 | $j('input:checked').val('on'); |
315 | + | |
316 | + let verificaCamposDepAdm = () => { | |
317 | + $j('#categoria_escola_privada').makeUnrequired(); | |
318 | + $j('#conveniada_com_poder_publico').makeUnrequired(); | |
319 | + $j('#mantenedora_escola_privada').makeUnrequired(); | |
320 | + $j('#cnpj_mantenedora_principal').makeUnrequired(); | |
321 | + if (obrigarCamposCenso && $j('#situacao_funcionamento').val() == '1' && $j('#dependencia_administrativa').val() == '4'){ | |
322 | + $j('#categoria_escola_privada').makeRequired(); | |
323 | + $j('#conveniada_com_poder_publico').makeRequired(); | |
324 | + $j('#mantenedora_escola_privada').makeRequired(); | |
325 | + $j('#cnpj_mantenedora_principal').makeRequired(); | |
326 | + } | |
327 | + } | |
328 | + | |
329 | + $j('#dependencia_administrativa').on('change', verificaCamposDepAdm); | |
330 | + $j('#situacao_funcionamento').on('change', verificaCamposDepAdm); | |
331 | + verificaCamposDepAdm(); | |
332 | + | |
333 | + let verificaLatitudeLongitude = () => { | |
334 | + let regex = new RegExp('^(\\-?\\d+(\\.\\d+)?)\\.\\s*(\\-?\\d+(\\.\\d+)?)\$'); | |
335 | + | |
336 | + let longitude = $j('#longitude').val(); | |
337 | + | |
338 | + if (longitude && !regex.exec(longitude)) { | |
339 | + messageUtils.error('Longitude informada inválida.'); | |
340 | + $j('#longitude').val('').focus(); | |
341 | + longitude = ''; | |
342 | + } | |
343 | + | |
344 | + let latitude = $j('#latitude').val(); | |
345 | + if (latitude && !regex.exec(latitude)) { | |
346 | + messageUtils.error('Latitude informada inválida.'); | |
347 | + $j('#latitude').val('').focus(); | |
348 | + latitude = ''; | |
349 | + } | |
350 | + $j('#latitude').makeUnrequired(); | |
351 | + $j('#longitude').makeUnrequired(); | |
352 | + | |
353 | + if (obrigarCamposCenso && (latitude || longitude)) { | |
354 | + $j('#latitude').makeRequired(); | |
355 | + $j('#longitude').makeRequired(); | |
356 | + } | |
357 | + | |
358 | + } | |
359 | + | |
360 | + $j('#latitude').on('change', verificaLatitudeLongitude); | |
361 | + $j('#longitude').on('change', verificaLatitudeLongitude); | |
315 | 362 | }); |
316 | 363 | |
317 | 364 | document.getElementById('cnpj').readOnly = true; | ... | ... |