publish show

This commit is contained in:
2020-04-17 15:13:39 +02:00
committed by smuddy
parent b8fbcb4b9a
commit c5748d5e34
19 changed files with 126 additions and 63 deletions

View File

@@ -1,8 +1,8 @@
import {Component} from '@angular/core';
import {Observable} from 'rxjs';
import {Show} from '../services/show';
import {ShowDataService} from '../services/show-data.service';
import {fade} from '../../../animations';
import {ShowService} from '../services/show.service';
@Component({
selector: 'app-list',
@@ -13,8 +13,8 @@ import {fade} from '../../../animations';
export class ListComponent {
public shows$: Observable<Show[]>;
constructor(showDataService: ShowDataService) {
this.shows$ = showDataService.list$();
constructor(showService: ShowService) {
this.shows$ = showService.list$();
}
}

View File

@@ -12,7 +12,7 @@ export class ShowDataService {
constructor(private dbService: DbService) {
}
public list$ = (): Observable<Show[]> => this.dbService.col$(this.collection);
public list$ = (queryFn?): Observable<Show[]> => this.dbService.col$(this.collection, queryFn);
public read$ = (showId: string): Observable<Show | undefined> => 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 add = async (data: Partial<Show>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id

View File

@@ -2,6 +2,9 @@ import {Injectable} from '@angular/core';
import {ShowDataService} from './show-data.service';
import {Show} from './show';
import {Observable} from 'rxjs';
import {UserService} from '../../../services/user.service';
import {map, switchMap} from 'rxjs/operators';
import {User} from '../../../services/user';
@Injectable({
providedIn: 'root'
@@ -11,15 +14,32 @@ 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_PRIVATE = ['home-group', 'prayer-group', 'misc-private',];
private user: User;
constructor(private showDataService: ShowDataService) {
constructor(private showDataService: ShowDataService, private userService: UserService) {
userService.user$.subscribe(_ => this.user = _);
}
public read$ = (showId: string): Observable<Show> => this.showDataService.read$(showId);
public list$(publishedOnly: boolean = false): Observable<Show[]> {
return this.userService.user$.pipe(
switchMap(_ => this.showDataService.list$(), (user: User, shows: Show[]) => ({user, shows})),
map(_ => _.shows
.filter(_ => !_.archived)
.filter(show => show.published || (show.owner === _.user.id && !publishedOnly))
)
)
}
public update$ = async (showId: string, data: Partial<Show>): Promise<void> => this.showDataService.update(showId, data);
public async new$(data: Partial<Show>): Promise<string> {
const calculatedData: Partial<Show> = {
...data,
owner: this.user.id,
public: ShowService.SHOW_TYPE_PUBLIC.indexOf(data.showType) !== -1,
};
return await this.showDataService.add(calculatedData);

View File

@@ -8,6 +8,8 @@ export interface Show {
owner: string;
public: boolean;
reported: boolean;
published: boolean;
archived: boolean;
presentationSongId: string;
presentationSection: number;

View File

@@ -1,16 +1,18 @@
<div *ngIf="(show$|async) as show">
<app-card
heading="{{show.showType|showType}}, {{show.date.toDate()|date:'dd.MM.yyyy'}}">
<mat-checkbox [(ngModel)]="showText">Text anzeigen</mat-checkbox>
heading="{{show.showType|showType}}, {{show.date.toDate()|date:'dd.MM.yyyy'}} - {{getStatus(show)}}">
<i *ngIf="show.public">öffentliche Veranstaltung</i>
<i *ngIf="!show.public">geschlossene Veranstaltung</i>
<p>
<mat-checkbox [(ngModel)]="showText">Text anzeigen</mat-checkbox>
</p>
<div *ngIf="showSongs && songs" class="song-list">
<app-song *ngFor="let song of showSongs" class="song-row"
[showId]="showId"
<app-song *ngFor="let song of showSongs" [showId]="showId"
[showSong]="song"
[showSongs]="showSongs"
[song]="getSong(song.songId)"
[showText]="showText"
[song]="getSong(song.songId)"
class="song-row"
></app-song>
</div>
@@ -23,5 +25,11 @@
</mat-form-field>
<button mat-button>aus Übersicht</button>
</div>
<app-button-row>
<button (click)="onArchive(true)" *ngIf="!show.archived" mat-button>Archivieren</button>
<button (click)="onArchive(false)" *ngIf="show.archived" mat-button>Wiederherstellen</button>
<button (click)="onPublish(true)" *ngIf="!show.published" mat-button>Veröffentlichen</button>
<button (click)="onPublish(false)" *ngIf="show.published" mat-button>Veröffentlichung zurückziehen</button>
</app-button-row>
</app-card>
</div>

View File

@@ -69,4 +69,18 @@ export class ShowComponent implements OnInit {
const filtered = this.songs.filter(_ => _.id === songId);
return filtered.length > 0 ? filtered[0] : null;
}
public async onArchive(archived: boolean): Promise<void> {
await this.showService.update$(this.showId, {archived});
}
public async onPublish(published: boolean): Promise<void> {
await this.showService.update$(this.showId, {published});
}
public getStatus(show: Show): string {
if (show.published) return 'veröffentlicht';
if (show.reported) return 'gemeldet';
return 'entwurf';
}
}

View File

@@ -14,5 +14,5 @@
<app-menu-button (click)="onDelete()" [icon]="faDelete" class="btnDelete"></app-menu-button>
</div>
<app-song-text (chordModeChanged)="onChordModeChanged($event)" *ngIf="showText" [chordMode]="showSong.chordMode"
[text]="_song.text"></app-song-text>
[showSwitch]="true" [text]="_song.text"></app-song-text>
</div>

View File

@@ -1,6 +1,4 @@
.song {
display: grid;
grid-template-columns: 20px 20px auto 70px 25px;