Commit f37bbaf2 authored by alinetenorio's avatar alinetenorio
Browse files

old input em dados de participantes

parent c3a82172
...@@ -266,13 +266,18 @@ ...@@ -266,13 +266,18 @@
<div class="row" style="margin-top:20px"> <div class="row" style="margin-top:20px">
<div class="col-sm-12"> <div class="col-sm-12">
<div id="participantes"> <div id="participantes">
@if(old('divParticipante') == null)
@php $countParticipante = 1; @endphp
@if(old('countParticipante') != null)
@php $countParticipante = old('countParticipante') @endphp
@endif
{{$countParticipante}}
@if ($countParticipante != null && $countParticipante > 0)
@for ($i = 0; $i < $countParticipante; $i++)
<div id="novoParticipante" style="display: block;"> <div id="novoParticipante" style="display: block;">
<br> <br>
<h5>Dados do participante</h5> <h5>Dados do participante</h5>
@php
$i = 0;
@endphp
<div class="row"> <div class="row">
<div class="col-sm-5"> <div class="col-sm-5">
<label>Nome Completo*</label> <label>Nome Completo*</label>
...@@ -351,11 +356,10 @@ ...@@ -351,11 +356,10 @@
</div> </div>
</div> </div>
</div> </div>
@else @endfor
<div id="novoParticipante" style="display: none;">{{old('divParticipante')}}</div>
@endif @endif
</div> </div>
<input type="hidden" name="divParticipante" id="divParticipante" value="{{old('divParticipante')}}"></input> <input type="hidden" name="countParticipante" id="countParticipante" value="{{ old('countParticipante') != null ? old('countParticipante') : 1}}"></input>
<a href="#" class="btn btn-primary" id="addCoautor" style="width:100%;margin-top:10px">Participantes +</a> <a href="#" class="btn btn-primary" id="addCoautor" style="width:100%;margin-top:10px">Participantes +</a>
</div> </div>
</div> </div>
...@@ -391,42 +395,17 @@ ...@@ -391,42 +395,17 @@
e.preventDefault(); e.preventDefault();
linha = montarLinhaInput(); linha = montarLinhaInput();
$('#participantes').append(linha); $('#participantes').append(linha);
setParticipanteDiv(qtdParticipantes);
qtdParticipantes++; qtdParticipantes++;
setParticipanteDiv();
} }
}); });
function setParticipanteDiv(){ function setParticipanteDiv(qtdParticipante){
var participantes = document.getElementById('participantes'); var countParticipante = document.getElementById('countParticipante');
var novoParticipante = document.getElementById('novoParticipante'); countParticipante.value = qtdParticipante;
var divParticipante = document.getElementById('divParticipante');
//console.log(participantes.innerHTML);
if(novoParticipante.style.display == 'block'){
console.log('block');
divParticipante.value = participantes.innerHTML;
}else{
console.log('none');
participantes.innerHTML = divParticipante.value;
}
}
function getParticipanteDiv(){
var oldNovoParticipante = document.getElementById('oldNovoParticipante');
var participantes = document.getElementById('participantes');
var divParticipante = document.getElementById('divParticipante');
// console.log(participantes.innerHTML);
if(novoParticipante.style.display == 'none'){
console.log('none');
participantes.innerHTML = divParticipante.value;
}else{
console.log('block');
}
} }
//window.onload = setParticipanteDiv();
window.onload = getParticipanteDiv();
$('#addPlanoTrabalho').click(function(e) { $('#addPlanoTrabalho').click(function(e) {
e.preventDefault(); e.preventDefault();
if (qtdLinhas < 4) { if (qtdLinhas < 4) {
...@@ -444,6 +423,7 @@ ...@@ -444,6 +423,7 @@
$(document).on('click', '.delete', function() { $(document).on('click', '.delete', function() {
if (qtdParticipantes > 2) { if (qtdParticipantes > 2) {
qtdParticipantes--; qtdParticipantes--;
setParticipanteDiv(qtdParticipantes-1);
$(this).closest('#novoParticipante').remove(); $(this).closest('#novoParticipante').remove();
return false; return false;
} }
......
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