Skip to content

Commit

Permalink
Merge pull request #239 from ErisvaldoCorreia/master
Browse files Browse the repository at this point in the history
Incluindo Informações sobre Versão Node e Angular no Readme
  • Loading branch information
ErisvaldoCorreia authored Dec 21, 2019
2 parents c6921bf + 7eebdff commit b83d325
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ Hora de colocar a mão na massa. A parte mais divertida, trabalhar no código-fo

### 5 MISSÃO CUMPRIDA. VC AJUDOU O PROJETO. ❤️

## Observções:
Verifique a versão do Node - Recomendamos Versão 10.x.x
Versões recentes tem apresentado instabilidades com pacotes presente no projeto.
Use o Angular 7+

# Rodar o app pela primeira vez

```bash
Expand Down
16 changes: 16 additions & 0 deletions src/app/components/input-search/input-search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,20 @@
<button class="btn btn-outline-primary" type="submit" id="button-addon2">Pesquisar</button>
</div>
</div>
<div
*ngIf="searchAlert"
#alert
class="alert alert-warning alert-dismissible fade show"
role="alert"
>
<button
type="button"
class="close"
aria-label="Close"
(click)="closeAlert()"
>
<span aria-hidden="true">&times;</span>
</button>
<strong>Você deve incluir uma palavra na pesquisa</strong>
</div>
</form>
21 changes: 19 additions & 2 deletions src/app/components/input-search/input-search.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router } from '@angular/router';

Expand All @@ -9,6 +9,7 @@ import { Router } from '@angular/router';
})
export class InputSearchComponent implements OnInit {
public searchForm: FormGroup;
public searchAlert = false;

constructor(private fb: FormBuilder, private _router: Router) {}

Expand All @@ -19,6 +20,22 @@ export class InputSearchComponent implements OnInit {
}

public search(): void {
this._router.navigate(['/book/search', this.searchForm.value.paramSearch]);
// verifica se há alguma coisa na busca - senão houver exibe um alerta e não direciona pesquisa
if (this.searchForm.value.paramSearch){
this._router.navigate(['/book/search', this.searchForm.value.paramSearch]);
this.searchAlert = false;
} else {
this.searchAlert = true;
}

}

@ViewChild("alert") alert: ElementRef;

// remove o alerta, e joga para a home do site ajustando o menu novamente sem o alerta
closeAlert() {
this.alert.nativeElement.classList.remove("show");
this._router.navigate(['/']);
this.searchAlert = false;
}
}

0 comments on commit b83d325

Please sign in to comment.