show song - order and delete
This commit is contained in:
@@ -13,8 +13,9 @@ export class ShowSongDataService {
|
||||
constructor(private dbService: DbService) {
|
||||
}
|
||||
|
||||
public list$ = (showId: string): Observable<ShowSong[]> => this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`);
|
||||
public list$ = (showId: string, queryFn?): Observable<ShowSong[]> => this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryFn);
|
||||
public read$ = (showId: string, songId: string): Observable<ShowSong | undefined> => this.dbService.doc$(`${this.collection}/${showId}/${this.subCollection}/${songId}`);
|
||||
public update = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.dbService.doc(`${this.collection}/${showId}/${this.subCollection}/${songId}`).update(data);
|
||||
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.dbService.doc(`${this.collection}/${showId}/${this.subCollection}/${songId}`).update(data);
|
||||
public delete = async (showId: string, songId: string): Promise<void> => await this.dbService.doc(`${this.collection}/${showId}/${this.subCollection}/${songId}`).delete();
|
||||
public add = async (showId: string, data: Partial<ShowSong>): Promise<string> => (await this.dbService.col(`${this.collection}/${showId}/${this.subCollection}`).add(data)).id
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ShowSongDataService} from './show-song-data.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {ShowSong} from './showSong';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -9,8 +11,12 @@ export class ShowSongService {
|
||||
constructor(private showSongDataService: ShowSongDataService) {
|
||||
}
|
||||
|
||||
public async new$(showId: string, songId: string): Promise<string> {
|
||||
const data = {songId};
|
||||
public async new$(showId: string, songId: string, order: number): Promise<string> {
|
||||
const data = {songId, order};
|
||||
return await this.showSongDataService.add(showId, data);
|
||||
}
|
||||
|
||||
public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId, _ => _.orderBy('order'));
|
||||
public delete$ = (showId: string, songId: string): Promise<void> => this.showSongDataService.delete(showId, songId);
|
||||
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface ShowSong {
|
||||
id: string;
|
||||
songId: string;
|
||||
order: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user