filter keys
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
export interface FilterValues {
|
export interface FilterValues {
|
||||||
q: string;
|
q: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
key: string;
|
||||||
legalType: string;
|
legalType: string;
|
||||||
flag: string;
|
flag: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,14 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Tonart</mat-label>
|
||||||
|
<mat-select formControlName="key">
|
||||||
|
<mat-option *ngFor="let key of keys" [value]="key">{{key|key}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Rechtlicher Status</mat-label>
|
<mat-label>Rechtlicher Status</mat-label>
|
||||||
<mat-select formControlName="legalType">
|
<mat-select formControlName="legalType">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.third {
|
.third {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||||
column-gap: 20px;
|
column-gap: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {FormBuilder, FormGroup} from '@angular/forms';
|
|||||||
import {SongService} from '../../services/song.service';
|
import {SongService} from '../../services/song.service';
|
||||||
import {FilterValues} from './filter-values';
|
import {FilterValues} from './filter-values';
|
||||||
import {Song} from '../../services/song';
|
import {Song} from '../../services/song';
|
||||||
|
import {KEYS} from '../../services/key.helper';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-filter',
|
selector: 'app-filter',
|
||||||
@@ -17,11 +18,13 @@ export class FilterComponent implements OnInit {
|
|||||||
@Input() songs: Song[];
|
@Input() songs: Song[];
|
||||||
public types = SongService.TYPES;
|
public types = SongService.TYPES;
|
||||||
public legalType = SongService.LEGAL_TYPE;
|
public legalType = SongService.LEGAL_TYPE;
|
||||||
|
public keys = KEYS;
|
||||||
|
|
||||||
constructor(private router: Router, activatedRoute: ActivatedRoute, fb: FormBuilder) {
|
constructor(private router: Router, activatedRoute: ActivatedRoute, fb: FormBuilder) {
|
||||||
this.filterFormGroup = fb.group({
|
this.filterFormGroup = fb.group({
|
||||||
q: '',
|
q: '',
|
||||||
type: '',
|
type: '',
|
||||||
|
key: '',
|
||||||
legalType: '',
|
legalType: '',
|
||||||
flag: '',
|
flag: '',
|
||||||
});
|
});
|
||||||
@@ -29,11 +32,13 @@ export class FilterComponent implements OnInit {
|
|||||||
activatedRoute.queryParams.subscribe((filterValues: FilterValues) => {
|
activatedRoute.queryParams.subscribe((filterValues: FilterValues) => {
|
||||||
if (filterValues.q) this.filterFormGroup.controls.q.setValue(filterValues.q);
|
if (filterValues.q) this.filterFormGroup.controls.q.setValue(filterValues.q);
|
||||||
if (filterValues.type) this.filterFormGroup.controls.type.setValue(filterValues.type);
|
if (filterValues.type) this.filterFormGroup.controls.type.setValue(filterValues.type);
|
||||||
|
if (filterValues.key) this.filterFormGroup.controls.key.setValue(filterValues.key);
|
||||||
if (filterValues.legalType) this.filterFormGroup.controls.legalType.setValue(filterValues.legalType);
|
if (filterValues.legalType) this.filterFormGroup.controls.legalType.setValue(filterValues.legalType);
|
||||||
if (filterValues.flag) this.filterFormGroup.controls.flag.setValue(filterValues.flag);
|
if (filterValues.flag) this.filterFormGroup.controls.flag.setValue(filterValues.flag);
|
||||||
})
|
})
|
||||||
|
|
||||||
this.filterFormGroup.controls.q.valueChanges.subscribe(_ => this.filerValueChanged('q', _));
|
this.filterFormGroup.controls.q.valueChanges.subscribe(_ => this.filerValueChanged('q', _));
|
||||||
|
this.filterFormGroup.controls.key.valueChanges.subscribe(_ => this.filerValueChanged('key', _));
|
||||||
this.filterFormGroup.controls.type.valueChanges.subscribe(_ => this.filerValueChanged('type', _));
|
this.filterFormGroup.controls.type.valueChanges.subscribe(_ => this.filerValueChanged('type', _));
|
||||||
this.filterFormGroup.controls.legalType.valueChanges.subscribe(_ => this.filerValueChanged('legalType', _));
|
this.filterFormGroup.controls.legalType.valueChanges.subscribe(_ => this.filerValueChanged('legalType', _));
|
||||||
this.filterFormGroup.controls.flag.valueChanges.subscribe(_ => this.filerValueChanged('flag', _));
|
this.filterFormGroup.controls.flag.valueChanges.subscribe(_ => this.filerValueChanged('flag', _));
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export class SongListComponent implements OnInit {
|
|||||||
private filter(song: Song, filter: FilterValues): boolean {
|
private filter(song: Song, filter: FilterValues): boolean {
|
||||||
let baseFilter = filterSong(song, filter.q);
|
let baseFilter = filterSong(song, filter.q);
|
||||||
baseFilter = baseFilter && (!filter.type || filter.type === song.type);
|
baseFilter = baseFilter && (!filter.type || filter.type === song.type);
|
||||||
|
baseFilter = baseFilter && (!filter.key || filter.key === song.key);
|
||||||
baseFilter = baseFilter && (!filter.legalType || filter.legalType === song.legalType);
|
baseFilter = baseFilter && (!filter.legalType || filter.legalType === song.legalType);
|
||||||
baseFilter = baseFilter && (!filter.flag || this.checkFlag(filter.flag, song.flags));
|
baseFilter = baseFilter && (!filter.flag || this.checkFlag(filter.flag, song.flags));
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ export class SongListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private checkIfFilterActive(filter: FilterValues): boolean {
|
private checkIfFilterActive(filter: FilterValues): boolean {
|
||||||
return !!filter.q || !!filter.type || !!filter.legalType || !!filter.flag;
|
return !!filter.q || !!filter.type || !!filter.key || !!filter.legalType || !!filter.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkFlag(flag: string, flags: string) {
|
private checkFlag(flag: string, flags: string) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {SongTypeTranslaterModule} from '../../../widget-modules/pipes/song-type-
|
|||||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||||
import {MatTooltipModule} from '@angular/material/tooltip';
|
import {MatTooltipModule} from '@angular/material/tooltip';
|
||||||
import {RoleModule} from '../../../services/user/role.module';
|
import {RoleModule} from '../../../services/user/role.module';
|
||||||
|
import {KeyTranslatorModule} from '../../../widget-modules/pipes/key-translator/key-translator.module';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -34,7 +35,8 @@ import {RoleModule} from '../../../services/user/role.module';
|
|||||||
SongTypeTranslaterModule,
|
SongTypeTranslaterModule,
|
||||||
FontAwesomeModule,
|
FontAwesomeModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
RoleModule
|
RoleModule,
|
||||||
|
KeyTranslatorModule,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class SongListModule {
|
export class SongListModule {
|
||||||
|
|||||||
Reference in New Issue
Block a user