show song - order and delete

This commit is contained in:
2020-03-08 14:08:50 +01:00
committed by smuddy
parent 605fe0b2ad
commit 8c000867cb
21 changed files with 252 additions and 31 deletions

View File

@@ -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
}

View File

@@ -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);
}

View File

@@ -1,4 +1,5 @@
export interface ShowSong {
id: string;
songId: string;
order: number;
}