Commit 9aa0f1cd authored by Gabriel Alves's avatar Gabriel Alves
Browse files

Notificacao bootstrap adicionada

parent 8a3746fe
......@@ -12,7 +12,9 @@
<div class="container">
<div class="row justify-content-center" style="margin-top: 35px">
<div class="alert alert-danger" id="notificacao-erro" style="display: none;" role="alert">
não pode selecionar mais de 3 ods
</div>
@include('evento.formulario.projeto')
......@@ -803,8 +805,15 @@
}
}
function showAlert($id, $mensagem){
$('#notificacao-erro').html($mensagem)
$($id).fadeIn();
$($id)[0].scrollIntoView({ behavior: 'smooth' });
setTimeout(function() {
$($id).fadeOut();
}, 5000);
}
// Form dinâmico da ODS
$(document).ready(function(){
var selectedOds = [];
$('.form-check-input').change(function(){
......@@ -815,7 +824,7 @@
});
if(selectedOds.length > 3){
alert('Você só pode selecionar até 3 ODS.');
showAlert('#notificacao-erro','Você atingiu o limite maximo de ODS selecionadas(3 ODS)')
$(this).prop('checked', false);
selectedOds.pop()
}
......@@ -845,24 +854,16 @@
});
$(document).on('change', '.form-check-input', function(){
var metaCheckboxes = $('input[name^="metas"]');
var selectedMetas = {};
$(document).on('change', '.meta-checkbox', function() {
totalSelectedMetas = $('.meta-checkbox:checked').length;
metaCheckboxes.each(function(){
var odsId = $(this).attr('name').match(/metas\[(\d+)\]/)[1];
if(!selectedMetas[odsId]) selectedMetas[odsId] = [];
if($(this).prop('checked')) selectedMetas[odsId].push($(this).val());
});
for(var odsId in selectedMetas){
if(selectedMetas[odsId].length > 3){
alert('Você só pode selecionar até 3 metas por ODS.');
if (totalSelectedMetas > 3) {
showAlert('#notificacao-erro','Você atingiu o limite maximo de metas selecionadas(3 metas)')
$(this).prop('checked', false);
return;
}
}
});
});
});
</script>
@endsection
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment