persisting songs ins show
This commit is contained in:
@@ -63,12 +63,7 @@ export class DocxService {
|
||||
this.saveAs(blob, `${title}.docx`);
|
||||
}
|
||||
|
||||
private prepareNewDocument(
|
||||
type: string,
|
||||
name: string,
|
||||
options: DownloadOptions,
|
||||
sections: ISectionOptions[]
|
||||
): Document {
|
||||
private prepareNewDocument(type: string, name: string, options: DownloadOptions, sections: ISectionOptions[]): Document {
|
||||
return new Document({
|
||||
creator: name,
|
||||
title: type,
|
||||
@@ -99,24 +94,11 @@ export class DocxService {
|
||||
});
|
||||
}
|
||||
|
||||
private renderSongs(
|
||||
songs: {showSong: ShowSong; song: Song; sections: Section[]}[],
|
||||
options: DownloadOptions,
|
||||
config: Config
|
||||
): Paragraph[] {
|
||||
return songs.reduce(
|
||||
(p: Paragraph[], song) => [...p, ...this.renderSong(song.showSong, song.song, song.sections, options, config)],
|
||||
[]
|
||||
);
|
||||
private renderSongs(songs: {showSong: ShowSong; sections: Section[]}[], options: DownloadOptions, config: Config): Paragraph[] {
|
||||
return songs.reduce((p: Paragraph[], song) => [...p, ...this.renderSong(song.showSong, song.showSong, song.sections, options, config)], []);
|
||||
}
|
||||
|
||||
private renderSong(
|
||||
showSong: ShowSong,
|
||||
song: Song,
|
||||
sections: Section[],
|
||||
options: DownloadOptions,
|
||||
config: Config
|
||||
): Paragraph[] {
|
||||
private renderSong(showSong: ShowSong, song: Song, sections: Section[], options: DownloadOptions, config: Config): Paragraph[] {
|
||||
const songTitle = this.renderSongTitle(song);
|
||||
const copyright = this.renderCopyright(song, options, config);
|
||||
const songText = this.renderSongText(sections, options?.chordMode ?? showSong.chordMode);
|
||||
@@ -148,10 +130,7 @@ export class DocxService {
|
||||
const artist = song.artist ? song.artist + ', ' : '';
|
||||
const termsOfUse = song.termsOfUse ? song.termsOfUse + ', ' : '';
|
||||
const origin = song.origin ? song.origin + ', ' : '';
|
||||
const licence =
|
||||
song.legalOwner === 'CCLI'
|
||||
? 'CCLI-Liednummer: ' + song.legalOwnerId + ', CCLI-Lizenz: ' + config.ccliLicenseId
|
||||
: 'CCLI-Liednummer: ' + song.legalOwnerId;
|
||||
const licence = song.legalOwner === 'CCLI' ? 'CCLI-Liednummer: ' + song.legalOwnerId + ', CCLI-Lizenz: ' + config.ccliLicenseId : 'CCLI-Liednummer: ' + song.legalOwnerId;
|
||||
|
||||
return new Paragraph({
|
||||
text: artist + label + termsOfUse + origin + licence,
|
||||
@@ -197,7 +176,7 @@ export class DocxService {
|
||||
}
|
||||
|
||||
private async prepareData(showId: string): Promise<{
|
||||
songs: {showSong: ShowSong; song: Song; sections: Section[]}[];
|
||||
songs: {showSong: ShowSong; sections: Section[]}[];
|
||||
show: Show;
|
||||
user: User;
|
||||
config: Config;
|
||||
@@ -210,22 +189,17 @@ export class DocxService {
|
||||
if (!config) return null;
|
||||
|
||||
const showSongs = await this.showSongService.list(showId);
|
||||
const songsAsync = showSongs.map(async showSong => {
|
||||
const song = await this.songService.read(showSong.songId);
|
||||
if (!song) return null;
|
||||
const sections = this.textRenderingService.parse(song.text, {
|
||||
const songsAsync = showSongs.map(showSong => {
|
||||
const sections = this.textRenderingService.parse(showSong.text, {
|
||||
baseKey: showSong.keyOriginal,
|
||||
targetKey: showSong.key,
|
||||
});
|
||||
return {
|
||||
showSong,
|
||||
song,
|
||||
sections,
|
||||
};
|
||||
});
|
||||
const songs = (await Promise.all(songsAsync))
|
||||
.filter(_ => !!_)
|
||||
.map(_ => _ as {showSong: ShowSong; song: Song; sections: Section[]});
|
||||
const songs = (await Promise.all(songsAsync)).filter(_ => !!_).map(_ => _ as {showSong: ShowSong; song: Song; sections: Section[]});
|
||||
return {songs, show, user, config};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ export class ShowDataService {
|
||||
|
||||
public list$ = (queryFn?: QueryFn): Observable<Show[]> => this.dbService.col$(this.collection, queryFn);
|
||||
public read$ = (showId: string): Observable<Show | null> => this.dbService.doc$(`${this.collection}/${showId}`);
|
||||
public update = async (showId: string, data: Partial<Show>): Promise<void> =>
|
||||
await this.dbService.doc(`${this.collection}/${showId}`).update(data);
|
||||
public update = async (showId: string, data: Partial<Show>): Promise<void> => await this.dbService.doc(`${this.collection}/${showId}`).update(data);
|
||||
public add = async (data: Partial<Show>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id;
|
||||
}
|
||||
|
||||
@@ -13,14 +13,10 @@ export class ShowSongDataService {
|
||||
|
||||
public constructor(private dbService: DbService) {}
|
||||
|
||||
public list$ = (showId: string, queryFn?: QueryFn): Observable<ShowSong[]> =>
|
||||
this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryFn);
|
||||
public read$ = (showId: string, songId: string): Observable<ShowSong | null> =>
|
||||
this.dbService.doc$(`${this.collection}/${showId}/${this.subCollection}/${songId}`);
|
||||
public list$ = (showId: string, queryFn?: QueryFn): Observable<ShowSong[]> => this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryFn);
|
||||
public read$ = (showId: string, songId: string): Observable<ShowSong | null> => 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 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;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -10,17 +10,14 @@ import {UserService} from '../../../services/user/user.service';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowSongService {
|
||||
public constructor(
|
||||
private showSongDataService: ShowSongDataService,
|
||||
private songDataService: SongDataService,
|
||||
private userService: UserService
|
||||
) {}
|
||||
public constructor(private showSongDataService: ShowSongDataService, private songDataService: SongDataService, private userService: UserService) {}
|
||||
|
||||
public async new$(showId: string, songId: string, order: number, addedLive = false): Promise<string | null> {
|
||||
const song = await this.songDataService.read$(songId).pipe(take(1)).toPromise();
|
||||
const user = await this.userService.user$.pipe(take(1)).toPromise();
|
||||
if (!song || !user) return null;
|
||||
const data: Partial<ShowSong> = {
|
||||
...song,
|
||||
songId,
|
||||
order,
|
||||
key: song.key,
|
||||
@@ -31,10 +28,11 @@ export class ShowSongService {
|
||||
return await this.showSongDataService.add(showId, data);
|
||||
}
|
||||
|
||||
public list$ = (showId: string): Observable<ShowSong[]> =>
|
||||
this.showSongDataService.list$(showId, _ => _.orderBy('order'));
|
||||
public read$ = (showId: string, songId: string): Observable<ShowSong | null> => this.showSongDataService.read$(showId, songId);
|
||||
public read = (showId: string, songId: string): Promise<ShowSong | null> => this.read$(showId, songId).pipe(first()).toPromise();
|
||||
|
||||
public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId, _ => _.orderBy('order'));
|
||||
public list = (showId: string): Promise<ShowSong[]> => this.list$(showId).pipe(first()).toPromise();
|
||||
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);
|
||||
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {ChordMode} from '../../../widget-modules/components/song-text/song-text.component';
|
||||
import {Song} from '../../songs/services/song';
|
||||
|
||||
export interface ShowSong {
|
||||
export interface ShowSong extends Song {
|
||||
id: string;
|
||||
songId: string;
|
||||
key: string;
|
||||
|
||||
@@ -10,25 +10,8 @@ import {User} from '../../../services/user/user';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowService {
|
||||
public static SHOW_TYPE = [
|
||||
'service-worship',
|
||||
'service-praise',
|
||||
'home-group-big',
|
||||
'home-group',
|
||||
'prayer-group',
|
||||
'teens-group',
|
||||
'kids-group',
|
||||
'misc-public',
|
||||
'misc-private',
|
||||
];
|
||||
public static SHOW_TYPE_PUBLIC = [
|
||||
'service-worship',
|
||||
'service-praise',
|
||||
'home-group-big',
|
||||
'teens-group',
|
||||
'kids-group',
|
||||
'misc-public',
|
||||
];
|
||||
public static SHOW_TYPE = ['service-worship', 'service-praise', 'home-group-big', 'home-group', 'prayer-group', 'teens-group', 'kids-group', 'misc-public', 'misc-private'];
|
||||
public static SHOW_TYPE_PUBLIC = ['service-worship', 'service-praise', 'home-group-big', 'teens-group', 'kids-group', 'misc-public'];
|
||||
public static SHOW_TYPE_PRIVATE = ['home-group', 'prayer-group', 'misc-private'];
|
||||
private user: User | null = null;
|
||||
|
||||
@@ -44,14 +27,11 @@ export class ShowService {
|
||||
() => this.showDataService.list$(),
|
||||
(user: User | null, shows: Show[]) => ({user, shows})
|
||||
),
|
||||
map(s =>
|
||||
s.shows.filter(_ => !_.archived).filter(show => show.published || (show.owner === s.user?.id && !publishedOnly))
|
||||
)
|
||||
map(s => s.shows.filter(_ => !_.archived).filter(show => show.published || (show.owner === s.user?.id && !publishedOnly)))
|
||||
);
|
||||
}
|
||||
|
||||
public update$ = async (showId: string, data: Partial<Show>): Promise<void> =>
|
||||
this.showDataService.update(showId, data);
|
||||
public update$ = async (showId: string, data: Partial<Show>): Promise<void> => this.showDataService.update(showId, data);
|
||||
|
||||
public async new$(data: Partial<Show>): Promise<string | null> {
|
||||
if (!data.showType || !this.user) return null;
|
||||
|
||||
@@ -5,12 +5,7 @@
|
||||
show.date.toDate() | date: 'dd.MM.yyyy'
|
||||
}} - {{ getStatus(show) }}"
|
||||
>
|
||||
<i *ngIf="show.public"
|
||||
>öffentliche Veranstaltung von
|
||||
<app-user-name [userId]="show.owner"></app-user-name>
|
||||
</i>
|
||||
<i *ngIf="!show.public"
|
||||
>geschlossene Veranstaltung von
|
||||
<i>{{show.public ? 'öffentliche' : 'geschlossene'}} Veranstaltung von
|
||||
<app-user-name [userId]="show.owner"></app-user-name>
|
||||
</i>
|
||||
<p *ngIf="!show.published">
|
||||
@@ -19,7 +14,7 @@
|
||||
<div *ngIf="showSongs && songs" class="song-list">
|
||||
<app-song
|
||||
*ngFor="let song of showSongs"
|
||||
[Song]="getSong(song.songId)"
|
||||
[Song]="song"
|
||||
[showId]="showId"
|
||||
[showSong]="song"
|
||||
[showSongs]="showSongs"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
.song {
|
||||
min-height: 28px;
|
||||
display: grid;
|
||||
grid-template-columns: 20px 20px auto 70px 25px;
|
||||
@media screen and (max-width: 860px) {
|
||||
|
||||
Reference in New Issue
Block a user