search function for show editing

This commit is contained in:
2020-04-21 18:43:08 +02:00
committed by smuddy
parent 5695640fe4
commit c526f127e8
10 changed files with 73 additions and 35 deletions

View File

@@ -21,7 +21,10 @@
<mat-form-field appearance="outline">
<mat-label>Lied hinzufügen...</mat-label>
<mat-select (selectionChange)="onAddSongSelectionChanged($event)">
<mat-option *ngFor="let song of songs" [value]="song.id">{{song.title}}</mat-option>
<mat-option>
<ngx-mat-select-search [formControl]="filteredSongsControl"></ngx-mat-select-search>
</mat-option>
<mat-option *ngFor="let song of filteredSongs()" [value]="song.id">{{song.title}}</mat-option>
</mat-select>
</mat-form-field>

View File

@@ -10,6 +10,8 @@ import {MatSelectChange} from '@angular/material/select';
import {ShowSongService} from '../services/show-song.service';
import {ShowSong} from '../services/showSong';
import {DocxService} from '../services/docx.service';
import {FormControl} from '@angular/forms';
import {filterSong} from '../../../services/filter.helper';
@Component({
selector: 'app-show',
@@ -89,4 +91,11 @@ export class ShowComponent implements OnInit {
public async onDownload(): Promise<void> {
await this.docxService.create(this.showId);
}
public filteredSongsControl = new FormControl();
filteredSongs() {
const filterValue = this.filteredSongsControl.value;
return filterValue ? this.songs.filter(_ => filterSong(_, filterValue)) : this.songs;
}
}