Skip to content
Snippets Groups Projects
Commit edf9ceaf authored by Stephanie Briere Americo's avatar Stephanie Briere Americo
Browse files

Adicionar mais de uma faixa etária

parent c9189a10
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,6 @@ function alertPublicoEmpresa(e){
if(dados.getNecessidadesNutr())
{
tabs = dados.getNecessidadesNutr().getTabelas()
for(var element in tabelas)
{
for (var e in tabs)
......@@ -92,29 +91,32 @@ function alertPublicoEmpresa(e){
}
igual =0;
}
}
else
{
for (var element in tabelas)
{
htmlCheckBoxes+="<li> <input id="+tabelas[element]+" type=checkbox>"+tabelas[element]+" </li><br>"
}
}
$("#checkBoxes").html(htmlCheckBoxes+"</ul>");
if(dados.getNecessidadesNutr()){
colunas="";
vetor=[]
vetor = dados.getNecessidadesNutr().getIdades()
console.log(vetor)
for(var object in vetor)
{
console.log(object)
colunas += "<tr><td><input type = text></input></td></tr>"
faixaIdade= vetor[object]
console.log(faixaIdade[0], faixaIdade[1])
colunas += "<tr><td><input type = text id=idadeMinima"+object+"></input></td>"
colunas +="<td><input type=text id=idadeMaxima"+object+"></input></td></tr>"
}
document.getElementById("tidades").innerHTML += colunas;
}
else
{
for (var element in tabelas)
{
htmlCheckBoxes+="<li> <input id="+tabelas[element]+" type=checkbox>"+tabelas[element]+" </li><br>"
}
}
$("#checkBoxes").html(htmlCheckBoxes+"</ul>");
}
function alertCardapioEmpresa(e){
dados = ListaEmpresas[e];
......@@ -198,9 +200,29 @@ $("#adicionaCardapioEmpresa").click(function(){
});
$("#adicionaIdadesEmpresa").click(function(){
var colunas = "<tr><td> <input type=text id = idadeCardapio></td><td style=\"width:auto;\">";
colunas += "</td></tr>"
numFaixas = $("#tidades").children().length;
backupValues = [];
numFaixas = $("#tidades").children().length;
for (var i = 0; i < numFaixas; i++){
valor = [];
valor.push(document.getElementById("idadeMinima"+i).value);
valor.push(document.getElementById("idadeMaxima"+i).value);
backupValues.push(valor);
}
var colunas = "<tr><td> <input type=text id = idadeMinima"+numFaixas+"></td><td><input type= text id = idadeMaxima"+numFaixas+">";
colunas += "</td></tr>";
console.log(colunas)
document.getElementById("tidades").innerHTML += colunas;
for (var i = 0; i < numFaixas; i++){
document.getElementById("idadeMinima"+i).value = backupValues[i][0];
document.getElementById("idadeMaxima"+i).value = backupValues[i][1];
}
});
$("#editaDadosEmpresa").click( function(){
......@@ -250,17 +272,16 @@ $("#editaPublicoEmpresa").click( function(){
tabelasDados.push(tabelas[element]);
}
}
idades = []
if(dados.getNecessidadesNutr())
{
idades = dados.getNecessidadesNutr().getIdades()
}
idades.push($("#idadeCardapio").val());
console.log($("#idadeCardapio").val())
console.log(idades);
dados.setNecessidadesNutr( new NecessidadesNutr(tabelasDados,idades) );
idades = []
numFaixas = $("#tidades").children().length;
console.log(numFaixas);
for (var i = 0; i < numFaixas; i++){
console.log(document.getElementById("idadeMinima"+i).value);
console.log(document.getElementById("idadeMaxima"+i).value);
}
//dados.setNecessidadesNutr( new NecessidadesNutr(tabelasDados,idades) );
atualizaEmpresas();
$(".ui-button").click();
});
......
......@@ -59,8 +59,8 @@
<thead>
<tr>
<td> Faixa de idade </td>
<td> Ações </td>
<td> Idade minima </td>
<td> Idade máxima </td>
</tr>
</thead>
<tbody id ="tidades">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment