mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
feat: allow sorting by date added (#1631)
This commit is contained in:
parent
cb84f14f34
commit
e8e2c2db75
3 changed files with 19 additions and 2 deletions
|
@ -22,12 +22,21 @@ class SongRepository extends Repository
|
|||
'title' => 'songs.title',
|
||||
'track' => 'songs.track',
|
||||
'length' => 'songs.length',
|
||||
'created_at' => 'songs.created_at',
|
||||
'disc' => 'songs.disc',
|
||||
'artist_name' => 'artists.name',
|
||||
'album_name' => 'albums.name',
|
||||
];
|
||||
|
||||
private const VALID_SORT_COLUMNS = ['songs.title', 'songs.track', 'songs.length', 'artists.name', 'albums.name'];
|
||||
private const VALID_SORT_COLUMNS = [
|
||||
'songs.title',
|
||||
'songs.track',
|
||||
'songs.length',
|
||||
'songs.created_at',
|
||||
'artists.name',
|
||||
'albums.name',
|
||||
];
|
||||
|
||||
private const DEFAULT_QUEUE_LIMIT = 500;
|
||||
|
||||
public function getOneByPath(string $path): ?Song
|
||||
|
|
|
@ -53,6 +53,10 @@ const menuItems: { label: string, field: SongListSortField }[] = [
|
|||
{
|
||||
label: 'Time',
|
||||
field: 'length'
|
||||
},
|
||||
{
|
||||
label: 'Date Added',
|
||||
field: 'created_at'
|
||||
}
|
||||
]
|
||||
|
||||
|
|
6
resources/assets/js/types.d.ts
vendored
6
resources/assets/js/types.d.ts
vendored
|
@ -21,9 +21,13 @@ interface Plyr {
|
|||
media: HTMLMediaElement
|
||||
|
||||
restart (): void
|
||||
|
||||
play (): void
|
||||
|
||||
pause (): void
|
||||
|
||||
seek (position: number): void
|
||||
|
||||
setVolume (volume: number): void
|
||||
}
|
||||
|
||||
|
@ -351,7 +355,7 @@ interface SongListConfig {
|
|||
reorderable: boolean
|
||||
}
|
||||
|
||||
type SongListSortField = keyof Pick<Song, 'track' | 'disc' | 'title' | 'album_name' | 'length' | 'artist_name'>
|
||||
type SongListSortField = keyof Pick<Song, 'track' | 'disc' | 'title' | 'album_name' | 'length' | 'artist_name' | 'created_at'>
|
||||
|
||||
type SortOrder = 'asc' | 'desc'
|
||||
|
||||
|
|
Loading…
Reference in a new issue