From c5e8edf70d22f83029ce049cc980e870f7d3f94a Mon Sep 17 00:00:00 2001 From: Gabriel Alves Date: Thu, 19 Sep 2024 06:12:09 -0300 Subject: [PATCH] ajuste parametrizacao aumentado para 17 e quantidade de metas relativo a card --- resources/views/evento/criarEvento.blade.php | 6 +- .../views/evento/submeterTrabalho.blade.php | 110 +++++++++++------- 2 files changed, 69 insertions(+), 47 deletions(-) diff --git a/resources/views/evento/criarEvento.blade.php b/resources/views/evento/criarEvento.blade.php index b64617d..b2fa802 100755 --- a/resources/views/evento/criarEvento.blade.php +++ b/resources/views/evento/criarEvento.blade.php @@ -59,14 +59,14 @@ @enderror - {{--
+
-
--}} +
diff --git a/resources/views/evento/submeterTrabalho.blade.php b/resources/views/evento/submeterTrabalho.blade.php index 87c455a..b3f2602 100755 --- a/resources/views/evento/submeterTrabalho.blade.php +++ b/resources/views/evento/submeterTrabalho.blade.php @@ -814,56 +814,78 @@ }, 5000); } // Form dinâmico da ODS - $(document).ready(function(){ + $(document).ready(function () { var selectedOds = []; - $('.form-check-input').change(function(){ - selectedOds = []; - $('#metas-container').empty(); - $('.form-check-input:checked').each(function(){ - selectedOds.push($(this).val()); - }); - - if(selectedOds.length > quantidadeOds){ - showAlert('#notificacao-erro',`Você atingiu o limite maximo de ODS\'s selecionadas(${quantidadeOds})`) - $(this).prop('checked', false); - selectedOds.pop() - } - - selectedOds.forEach(function(odsId){ - $.ajax({ - url: '/metas/' + odsId, - method: 'GET', - success: function(response){ - var metaOptions = '

Metas para ' + response.ods + '

' + '
'; - response.metas.forEach(function(meta){ - metaOptions += '
' + - '' + - '' + - '

' + meta.descricao + '

' + - '
'; - }); - metaOptions += '
' - $('#metas-container').append(metaOptions); - }, - error: function(jqXHR, textStatus, errorThrown){ - console.error('Erro ao carregar as metas:', textStatus, errorThrown); - alert('Erro ao carregar as metas.'); - } - }); - }); + $('.form-check-input').change(function () { + selectedOds = []; + $('#metas-container').empty(); + $('.form-check-input:checked').each(function () { + selectedOds.push($(this).val()); }); - - $(document).on('change', '.meta-checkbox', function() { - totalSelectedMetas = $('.meta-checkbox:checked').length; - - if (totalSelectedMetas > 5) { - showAlert('#notificacao-erro','Você atingiu o limite maximo de metas selecionadas(5)') - $(this).prop('checked', false); - return; + + if (selectedOds.length > quantidadeOds) { + showAlert('#notificacao-erro', `Você atingiu o limite máximo de ODS's selecionadas (${quantidadeOds})`); + $(this).prop('checked', false); + selectedOds.pop(); } + + selectedOds.forEach(function (odsId) { + $.ajax({ + url: '/metas/' + odsId, + method: 'GET', + success: function (response) { + var metaOptions = + '

Metas para ' + + response.ods + + '

' + + '
'; + response.metas.forEach(function (meta) { + metaOptions += + '
' + + '' + + '' + + '

' + + meta.descricao + + '

' + + '
'; + }); + metaOptions += '
'; + $('#metas-container').append(metaOptions); + }, + error: function (jqXHR, textStatus, errorThrown) { + console.error('Erro ao carregar as metas:', textStatus, errorThrown); + alert('Erro ao carregar as metas.'); + }, + }); + }); + }); + + $(document).on('change', '.meta-checkbox', function () { + // Get the odsId from the checkbox + var odsId = $(this).data('ods-id'); + // Count the number of selected checkboxes within the same group (odsId) + var totalSelectedMetas = $('.meta-checkbox[data-ods-id="' + odsId + '"]:checked').length; + + if (totalSelectedMetas > 3) { // Change the limit here if needed + showAlert('#notificacao-erro', 'Você atingiu o limite máximo de metas selecionadas (3) para este grupo'); + $(this).prop('checked', false); + } }); }); + @endsection \ No newline at end of file -- GitLab