directly add song to show
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<div [formGroup]="filterFormGroup">
|
||||
|
||||
|
||||
<div class="third">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Zeitraum</mat-label>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<div>
|
||||
<!-- <app-list-header *appRole="['leader']"></app-list-header>-->
|
||||
<app-list-header *appRole="['leader']">
|
||||
<app-filter *ngIf="shows$ | async as shows" [shows]="shows"></app-filter>
|
||||
<app-filter *ngIf="shows$ | async as shows" [shows]="publicShows$ | async"></app-filter>
|
||||
</app-list-header>
|
||||
|
||||
<ng-container *appRole="['leader']">
|
||||
<ng-container *ngIf="shows$ | async as shows">
|
||||
<ng-container *ngIf="privateShows$ | async as shows">
|
||||
<app-card
|
||||
*ngIf="getPrivateSongs(shows).length > 0"
|
||||
*ngIf="shows.length > 0"
|
||||
[padding]="false"
|
||||
heading="meine Veranstaltungen"
|
||||
>
|
||||
<app-list-item
|
||||
*ngFor="let show of getPrivateSongs(shows) | sortBy: 'desc':'date'"
|
||||
*ngFor="let show of shows | sortBy: 'desc':'date'"
|
||||
[routerLink]="show.id"
|
||||
[show]="show"
|
||||
></app-list-item>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {combineLatest, Observable} from 'rxjs';
|
||||
import {combineLatest} from 'rxjs';
|
||||
import {Show} from '../services/show';
|
||||
import {fade} from '../../../animations';
|
||||
import {ShowService} from '../services/show.service';
|
||||
@@ -14,34 +14,27 @@ import {map} from 'rxjs/operators';
|
||||
animations: [fade],
|
||||
})
|
||||
export class ListComponent {
|
||||
public shows$: Observable<Show[]>;
|
||||
public publicShows$: Observable<Show[]>;
|
||||
public lastMonths$: Observable<number>;
|
||||
public shows$ = this.showService.list$();
|
||||
public privateShows$ = this.showService.list$().pipe(map(show => show.filter(_ => !_.published)));
|
||||
public lastMonths$ = this.activatedRoute.queryParams.pipe(
|
||||
map(params => {
|
||||
const filterValues = params as FilterValues;
|
||||
if (!filterValues?.time) return 1;
|
||||
return +filterValues.time;
|
||||
})
|
||||
);
|
||||
|
||||
public constructor(showService: ShowService, activatedRoute: ActivatedRoute) {
|
||||
this.shows$ = showService.list$();
|
||||
this.lastMonths$ = activatedRoute.queryParams.pipe(
|
||||
map(params => {
|
||||
const filterValues = params as FilterValues;
|
||||
if (!filterValues?.time) return 3;
|
||||
return +filterValues.time;
|
||||
public publicShows$ = combineLatest([this.shows$, this.lastMonths$]).pipe(
|
||||
map(_ =>
|
||||
_[0].filter(f => {
|
||||
const d = new Date();
|
||||
d.setMonth(d.getMonth() - _[1]);
|
||||
return f.published && f.date.toDate() >= d;
|
||||
})
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
this.publicShows$ = combineLatest([this.shows$, this.lastMonths$]).pipe(
|
||||
map(_ =>
|
||||
_[0].filter(f => {
|
||||
const d = new Date();
|
||||
d.setMonth(d.getMonth() - _[1]);
|
||||
return f.published && f.date.toDate() >= d;
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public getPrivateSongs(songs: Show[]): Show[] {
|
||||
return songs.filter(_ => !_.published);
|
||||
}
|
||||
public constructor(private showService: ShowService, private activatedRoute: ActivatedRoute) {}
|
||||
|
||||
public trackBy = (index: number, show: unknown) => (show as Show).id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user