Skip to content

Commit

Permalink
fix: sort by album in songs view
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Mar 30, 2020
1 parent 46f4f63 commit 301fa2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
16 changes: 16 additions & 0 deletions ui/src/song/AlbumLinkField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Link } from 'react-admin'
import React from 'react'

export const AlbumLinkField = (props) => (
<Link
to={`/album/${props.record.albumId}/show`}
onClick={(e) => e.stopPropagation()}
>
{props.record.album}
</Link>
)

AlbumLinkField.defaultProps = {
source: 'albumId',
addLabel: true
}
17 changes: 4 additions & 13 deletions ui/src/song/SongList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {
Datagrid,
DateField,
Filter,
FunctionField,
List,
NumberField,
ReferenceField,
SearchInput,
Show,
SimpleShowLayout,
TextField,
FunctionField
TextField
} from 'react-admin'
import { useMediaQuery } from '@material-ui/core'
import {
Expand All @@ -26,6 +25,7 @@ import { useDispatch } from 'react-redux'
import { addTrack, setTrack } from '../audioplayer'
import AddIcon from '@material-ui/icons/Add'
import { SongBulkActions } from './SongBulkActions'
import { AlbumLinkField } from './AlbumLinkField'

const SongFilter = (props) => (
<Filter {...props}>
Expand Down Expand Up @@ -82,16 +82,7 @@ const SongList = (props) => {
rowClick={(id, basePath, record) => dispatch(setTrack(record))}
>
<TextField source="title" />
{isDesktop && (
<ReferenceField
label="Album"
source="albumId"
reference="album"
link="show"
>
<TextField source="name" />
</ReferenceField>
)}
{isDesktop && <AlbumLinkField source="albumId" sortBy="album" />}
<TextField source="artist" />
{isDesktop && <NumberField source="trackNumber" />}
{isDesktop && <NumberField source="playCount" />}
Expand Down

0 comments on commit 301fa2a

Please sign in to comment.