import { Component } from '@angular/core' ; import { Config , ModalController , NavParams } from '@ionic/angular' ; import { ConferenceData } from '../../providers/conference-data' ; @ Component ( { selector : 'page-schedule-filter' , templateUrl : 'schedule-filter.html' , styleUrls : [ './schedule-filter.scss' ] , } ) export class ScheduleFilterPage { ios : boolean ; tracks : { name : string ; icon : string ; isChecked : boolean ; } [ ] = [ ] ; constructor ( public confData , private config , public modalCtrl , public navParams ) { } ionViewWillEnter ( ) { this . ios = this . config . get ( 'mode' ) === `ios` ; const excludedTrackNames = this . navParams . get ( 'excludedTracks' ) ; this . confData . getTracks ( ) . subscribe ( ( tracks ) => { tracks . forEach ( track => { this . tracks . push ( { name : track . name , icon : track . icon , isChecked : ( excludedTrackNames . indexOf ( track . name ) === - 1 ) } ) ; } ) ; } ) ; } selectAll ( check ) { this . tracks . forEach ( track => { track . isChecked = check ; } ) ; } applyFilters ( ) { const excludedTrackNames = this . tracks . filter ( c => ! c . isChecked ) . map ( c => c . name ) ; this . dismiss ( excludedTrackNames ) ; } dismiss ( data ? ) { this . modalCtrl . dismiss ( data ) ; } }