import { JourneyManager } from './../../services/JourneyManager' ; import { AppManager } from './../../services/AppManager' ; import { WayPoint , BookmarkedPOI , Journey } from './../../model/Journey' ; import { Component } from '@angular/core' ; import { NavParams , ModalController } from '@ionic/angular' ; @ Component ( { templateUrl : 'favourite-editor.html' , } ) export class FavouriteEditorPage { selectedJourneyID ; selectedStageIndex : number ; newJourneyName : string ; waypoint : WayPoint ; poi ; constructor ( public appManager , public navParams , public journeyManager , private modalController ) { this . poi = this . navParams . get ( 'poi' ) ; this . waypoint = new WayPoint ( ) ; this . waypoint . Title = this . poi . AddressInfo . Title ; this . waypoint . PoiIDs = [ this . poi . ID ] ; this . waypoint . PoiList = [ ] ; const bookmark = new BookmarkedPOI ( 'charging' , 1 ) ; bookmark . Poi = this . poi ; bookmark . PoiID = this . poi . ID ; this . waypoint . PoiList . push ( bookmark ) ; this . newJourneyName = 'Trip to ' + this . poi . AddressInfo . Title ; } cancel ( ) { this . modalController . dismiss ( ) ; } add ( ) { if ( this . selectedJourneyID != null && this . selectedJourneyID !== '' ) { this . journeyManager . addJourneyWaypoint ( this . selectedJourneyID , this . selectedStageIndex , this . waypoint ) ; } else { const journey = new Journey ( ) ; journey . ID = Date . now ( ) . toString ( ) ; if ( this . newJourneyName === '' ) { this . newJourneyName = 'New Journey' ; } journey . Title = this . newJourneyName ; this . journeyManager . addJourney ( journey , this . waypoint ) ; } this . journeyManager . saveJourneys ( ) ; this . modalController . dismiss ( ) ; } }