-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from GoogolApp/filterMatches
Filter matches
- Loading branch information
Showing
8 changed files
with
166 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<ion-header> | ||
<ion-navbar> | ||
<ion-title>Filtros</ion-title> | ||
<ion-buttons end> | ||
<button ion-button (click)="dismiss()"> | ||
<ion-icon name="close"></ion-icon> | ||
</button> | ||
</ion-buttons> | ||
</ion-navbar> | ||
</ion-header> | ||
|
||
<ion-content padding class="content"> | ||
<ion-list> | ||
<ion-item> | ||
<ion-label>Campeonato</ion-label> | ||
<ion-select id="Liga/Campeonato" [(ngModel)]="selectedLeagues" multiple="true"> | ||
<ion-option *ngFor="let league of leagues" [value]="league">{{ league }}</ion-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-list> | ||
|
||
<ion-list> | ||
<ion-item> | ||
<ion-label>Time/Seleção</ion-label> | ||
<ion-select id="Time/Seleção" [(ngModel)]="selectedTeams" multiple="true"> | ||
<ion-option *ngFor="let team of teams" [value]="team">{{ team }}</ion-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-list> | ||
|
||
<ion-list> | ||
<ion-item> | ||
<ion-label>Apenas times favoritos</ion-label> | ||
<ion-toggle [(ngModel)]="favorites" color="royal" checked="false"></ion-toggle> | ||
</ion-item> | ||
</ion-list> | ||
|
||
<ion-buttons> | ||
<button ion-button float-left color="secondary" (click)="applyFilters()"> | ||
Aplicar filtros | ||
</button> | ||
|
||
<button ion-button float-right color="danger" (click)="clearFilters()"> | ||
Remover filtros | ||
</button> | ||
</ion-buttons> | ||
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.content { | ||
//background-color: rgba(0, 0, 0, 0.5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
import { NavController, ViewController, NavParams } from "ionic-angular/"; | ||
import { Match } from "../../../../_models/match"; | ||
|
||
@Component({ | ||
selector: 'filter-matches', | ||
templateUrl: 'filter-matches.html' | ||
}) | ||
export class FilterMatchesModal implements OnInit{ | ||
constructor(public navCtrl: NavController, public viewCtrl: ViewController, public navParams: NavParams) { | ||
} | ||
|
||
leagues: string[] = []; | ||
selectedLeagues: string[] = []; | ||
|
||
teams: string[] = []; | ||
selectedTeams: string[] = []; | ||
|
||
favorites:boolean = false; | ||
|
||
ngOnInit(): void { | ||
let matches:Match[] = this.navParams.get('matches'); | ||
|
||
this.leagues = this.getLeagues(matches); | ||
this.teams = this.getTeams(matches); | ||
} | ||
|
||
private getLeagues(matches: Match[]) { | ||
let leagues = matches.map(function (match) { | ||
return match.league; | ||
}); | ||
return Array.from(new Set(leagues)).sort(); | ||
} | ||
|
||
private getTeams(matches: Match[]) { | ||
let teams: string[] = []; | ||
matches.forEach( | ||
match => { | ||
teams.push(match.homeTeam); | ||
teams.push(match.awayTeam); | ||
} | ||
); | ||
return Array.from(new Set(teams)).sort(); | ||
} | ||
|
||
dismiss() { | ||
this.viewCtrl.dismiss(); | ||
} | ||
|
||
applyFilters() { | ||
let filters = { | ||
'leagues': this.selectedLeagues, | ||
'teams': this.selectedTeams, | ||
'favorites': this.favorites | ||
} | ||
this.viewCtrl.dismiss(filters); | ||
} | ||
|
||
clearFilters() { | ||
let filter = {}; | ||
this.viewCtrl.dismiss(filter); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters