mirror of
https://github.com/koel/koel
synced 2024-11-14 00:17:13 +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',
|
'title' => 'songs.title',
|
||||||
'track' => 'songs.track',
|
'track' => 'songs.track',
|
||||||
'length' => 'songs.length',
|
'length' => 'songs.length',
|
||||||
|
'created_at' => 'songs.created_at',
|
||||||
'disc' => 'songs.disc',
|
'disc' => 'songs.disc',
|
||||||
'artist_name' => 'artists.name',
|
'artist_name' => 'artists.name',
|
||||||
'album_name' => 'albums.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;
|
private const DEFAULT_QUEUE_LIMIT = 500;
|
||||||
|
|
||||||
public function getOneByPath(string $path): ?Song
|
public function getOneByPath(string $path): ?Song
|
||||||
|
|
|
@ -53,6 +53,10 @@ const menuItems: { label: string, field: SongListSortField }[] = [
|
||||||
{
|
{
|
||||||
label: 'Time',
|
label: 'Time',
|
||||||
field: 'length'
|
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
|
media: HTMLMediaElement
|
||||||
|
|
||||||
restart (): void
|
restart (): void
|
||||||
|
|
||||||
play (): void
|
play (): void
|
||||||
|
|
||||||
pause (): void
|
pause (): void
|
||||||
|
|
||||||
seek (position: number): void
|
seek (position: number): void
|
||||||
|
|
||||||
setVolume (volume: number): void
|
setVolume (volume: number): void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +355,7 @@ interface SongListConfig {
|
||||||
reorderable: boolean
|
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'
|
type SortOrder = 'asc' | 'desc'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue