import { Component } from '@angular/core' ; import { Store } from '@ngrx/store' ; import 'rxjs/add/operator/take' ; import { DrawerService , FancyAlertService , LogService } from '../../core/index' ; import { AuthService } from '../services/auth.service' ; import { PlaylistModel } from '../models/playlist.model' ; import { FIREBASE_ACTIONS } from '../services/firebase.service' ; @ Component ( { selector : 'PlaylistActionBar' , templateUrl : './shared/shoutoutplay/components/playlist-actionbar.component.html' } ) export class PlaylistActionBarComponent { constructor ( public drawerService , public authService , private fancyalert , private logger , private store ) { } public add ( ) { this . fancyalert . prompt ( 'Name' , '' , 'Add New Playlist...' , 'plus' , ( value ) => { this . logger . debug ( `Creating playlist named '${ value }'` ) ; let newPlaylist = new PlaylistModel ( { name : value } ) ; this . store . take ( 1 ) . subscribe ( ( s ) => { newPlaylist . order = s . firebase . playlists . length ; this . store . dispatch ( { type : FIREBASE_ACTIONS . CREATE , payload : newPlaylist } ) ; } ) ; } ) ; } }