Skip to content

Commit

Permalink
Funcionalidade de deletar conjugação adicionada - v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviamattiazzo committed Sep 28, 2020
1 parent a36c36b commit 9a37be9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
17 changes: 12 additions & 5 deletions css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ h2 {

footer {
width: 100%;
height: 50px;
height: 10px;
position: absolute;
bottom: 0;
bottom: 10px;
text-align: center;
font-size: 10px;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ footer {
}

.resultados {
margin-left: 10em;
margin-left: 3em;
}

.msg-sucesso,
Expand Down Expand Up @@ -129,12 +129,14 @@ footer {
font-size: 12px;
}

.verbo-conjugado {
.verbo-conjugado,
.verbo-conjugado-export {
margin-top: 1em;
margin-bottom: 2em;
}

.verbo-conjugado h3 {
.verbo-conjugado h3,
.verbo-conjugado-export h3 {
margin-left: 1em;
margin-bottom: 0.5em;
}
Expand All @@ -143,6 +145,10 @@ footer {
margin-left: 6em;
}

.verbo-conjugado-export p {
margin-left: 2.5em;
}

.resultados button {
margin-left: 4em;
margin-top: 1.5em;
Expand All @@ -154,6 +160,7 @@ footer {

.btn-delete {
color: #d93025;
font-size: 14px;
}

.btn-delete:hover {
Expand Down
15 changes: 13 additions & 2 deletions js/controllers/ConjugacionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConjugacionController {
let campoErro = this._camposPreenchidosCorretamente();
if (campoErro)
{
this._mensagem.texto = 'É necessário preencher todos os campos!';
this._mensagem.texto = 'Es necesario llenar todos los campos!';
this._mensagem.sucesso = false;
this._mensagemView.update(this._mensagem);

Expand All @@ -36,7 +36,7 @@ class ConjugacionController {
this._listaConjugaciones.add(this._criaConjugacion());
this._conjugacionesView.update(this._listaConjugaciones);

this._mensagem.texto = 'Negociação adicionada com sucesso!';
this._mensagem.texto = 'Conjugación adicionada con éxito!';
this._mensagem.sucesso = true;
this._mensagemView.update(this._mensagem);

Expand All @@ -49,6 +49,17 @@ class ConjugacionController {
printWindow.document.close();
}

delete(infinitivo) {
console.log(infinitivo);

this._listaConjugaciones.delete(infinitivo);
this._conjugacionesView.update(this._listaConjugaciones);

this._mensagem.texto = 'Conjugación apagada con éxito!'
this._mensagem.sucesso = true;
this._mensagemView.update(this._mensagem);
}

_camposPreenchidosCorretamente() {
if (this._inputVerbo.value.trim() == '')
return this._inputVerbo;
Expand Down
13 changes: 12 additions & 1 deletion js/models/ListaConjugaciones.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ class ListaConjugaciones {
this._lstConjugaciones.push(conjugacion);
}

delete(infinitivo) {
console.log(this._getIndexOfElement(infinitivo));
this._lstConjugaciones.splice(this._getIndexOfElement(infinitivo), 1);
}

_getIndexOfElement(verboInfinitivo) {
let conjugacion = this._lstConjugaciones.find(element => element.infinitivo == verboInfinitivo);
console.log(conjugacion);
return this._lstConjugaciones.indexOf(conjugacion);
}

get listaConjugaciones() {
return [].concat(this._lstConjugaciones);
}
}
}
8 changes: 4 additions & 4 deletions js/views/ConjugacionView.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class ConjugacionView extends View {
template(model) {
return `
<h2>Resultados <i class="em em-white_check_mark" aria-role="presentation" aria-label="WHITE HEAVY CHECK MARK"></i></h2>
return model.listaConjugaciones.length == 0 ? `` :
`<h2>Resultados <i class="em em-white_check_mark" aria-role="presentation" aria-label="WHITE HEAVY CHECK MARK"></i></h2>
${model.listaConjugaciones.map(c =>
`<div class="verbo-conjugado">
<h3><button class="btn-delete"><i class="fas fa-minus-circle"></i></button> Infinitivo: ${c.infinitivo}</h3>
<h3><button class="btn-delete" onclick="conjugacionController.delete('${c.infinitivo}')"><i class="fas fa-minus-circle"></i></button> Infinitivo: ${c.infinitivo}</h3>
<p>Yo ${c.yo}</p>
<p>Tú ${c.tu}</p>
<p>Él | Ella | Usted ${c.el}</p>
Expand All @@ -23,7 +23,7 @@ class ConjugacionView extends View {
return `
<h2>Conjugaciones de verbos</h2>
${model.listaConjugaciones.map(c =>
`<div class="verbo-conjugado">
`<div class="verbo-conjugado-export">
<h3><i class="em em-arrow_right" aria-role="presentation" aria-label="BLACK RIGHTWARDS ARROW"></i> Infinitivo: ${c.infinitivo}</h3>
<p>Yo ${c.yo}</p>
<p>Tú ${c.tu}</p>
Expand Down
2 changes: 1 addition & 1 deletion js/views/FooterView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class FooterView extends View {
template() {
return `
<footer><a href="https://oliviamattiazzo.github.io/AuxiliarPronombresEspanol/">Automatizador de Pronombres</a> por <a href="https://oliviamattiazzo.dev/" target="_blank">Olivia Mattiazzo</a> - versión 1.1.0</footer>
<footer><a href="https://oliviamattiazzo.github.io/AuxiliarPronombresEspanol/">Automatizador de Pronombres</a> por <a href="https://oliviamattiazzo.dev/" target="_blank">Olivia Mattiazzo</a> - versión 1.2.0</footer>
`;
}
}

0 comments on commit 9a37be9

Please sign in to comment.