Cleanup Code
This commit is contained in:
@@ -1,56 +1,56 @@
|
||||
import { SongsService } from './../../../data/songs.service';
|
||||
import {
|
||||
Component,
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef
|
||||
} from '@angular/core';
|
||||
import { State } from 'src/app/data/state';
|
||||
import { faFileMedical } from '@fortawesome/free-solid-svg-icons';
|
||||
import {SongsService} from '../../../data/songs.service';
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from '@angular/core';
|
||||
import {State} from 'src/app/data/state';
|
||||
import {faFileMedical} from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
@Component({
|
||||
selector: 'app-table',
|
||||
templateUrl: './table.component.html',
|
||||
styleUrls: ['./table.component.less'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
selector: 'app-table',
|
||||
templateUrl: './table.component.html',
|
||||
styleUrls: ['./table.component.less'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class TableComponent {
|
||||
public selectedSongId = 0;
|
||||
public State = State;
|
||||
public faNew = faFileMedical;
|
||||
public columnsFull = ['Number', 'Name', 'Key', 'SongType', 'Tempo'];
|
||||
public columnsPinned = ['Number', 'Name'];
|
||||
public get columns(): string[] {
|
||||
return this.songsService.state === State.list ? this.columnsFull : this.columnsPinned;
|
||||
}
|
||||
public selectedSongId = 0;
|
||||
public State = State;
|
||||
public faNew = faFileMedical;
|
||||
public columnsFull = ['Number', 'Name', 'Key', 'SongType', 'Tempo'];
|
||||
public columnsPinned = ['Number', 'Name'];
|
||||
|
||||
constructor(
|
||||
public songsService: SongsService,
|
||||
private change: ChangeDetectorRef
|
||||
) {
|
||||
songsService.selectedSong.subscribe(_ => {
|
||||
this.selectedSongId = _ ? _.ID : 0;
|
||||
this.change.markForCheck();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public renderSongType(songType: string) {
|
||||
switch (songType) {
|
||||
case 'Praise': return {name: 'Lobpreis', color: '#99FFB8'};
|
||||
case 'Worship': return {name: 'Anbetung', color: '#C999FF'};
|
||||
default: return null;
|
||||
constructor(
|
||||
public songsService: SongsService,
|
||||
private change: ChangeDetectorRef
|
||||
) {
|
||||
songsService.selectedSong.subscribe(_ => {
|
||||
this.selectedSongId = _ ? _.ID : 0;
|
||||
this.change.markForCheck();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public onClick(id: number): void {
|
||||
this.songsService.selectSong(id).subscribe();
|
||||
this.change.detectChanges();
|
||||
}
|
||||
public get columns(): string[] {
|
||||
return this.songsService.state === State.list ? this.columnsFull : this.columnsPinned;
|
||||
}
|
||||
|
||||
public onClickNew(): void {
|
||||
this.songsService.selectSong(null).subscribe();
|
||||
this.songsService.state = State.new;
|
||||
this.change.detectChanges();
|
||||
}
|
||||
public renderSongType(songType: string) {
|
||||
switch (songType) {
|
||||
case 'Praise':
|
||||
return {name: 'Lobpreis', color: '#99FFB8'};
|
||||
case 'Worship':
|
||||
return {name: 'Anbetung', color: '#C999FF'};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public onClick(id: number): void {
|
||||
this.songsService.selectSong(id).subscribe();
|
||||
this.change.detectChanges();
|
||||
}
|
||||
|
||||
public onClickNew(): void {
|
||||
this.songsService.selectSong(null).subscribe();
|
||||
this.songsService.state = State.new;
|
||||
this.change.detectChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user