Add Auto-Import toggle switch to playlists list view.
This commit is contained in:
@@ -82,6 +82,39 @@ const TogglePublicInput = ({ resource, source }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ToggleAutoImport = ({ resource, source }) => {
|
||||||
|
const record = useRecordContext()
|
||||||
|
console.log(record)
|
||||||
|
const notify = useNotify()
|
||||||
|
const [ToggleAutoImport] = useUpdate(
|
||||||
|
resource,
|
||||||
|
record.id,
|
||||||
|
{
|
||||||
|
...record,
|
||||||
|
sync: !record.sync,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
undoable: false,
|
||||||
|
onFailure: (error) => {
|
||||||
|
console.log(error)
|
||||||
|
notify('ra.page.error', 'warning')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
const handleClick = (e) => {
|
||||||
|
ToggleAutoImport()
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
return record.path ? (
|
||||||
|
<Switch
|
||||||
|
checked={record[source]}
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={!isWritable(record.ownerId)}
|
||||||
|
/>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
|
||||||
const PlaylistListBulkActions = (props) => (
|
const PlaylistListBulkActions = (props) => (
|
||||||
<>
|
<>
|
||||||
<ChangePublicStatusButton public={true} {...props} />
|
<ChangePublicStatusButton public={true} {...props} />
|
||||||
@@ -107,6 +140,7 @@ const PlaylistList = (props) => {
|
|||||||
<TogglePublicInput source="public" sortByOrder={'DESC'} />
|
<TogglePublicInput source="public" sortByOrder={'DESC'} />
|
||||||
),
|
),
|
||||||
comment: <TextField source="comment" />,
|
comment: <TextField source="comment" />,
|
||||||
|
sync: <ToggleAutoImport source="sync" sortByOrder={'DESC'} />,
|
||||||
}),
|
}),
|
||||||
[isDesktop, isXsmall],
|
[isDesktop, isXsmall],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user