Commit 703bded3 authored by Carlos André's avatar Carlos André
Browse files

número min e max de número de participantes

parent d7e525b1
...@@ -395,20 +395,14 @@ ...@@ -395,20 +395,14 @@
</span> </span>
@enderror @enderror
</div> </div>
<div class="col-sm-1">
{{-- <a class="delete">
<img src="{{ asset('/img/icons/user-times-solid.svg') }}" style="width:25px;margin-top:35px">
</a> --}}
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@if($i != 0) <button class="btn btn-danger mt-2 mb-2 delete" style='width:100%;margin-top:10px' disabled>Limite minimo de participantes</button>
<a href='#' class="btn btn-danger mt-2 mb-2 delete" style='width:100%;margin-top:10px'>Remover participante</a>
@endif
</div> </div>
{{-- </div> {{-- </div>
...@@ -418,7 +412,7 @@ ...@@ -418,7 +412,7 @@
@endif @endif
</div> </div>
<input type="hidden" name="countParticipante" id="countParticipante" value="{{ old('countParticipante') != null ? old('countParticipante') : 1}}"> <input type="hidden" name="countParticipante" id="countParticipante" value="{{ old('countParticipante') != null ? old('countParticipante') : 1}}">
<a href="#" class="btn btn-primary" id="addCoautor" style="width:100%;margin-top:10px">Adicionar participante</a> <button class="btn btn-primary" id="addCoautor" style="width:100%;margin-top:10px">Adicionar participante</button>
</div> </div>
</div> </div>
...@@ -453,14 +447,28 @@ ...@@ -453,14 +447,28 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
var qtdLinhas = 1; var qtdLinhas = 1;
const limiteMaxParticipantes = 3;
const limiteMinParticipantes = 1;
// Coautores // Coautores
$('#addCoautor').click(function(e) { $('#addCoautor').click(function(e) {
var countParticipante = document.getElementById('countParticipante'); var countParticipante = document.getElementById('countParticipante');
if (countParticipante.value < 100) { if (countParticipante.value < limiteMaxParticipantes) {
e.preventDefault(); e.preventDefault();
linha = montarLinhaInput(); linha = montarLinhaInput();
$('#participantes').append(linha); $('#participantes').append(linha);
setParticipanteDiv(parseInt(countParticipante.value) + 1); setParticipanteDiv(parseInt(countParticipante.value) + 1);
var btnsDeletar = document.getElementsByClassName("delete");
for(var i = 0; i < btnsDeletar.length; i++) {
btnsDeletar[i].disabled = "";
$(btnsDeletar[i]).text("Remover participantes");
}
if (countParticipante.value >= limiteMaxParticipantes) {
var btn = document.getElementById('addCoautor');
btn.disabled = "true";
$('#addCoautor').text("Limite de participantes atingido");
}
} }
}); });
...@@ -484,9 +492,18 @@ ...@@ -484,9 +492,18 @@
// }); // });
$(document).on('click', '.delete', function() { $(document).on('click', '.delete', function() {
var countParticipante = document.getElementById('countParticipante'); var countParticipante = document.getElementById('countParticipante');
if (countParticipante.value >= 2) { if (countParticipante.value >= limiteMinParticipantes) {
setParticipanteDiv(parseInt(countParticipante.value) - 1); setParticipanteDiv(parseInt(countParticipante.value) - 1);
$(this).closest('#novoParticipante').remove(); $(this).closest('#novoParticipante').remove();
document.getElementById("addCoautor").disabled = "";
$('#addCoautor').text("Adicionar participante");
if (countParticipante.value == limiteMinParticipantes) {
var btnsDeletar = document.getElementsByClassName("delete");
for(var i = 0; i < btnsDeletar.length; i++) {
btnsDeletar[i].disabled = true;
$(btnsDeletar).text("Limite minimo de participantes");
}
}
return false; return false;
} }
}); });
...@@ -663,15 +680,10 @@ ...@@ -663,15 +680,10 @@
"</span>"+ "</span>"+
"@enderror"+ "@enderror"+
"</div>"+ "</div>"+
"<div class="+"col-sm-1"+">"+
"<a class="+"delete"+">"+
"<img src="+"{{ asset('/img/icons/user-times-solid.svg') }}"+" style="+"width:25px;margin-top:35px"+">"+
"</a>"+
"</div>"+
"</div>"+ "</div>"+
"</div>"+ "</div>"+
"<a href='#' class="+"'btn btn-danger mt-2 mb-2 delete'"+" style='width:100%;margin-top:10px'"+">Remover participante</a>"+ "<button href='#' class="+"'btn btn-danger mt-2 mb-2 delete'"+" style='width:100%;margin-top:10px'"+">Remover participante</button>"+
"</div>"; "</div>";
} }
......
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