2017-09-04 02:20:56 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import Button from 'Components/Link/Button';
|
2018-08-08 00:57:15 +00:00
|
|
|
import { scrollDirections } from 'Helpers/Props';
|
2017-09-04 02:20:56 +00:00
|
|
|
import ModalContent from 'Components/Modal/ModalContent';
|
|
|
|
import ModalHeader from 'Components/Modal/ModalHeader';
|
|
|
|
import ModalBody from 'Components/Modal/ModalBody';
|
|
|
|
import ModalFooter from 'Components/Modal/ModalFooter';
|
2018-08-08 00:57:15 +00:00
|
|
|
import Table from 'Components/Table/Table';
|
|
|
|
import TableBody from 'Components/Table/TableBody';
|
|
|
|
import Scroller from 'Components/Scroller/Scroller';
|
|
|
|
import TextInput from 'Components/Form/TextInput';
|
2017-09-24 05:10:24 +00:00
|
|
|
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
2017-09-13 03:28:45 +00:00
|
|
|
import SelectAlbumRow from './SelectAlbumRow';
|
2018-08-08 00:57:15 +00:00
|
|
|
import styles from './SelectAlbumModalContent.css';
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
name: 'title',
|
|
|
|
label: 'Album Title',
|
|
|
|
isVisible: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'albumType',
|
|
|
|
label: 'Album Type',
|
|
|
|
isVisible: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'releaseDate',
|
|
|
|
label: 'Release Date',
|
|
|
|
isVisible: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'status',
|
|
|
|
label: 'Album Status',
|
|
|
|
isVisible: true
|
|
|
|
}
|
|
|
|
];
|
2017-09-04 02:20:56 +00:00
|
|
|
|
2017-09-13 03:28:45 +00:00
|
|
|
class SelectAlbumModalContent extends Component {
|
2017-09-04 02:20:56 +00:00
|
|
|
|
2018-08-08 00:57:15 +00:00
|
|
|
//
|
|
|
|
// Lifecycle
|
|
|
|
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
filter: ''
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Listeners
|
|
|
|
|
|
|
|
onFilterChange = ({ value }) => {
|
|
|
|
this.setState({ filter: value.toLowerCase() });
|
|
|
|
}
|
|
|
|
|
2017-09-04 02:20:56 +00:00
|
|
|
//
|
|
|
|
// Render
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
items,
|
2017-09-13 03:28:45 +00:00
|
|
|
onAlbumSelect,
|
2017-09-24 05:10:24 +00:00
|
|
|
onModalClose,
|
2018-08-08 00:57:15 +00:00
|
|
|
isFetching,
|
|
|
|
...otherProps
|
2017-09-04 02:20:56 +00:00
|
|
|
} = this.props;
|
|
|
|
|
2018-08-08 00:57:15 +00:00
|
|
|
const filter = this.state.filter;
|
|
|
|
|
2017-09-04 02:20:56 +00:00
|
|
|
return (
|
|
|
|
<ModalContent onModalClose={onModalClose}>
|
|
|
|
<ModalHeader>
|
2017-09-13 03:28:45 +00:00
|
|
|
Manual Import - Select Album
|
2017-09-04 02:20:56 +00:00
|
|
|
</ModalHeader>
|
|
|
|
|
2018-08-08 00:57:15 +00:00
|
|
|
<ModalBody
|
|
|
|
className={styles.modalBody}
|
|
|
|
scrollDirection={scrollDirections.NONE}
|
|
|
|
>
|
2017-09-24 05:10:24 +00:00
|
|
|
{
|
|
|
|
isFetching &&
|
|
|
|
<LoadingIndicator />
|
|
|
|
}
|
2018-08-08 00:57:15 +00:00
|
|
|
<TextInput
|
|
|
|
className={styles.filterInput}
|
|
|
|
placeholder="Filter album"
|
|
|
|
name="filter"
|
|
|
|
value={filter}
|
|
|
|
autoFocus={true}
|
|
|
|
onChange={this.onFilterChange}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Scroller className={styles.scroller}>
|
|
|
|
{
|
|
|
|
<Table
|
|
|
|
columns={columns}
|
|
|
|
{...otherProps}
|
|
|
|
>
|
|
|
|
<TableBody>
|
|
|
|
{
|
|
|
|
items.map((item) => {
|
|
|
|
return item.title.toLowerCase().includes(filter) ?
|
|
|
|
(
|
|
|
|
<SelectAlbumRow
|
|
|
|
key={item.id}
|
|
|
|
columns={columns}
|
|
|
|
onAlbumSelect={onAlbumSelect}
|
|
|
|
{...item}
|
|
|
|
/>
|
|
|
|
) :
|
|
|
|
null;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</TableBody>
|
|
|
|
</Table>
|
|
|
|
}
|
|
|
|
</Scroller>
|
2017-09-04 02:20:56 +00:00
|
|
|
</ModalBody>
|
|
|
|
|
|
|
|
<ModalFooter>
|
|
|
|
<Button onPress={onModalClose}>
|
|
|
|
Cancel
|
|
|
|
</Button>
|
|
|
|
</ModalFooter>
|
|
|
|
</ModalContent>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-13 03:28:45 +00:00
|
|
|
SelectAlbumModalContent.propTypes = {
|
2017-09-04 02:20:56 +00:00
|
|
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
2017-09-24 05:10:24 +00:00
|
|
|
isFetching: PropTypes.bool.isRequired,
|
2017-09-13 03:28:45 +00:00
|
|
|
onAlbumSelect: PropTypes.func.isRequired,
|
2017-09-04 02:20:56 +00:00
|
|
|
onModalClose: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
2017-09-13 03:28:45 +00:00
|
|
|
export default SelectAlbumModalContent;
|