2020-11-18 19:33:34 -09:00
|
|
|
import React from 'react'
|
2020-03-28 12:25:55 -08:00
|
|
|
import {
|
|
|
|
|
BooleanField,
|
|
|
|
|
Datagrid,
|
|
|
|
|
DateField,
|
2020-05-01 07:50:07 -08:00
|
|
|
NumberField,
|
2020-03-28 12:25:55 -08:00
|
|
|
Show,
|
|
|
|
|
SimpleShowLayout,
|
|
|
|
|
TextField,
|
|
|
|
|
} from 'react-admin'
|
2020-08-14 09:35:28 -08:00
|
|
|
import { useMediaQuery } from '@material-ui/core'
|
2021-03-26 19:56:19 -08:00
|
|
|
import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder'
|
2020-11-13 17:11:24 -09:00
|
|
|
import { makeStyles } from '@material-ui/core/styles'
|
2020-05-14 16:42:21 -08:00
|
|
|
import {
|
|
|
|
|
ArtistLinkField,
|
|
|
|
|
DurationField,
|
|
|
|
|
RangeField,
|
|
|
|
|
SimpleList,
|
2020-10-12 07:10:07 -08:00
|
|
|
SizeField,
|
2020-11-13 17:11:24 -09:00
|
|
|
MultiLineTextField,
|
|
|
|
|
AlbumContextMenu,
|
2020-05-14 16:42:21 -08:00
|
|
|
} from '../common'
|
2021-03-28 16:35:49 -08:00
|
|
|
import config from '../config'
|
2020-08-14 09:35:28 -08:00
|
|
|
|
|
|
|
|
const useStyles = makeStyles({
|
|
|
|
|
columnIcon: {
|
|
|
|
|
marginLeft: '3px',
|
|
|
|
|
marginTop: '-2px',
|
|
|
|
|
verticalAlign: 'text-top',
|
|
|
|
|
},
|
2020-11-18 19:33:34 -09:00
|
|
|
row: {
|
|
|
|
|
'&:hover': {
|
|
|
|
|
'& $contextMenu': {
|
|
|
|
|
visibility: 'visible',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
contextMenu: {
|
|
|
|
|
visibility: 'hidden',
|
|
|
|
|
},
|
2020-08-14 09:35:28 -08:00
|
|
|
})
|
2020-03-28 12:25:55 -08:00
|
|
|
|
|
|
|
|
const AlbumDetails = (props) => {
|
|
|
|
|
return (
|
|
|
|
|
<Show {...props} title=" ">
|
|
|
|
|
<SimpleShowLayout>
|
|
|
|
|
<TextField source="albumArtist" />
|
|
|
|
|
<TextField source="genre" />
|
|
|
|
|
<BooleanField source="compilation" />
|
|
|
|
|
<DateField source="updatedAt" showTime />
|
2020-10-12 07:10:07 -08:00
|
|
|
<SizeField source="size" />
|
2020-11-12 18:01:59 -09:00
|
|
|
{props.record && props.record['comment'] && (
|
|
|
|
|
<MultiLineTextField source="comment" />
|
|
|
|
|
)}
|
2020-03-28 12:25:55 -08:00
|
|
|
</SimpleShowLayout>
|
|
|
|
|
</Show>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-30 21:07:07 -08:00
|
|
|
const AlbumListView = ({
|
|
|
|
|
hasShow,
|
|
|
|
|
hasEdit,
|
|
|
|
|
hasList,
|
|
|
|
|
syncWithLocation,
|
|
|
|
|
...rest
|
|
|
|
|
}) => {
|
2020-08-14 09:35:28 -08:00
|
|
|
const classes = useStyles()
|
2020-03-28 12:25:55 -08:00
|
|
|
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
|
2020-05-01 07:50:07 -08:00
|
|
|
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
|
|
|
|
|
return isXsmall ? (
|
|
|
|
|
<SimpleList
|
|
|
|
|
primaryText={(r) => r.name}
|
|
|
|
|
secondaryText={(r) => r.albumArtist}
|
|
|
|
|
tertiaryText={(r) => (
|
|
|
|
|
<>
|
|
|
|
|
<RangeField record={r} source={'year'} sortBy={'maxYear'} />
|
2020-09-24 17:27:31 -08:00
|
|
|
|
2020-05-01 07:50:07 -08:00
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
linkType={'show'}
|
|
|
|
|
rightIcon={(r) => <AlbumContextMenu record={r} />}
|
|
|
|
|
{...rest}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
2020-11-18 19:33:34 -09:00
|
|
|
<Datagrid
|
|
|
|
|
expand={<AlbumDetails />}
|
|
|
|
|
rowClick={'show'}
|
|
|
|
|
classes={{ row: classes.row }}
|
|
|
|
|
{...rest}
|
|
|
|
|
>
|
2020-04-24 13:37:28 -08:00
|
|
|
<TextField source="name" />
|
2020-06-22 04:56:55 -08:00
|
|
|
<ArtistLinkField source="artist" />
|
2020-06-09 03:45:23 -08:00
|
|
|
{isDesktop && <NumberField source="songCount" sortByOrder={'DESC'} />}
|
|
|
|
|
{isDesktop && <NumberField source="playCount" sortByOrder={'DESC'} />}
|
|
|
|
|
<RangeField source={'year'} sortBy={'maxYear'} sortByOrder={'DESC'} />
|
2020-03-28 12:25:55 -08:00
|
|
|
{isDesktop && <DurationField source="duration" />}
|
2020-08-14 09:35:28 -08:00
|
|
|
<AlbumContextMenu
|
2020-08-14 11:35:15 -08:00
|
|
|
source={'starred'}
|
|
|
|
|
sortBy={'starred ASC, starredAt ASC'}
|
|
|
|
|
sortByOrder={'DESC'}
|
2021-03-28 16:35:49 -08:00
|
|
|
sortable={config.enableFavourites}
|
2020-11-18 19:33:34 -09:00
|
|
|
className={classes.contextMenu}
|
2020-08-14 09:35:28 -08:00
|
|
|
label={
|
2021-03-28 16:35:49 -08:00
|
|
|
config.enableFavourites && (
|
|
|
|
|
<FavoriteBorderIcon
|
|
|
|
|
fontSize={'small'}
|
|
|
|
|
className={classes.columnIcon}
|
|
|
|
|
/>
|
|
|
|
|
)
|
2020-08-14 09:35:28 -08:00
|
|
|
}
|
|
|
|
|
/>
|
2020-11-18 19:33:34 -09:00
|
|
|
</Datagrid>
|
2020-03-28 12:25:55 -08:00
|
|
|
)
|
|
|
|
|
}
|
2020-05-01 07:50:07 -08:00
|
|
|
|
2020-03-28 12:25:55 -08:00
|
|
|
export default AlbumListView
|