Skip to content

Commit

Permalink
partes mais importantes finalizadas
Browse files Browse the repository at this point in the history
  • Loading branch information
VDR-Crowley committed Oct 9, 2020
1 parent dfed9e1 commit cfb860b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
19 changes: 18 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Bd {
continue
}

despesa.id = i
despesas.push(despesa)
}
return despesas
Expand Down Expand Up @@ -100,6 +101,9 @@ class Bd {
return despesasFiltadas
}

remover(id) {
localStorage.removeItem(id)
}
}

let bd = new Bd()
Expand Down Expand Up @@ -180,7 +184,7 @@ function carregaListaDespesas(despesas = new Array(), filtro = false) {
listaDespesas.innerHTML = ''

// percorrer o array despesas listando cada despesa de forma dinâmica
despesas.forEach(function(d) {
despesas.forEach(d => {
//console.log(d)
// Criando a linha tr
let linha = listaDespesas.insertRow()
Expand All @@ -205,6 +209,19 @@ function carregaListaDespesas(despesas = new Array(), filtro = false) {
linha.insertCell(2).innerHTML = d.descricao
linha.insertCell(3).innerHTML = d.valor

// Criar um botão para exclusão
let btn = document.createElement('button')
btn.className = 'btn btn-danger'
btn.innerHTML = '<i class="fas fa-times"></i>'
btn.id = `id_despesa_${d.id}`
btn.onclick = function() {
let id = this.id.replace('id_despesa_', '')

bd.remover(id)

window.location.reload()
}
linha.insertCell(4).append(btn)
})

}
Expand Down
4 changes: 3 additions & 1 deletion consulta.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ <h1 class="display-4">Consulta de despesas</h1>
<div class="col-md-2">
<select class="form-control" id="ano">
<option value="">Ano</option>
<option value="2018">2018</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
</select>
</div>

Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ <h1 class="display-4">Registro de nova despesa</h1>
<select class="form-control" id="ano">
<option value="">Ano</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
</select>
</div> <!-- Fim ano -->

Expand Down

0 comments on commit cfb860b

Please sign in to comment.