2020-02-07 07:45:56 -09:00
|
|
|
import React from 'react'
|
2020-11-19 14:44:28 -09:00
|
|
|
import {
|
|
|
|
|
ReferenceManyField,
|
|
|
|
|
ShowContextProvider,
|
|
|
|
|
useShowContext,
|
|
|
|
|
useShowController,
|
|
|
|
|
} from 'react-admin'
|
2021-03-31 12:58:47 -08:00
|
|
|
import { makeStyles } from '@material-ui/core/styles'
|
2020-11-19 14:44:28 -09:00
|
|
|
import AlbumSongs from './AlbumSongs'
|
2020-02-07 11:04:45 -09:00
|
|
|
import AlbumDetails from './AlbumDetails'
|
2020-05-15 09:48:33 -08:00
|
|
|
import AlbumActions from './AlbumActions'
|
2020-02-12 16:35:35 -09:00
|
|
|
|
2021-03-31 12:58:47 -08:00
|
|
|
const useStyles = makeStyles(
|
|
|
|
|
(theme) => ({
|
2021-05-24 07:09:06 -08:00
|
|
|
albumActions: {
|
|
|
|
|
width: '100%',
|
|
|
|
|
},
|
2021-03-31 12:58:47 -08:00
|
|
|
}),
|
|
|
|
|
{
|
|
|
|
|
name: 'NDAlbumShow',
|
2023-12-18 10:56:03 -09:00
|
|
|
},
|
2021-03-31 12:58:47 -08:00
|
|
|
)
|
|
|
|
|
|
2020-11-19 14:44:28 -09:00
|
|
|
const AlbumShowLayout = (props) => {
|
|
|
|
|
const { loading, ...context } = useShowContext(props)
|
|
|
|
|
const { record } = context
|
2021-03-31 12:58:47 -08:00
|
|
|
const classes = useStyles()
|
2020-02-12 16:35:35 -09:00
|
|
|
|
2020-02-07 07:45:56 -09:00
|
|
|
return (
|
|
|
|
|
<>
|
2020-11-19 14:44:28 -09:00
|
|
|
{record && <AlbumDetails {...context} />}
|
|
|
|
|
{record && (
|
|
|
|
|
<ReferenceManyField
|
|
|
|
|
{...context}
|
|
|
|
|
addLabel={false}
|
2021-06-15 07:31:41 -08:00
|
|
|
reference="song"
|
2020-11-19 14:44:28 -09:00
|
|
|
target="album_id"
|
2020-12-18 06:48:36 -09:00
|
|
|
sort={{ field: 'album', order: 'ASC' }}
|
2020-11-19 14:44:28 -09:00
|
|
|
perPage={0}
|
|
|
|
|
pagination={null}
|
|
|
|
|
>
|
|
|
|
|
<AlbumSongs
|
2021-06-15 07:31:41 -08:00
|
|
|
resource={'song'}
|
2020-11-19 14:44:28 -09:00
|
|
|
exporter={false}
|
2021-04-24 17:40:55 -08:00
|
|
|
album={record}
|
2021-03-31 12:58:47 -08:00
|
|
|
actions={
|
|
|
|
|
<AlbumActions className={classes.albumActions} record={record} />
|
|
|
|
|
}
|
2020-11-19 14:44:28 -09:00
|
|
|
/>
|
|
|
|
|
</ReferenceManyField>
|
|
|
|
|
)}
|
2020-02-07 07:45:56 -09:00
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-19 14:44:28 -09:00
|
|
|
const AlbumShow = (props) => {
|
|
|
|
|
const controllerProps = useShowController(props)
|
|
|
|
|
return (
|
|
|
|
|
<ShowContextProvider value={controllerProps}>
|
|
|
|
|
<AlbumShowLayout {...props} {...controllerProps} />
|
|
|
|
|
</ShowContextProvider>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-07 07:45:56 -09:00
|
|
|
export default AlbumShow
|