Commit 97814c86 authored by PDuarte's avatar PDuarte

pesented manu layout playlist

parent 18cf491f
...@@ -8,6 +8,7 @@ import classnames from 'classnames' ...@@ -8,6 +8,7 @@ import classnames from 'classnames'
import { getData_menupagesplaylists, updatemenupages } from '../../store/actions' import { getData_menupagesplaylists, updatemenupages } from '../../store/actions'
import DataTableServerSide from '@components/datatable' import DataTableServerSide from '@components/datatable'
import { element } from 'prop-types'
// ** Table Server Side Column // ** Table Server Side Column
const serverSideColumns = [ const serverSideColumns = [
...@@ -18,18 +19,20 @@ const serverSideColumns = [ ...@@ -18,18 +19,20 @@ const serverSideColumns = [
minWidth: '25px' minWidth: '25px'
}, },
{ {
name: 'System name', name: 'Title',
selector: 'system_name', selector: 'title',
sortable: true, sortable: true,
minWidth: '225px' minWidth: '225px'
} }
] ]
const ManagePlaylist = (ElementID) => { const ManagePlaylist = (dataElement) => {
const store = useSelector(state => state.menupages), const store = useSelector(state => state.menupages),
[avaliablePlaylists, setavaliablePlaylists] = useState([]), [avaliablePlaylists, setavaliablePlaylists] = useState([]),
[selectedPlaylists, setSelectedPlaylists] = useState([]) [selectedPlaylists, setSelectedPlaylists] = useState([]),
dispatch = useDispatch()
const handleAdd = (value) => { const handleAdd = (value) => {
const newValue = selectedPlaylists.concat(value) const newValue = selectedPlaylists.concat(value)
...@@ -39,6 +42,17 @@ const ManagePlaylist = (ElementID) => { ...@@ -39,6 +42,17 @@ const ManagePlaylist = (ElementID) => {
const newValue = selectedPlaylists.filter(element => element.id !== value.id) const newValue = selectedPlaylists.filter(element => element.id !== value.id)
setSelectedPlaylists(newValue) setSelectedPlaylists(newValue)
} }
const getData_selectedPlaylists = (params) => {
return (dispatch) => {
if (params.q === '') {
setSelectedPlaylists(dataElement.dataElement)
return
}
const newValue = dataElement.dataElement.filter(element => element.title.includes(params.q))
setSelectedPlaylists(newValue)
}
}
const serverSideColumnsLeft = [ const serverSideColumnsLeft = [
...serverSideColumns, ...serverSideColumns,
{ {
...@@ -93,6 +107,12 @@ const ManagePlaylist = (ElementID) => { ...@@ -93,6 +107,12 @@ const ManagePlaylist = (ElementID) => {
setavaliablePlaylists(filtered) setavaliablePlaylists(filtered)
}, [selectedPlaylists]) }, [selectedPlaylists])
useEffect(() => {
if (dataElement !== null && dataElement.dataElement !== null) {
setSelectedPlaylists(dataElement.dataElement)
}
}, [dataElement])
return <div className="card"> return <div className="card">
<div className="card-header"> <div className="card-header">
<h4 className="card-title">playlist</h4> <h4 className="card-title">playlist</h4>
...@@ -103,7 +123,7 @@ const ManagePlaylist = (ElementID) => { ...@@ -103,7 +123,7 @@ const ManagePlaylist = (ElementID) => {
<DataTableServerSide <DataTableServerSide
cardTitle='Content' cardTitle='Content'
allData={selectedPlaylists} allData={selectedPlaylists}
getData={getData_menupagesplaylists} getData={getData_selectedPlaylists}
serverSideColumns={serverSideColumnsLeft} serverSideColumns={serverSideColumnsLeft}
// linkAddButton={`/add`} // linkAddButton={`/add`}
total={selectedPlaylists.length} total={selectedPlaylists.length}
......
...@@ -112,7 +112,7 @@ const TabLayoutPlaylist = ({block, selectedDataElement, setElementData}) => { ...@@ -112,7 +112,7 @@ const TabLayoutPlaylist = ({block, selectedDataElement, setElementData}) => {
</div> </div>
</div> </div>
<ManagePlaylist ElementID={dataElement && dataElement.layout_id} /> <ManagePlaylist dataElement={dataElement && dataElement.playlists} />
</Col> </Col>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment