diff --git a/src/app/modules/shows/list/filter/filter.component.html b/src/app/modules/shows/list/filter/filter.component.html index 8a9e476..3d73807 100644 --- a/src/app/modules/shows/list/filter/filter.component.html +++ b/src/app/modules/shows/list/filter/filter.component.html @@ -1,6 +1,5 @@
-
Zeitraum diff --git a/src/app/modules/shows/list/list.component.html b/src/app/modules/shows/list/list.component.html index 1a958f7..d56b6fb 100644 --- a/src/app/modules/shows/list/list.component.html +++ b/src/app/modules/shows/list/list.component.html @@ -1,18 +1,18 @@
- + - + diff --git a/src/app/modules/shows/list/list.component.ts b/src/app/modules/shows/list/list.component.ts index c6268a6..5607a11 100644 --- a/src/app/modules/shows/list/list.component.ts +++ b/src/app/modules/shows/list/list.component.ts @@ -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; - public publicShows$: Observable; - public lastMonths$: Observable; + 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; } diff --git a/src/app/modules/songs/song/song.component.html b/src/app/modules/songs/song/song.component.html index 22fcf38..92d2ee9 100644 --- a/src/app/modules/songs/song/song.component.html +++ b/src/app/modules/songs/song/song.component.html @@ -64,6 +64,16 @@ Bearbeiten + + + Zu Veranstaltung hinzufügen + + + + {{ show.date.toDate() | date: "dd.MM.yyyy" }} {{ show.showType | showType }} + + + diff --git a/src/app/modules/songs/song/song.component.ts b/src/app/modules/songs/song/song.component.ts index 75af592..2f526d4 100644 --- a/src/app/modules/songs/song/song.component.ts +++ b/src/app/modules/songs/song/song.component.ts @@ -8,7 +8,10 @@ import {FileDataService} from '../services/file-data.service'; import {File} from '../services/file'; import {UserService} from '../../../services/user/user.service'; import {User} from '../../../services/user/user'; -import {faEdit, faTrash} from '@fortawesome/free-solid-svg-icons'; +import {faEdit, faFileCirclePlus, faTrash} from '@fortawesome/free-solid-svg-icons'; +import {ShowService} from '../../shows/services/show.service'; +import {Show} from '../../shows/services/show'; +import {ShowSongService} from '../../shows/services/show-song.service'; @Component({ selector: 'app-song', @@ -21,13 +24,17 @@ export class SongComponent implements OnInit { public user$: Observable | null = null; public faEdit = faEdit; public faDelete = faTrash; + public faFileCirclePlus = faFileCirclePlus; + public privateShows$ = this.showService.list$().pipe(map(show => show.filter(_ => !_.published))); public constructor( private activatedRoute: ActivatedRoute, private songService: SongService, private fileService: FileDataService, private userService: UserService, - private router: Router + private router: Router, + private showService: ShowService, + private showSongService: ShowSongService ) { this.user$ = userService.user$; } @@ -57,4 +64,11 @@ export class SongComponent implements OnInit { await this.songService.delete(songId); await this.router.navigateByUrl('/songs'); } + + public async addSongToShow(show: Show, song: Song) { + if (!show) return; + const newId = await this.showSongService.new$(show?.id, song.id, false); + await this.showService.update$(show?.id, {order: [...show.order, newId ?? '']}); + await this.router.navigateByUrl('/shows/' + show.id); + } } diff --git a/src/app/modules/songs/song/song.module.ts b/src/app/modules/songs/song/song.module.ts index bc390bd..715be7b 100644 --- a/src/app/modules/songs/song/song.module.ts +++ b/src/app/modules/songs/song/song.module.ts @@ -13,6 +13,8 @@ import {RoleModule} from '../../../services/user/role.module'; import {StatusTranslaterModule} from '../../../widget-modules/pipes/status-translater/status-translater.module'; import {ButtonModule} from '../../../widget-modules/components/button/button.module'; import {FileComponent} from './file/file.component'; +import {MatMenuModule} from '@angular/material/menu'; +import {ShowTypeTranslaterModule} from '../../../widget-modules/pipes/show-type-translater/show-type-translater.module'; @NgModule({ declarations: [SongComponent, FileComponent], @@ -31,6 +33,8 @@ import {FileComponent} from './file/file.component'; RoleModule, StatusTranslaterModule, ButtonModule, + MatMenuModule, + ShowTypeTranslaterModule, ], }) export class SongModule {} diff --git a/src/app/widget-modules/components/button/button.component.ts b/src/app/widget-modules/components/button/button.component.ts index 84b4be4..53b1ac5 100644 --- a/src/app/widget-modules/components/button/button.component.ts +++ b/src/app/widget-modules/components/button/button.component.ts @@ -1,6 +1,5 @@ import {Component, Input} from '@angular/core'; import {IconProp} from '@fortawesome/fontawesome-svg-core'; -import {faCross} from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'app-button', @@ -8,5 +7,5 @@ import {faCross} from '@fortawesome/free-solid-svg-icons'; styleUrls: ['./button.component.less'], }) export class ButtonComponent { - @Input() public icon: IconProp = faCross; + @Input() public icon: IconProp | null = null; }