|
|
|
@ -34,6 +34,8 @@ class ImportSeriesSelectSeries extends Component {
|
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
|
|
this._seriesLookupTimeout = null;
|
|
|
|
|
this._buttonRef = {};
|
|
|
|
|
this._contentRef = {};
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
term: props.id,
|
|
|
|
@ -44,14 +46,6 @@ class ImportSeriesSelectSeries extends Component {
|
|
|
|
|
//
|
|
|
|
|
// Control
|
|
|
|
|
|
|
|
|
|
_setButtonRef = (ref) => {
|
|
|
|
|
this._buttonRef = ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_setContentRef = (ref) => {
|
|
|
|
|
this._contentRef = ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_addListener() {
|
|
|
|
|
window.addEventListener('click', this.onWindowClick);
|
|
|
|
|
}
|
|
|
|
@ -64,14 +58,18 @@ class ImportSeriesSelectSeries extends Component {
|
|
|
|
|
// Listeners
|
|
|
|
|
|
|
|
|
|
onWindowClick = (event) => {
|
|
|
|
|
const button = ReactDOM.findDOMNode(this._buttonRef);
|
|
|
|
|
const content = ReactDOM.findDOMNode(this._contentRef);
|
|
|
|
|
const button = ReactDOM.findDOMNode(this._buttonRef.current);
|
|
|
|
|
const content = ReactDOM.findDOMNode(this._contentRef.current);
|
|
|
|
|
|
|
|
|
|
if (!button) {
|
|
|
|
|
if (!button || !content) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!button.contains(event.target) && content && !content.contains(event.target) && this.state.isOpen) {
|
|
|
|
|
if (
|
|
|
|
|
!button.contains(event.target) &&
|
|
|
|
|
!content.contains(event.target) &&
|
|
|
|
|
this.state.isOpen
|
|
|
|
|
) {
|
|
|
|
|
this.setState({ isOpen: false });
|
|
|
|
|
this._removeListener();
|
|
|
|
|
}
|
|
|
|
@ -134,124 +132,145 @@ class ImportSeriesSelectSeries extends Component {
|
|
|
|
|
element: styles.tether
|
|
|
|
|
}}
|
|
|
|
|
{...tetherOptions}
|
|
|
|
|
>
|
|
|
|
|
<Link
|
|
|
|
|
ref={this._setButtonRef}
|
|
|
|
|
className={styles.button}
|
|
|
|
|
component="div"
|
|
|
|
|
onPress={this.onPress}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
isLookingUpSeries && isQueued && !isPopulated &&
|
|
|
|
|
<LoadingIndicator
|
|
|
|
|
className={styles.loading}
|
|
|
|
|
size={20}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
renderTarget={
|
|
|
|
|
(ref) => {
|
|
|
|
|
this._buttonRef = ref;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div ref={ref}>
|
|
|
|
|
<Link
|
|
|
|
|
className={styles.button}
|
|
|
|
|
component="div"
|
|
|
|
|
onPress={this.onPress}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
isLookingUpSeries && isQueued && !isPopulated ?
|
|
|
|
|
<LoadingIndicator
|
|
|
|
|
className={styles.loading}
|
|
|
|
|
size={20}
|
|
|
|
|
/> :
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isPopulated && selectedSeries && isExistingSeries &&
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.warningIcon}
|
|
|
|
|
name={icons.WARNING}
|
|
|
|
|
kind={kinds.WARNING}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
isPopulated && selectedSeries && isExistingSeries ?
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.warningIcon}
|
|
|
|
|
name={icons.WARNING}
|
|
|
|
|
kind={kinds.WARNING}
|
|
|
|
|
/> :
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isPopulated && selectedSeries &&
|
|
|
|
|
<ImportSeriesTitle
|
|
|
|
|
title={selectedSeries.title}
|
|
|
|
|
year={selectedSeries.year}
|
|
|
|
|
network={selectedSeries.network}
|
|
|
|
|
isExistingSeries={isExistingSeries}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
isPopulated && selectedSeries ?
|
|
|
|
|
<ImportSeriesTitle
|
|
|
|
|
title={selectedSeries.title}
|
|
|
|
|
year={selectedSeries.year}
|
|
|
|
|
network={selectedSeries.network}
|
|
|
|
|
isExistingSeries={isExistingSeries}
|
|
|
|
|
/> :
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isPopulated && !selectedSeries &&
|
|
|
|
|
<div className={styles.noMatches}>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.warningIcon}
|
|
|
|
|
name={icons.WARNING}
|
|
|
|
|
kind={kinds.WARNING}
|
|
|
|
|
/>
|
|
|
|
|
{
|
|
|
|
|
isPopulated && !selectedSeries ?
|
|
|
|
|
<div className={styles.noMatches}>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.warningIcon}
|
|
|
|
|
name={icons.WARNING}
|
|
|
|
|
kind={kinds.WARNING}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
No match found!
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
</div> :
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
!isFetching && !!error &&
|
|
|
|
|
<div>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.warningIcon}
|
|
|
|
|
title={errorMessage}
|
|
|
|
|
name={icons.WARNING}
|
|
|
|
|
kind={kinds.WARNING}
|
|
|
|
|
/>
|
|
|
|
|
{
|
|
|
|
|
!isFetching && !!error ?
|
|
|
|
|
<div>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.warningIcon}
|
|
|
|
|
title={errorMessage}
|
|
|
|
|
name={icons.WARNING}
|
|
|
|
|
kind={kinds.WARNING}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
Search failed, please try again later.
|
|
|
|
|
</div> :
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<div className={styles.dropdownArrowContainer}>
|
|
|
|
|
<Icon
|
|
|
|
|
name={icons.CARET_DOWN}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<div className={styles.dropdownArrowContainer}>
|
|
|
|
|
<Icon
|
|
|
|
|
name={icons.CARET_DOWN}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
this.state.isOpen &&
|
|
|
|
|
<div
|
|
|
|
|
ref={this._setContentRef}
|
|
|
|
|
className={styles.contentContainer}
|
|
|
|
|
>
|
|
|
|
|
<div className={styles.content}>
|
|
|
|
|
<div className={styles.searchContainer}>
|
|
|
|
|
<div className={styles.searchIconContainer}>
|
|
|
|
|
<Icon name={icons.SEARCH} />
|
|
|
|
|
}
|
|
|
|
|
renderElement={
|
|
|
|
|
(ref) => {
|
|
|
|
|
this._contentRef = ref;
|
|
|
|
|
|
|
|
|
|
if (!this.state.isOpen) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
ref={ref}
|
|
|
|
|
className={styles.contentContainer}
|
|
|
|
|
>
|
|
|
|
|
<div className={styles.content}>
|
|
|
|
|
<div className={styles.searchContainer}>
|
|
|
|
|
<div className={styles.searchIconContainer}>
|
|
|
|
|
<Icon name={icons.SEARCH} />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<TextInput
|
|
|
|
|
className={styles.searchInput}
|
|
|
|
|
name={`${name}_textInput`}
|
|
|
|
|
value={this.state.term}
|
|
|
|
|
onChange={this.onSearchInputChange}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<FormInputButton
|
|
|
|
|
kind={kinds.DEFAULT}
|
|
|
|
|
spinnerIcon={icons.REFRESH}
|
|
|
|
|
canSpin={true}
|
|
|
|
|
isSpinning={isFetching}
|
|
|
|
|
onPress={this.onRefreshPress}
|
|
|
|
|
>
|
|
|
|
|
<Icon name={icons.REFRESH} />
|
|
|
|
|
</FormInputButton>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<TextInput
|
|
|
|
|
className={styles.searchInput}
|
|
|
|
|
name={`${name}_textInput`}
|
|
|
|
|
value={this.state.term}
|
|
|
|
|
onChange={this.onSearchInputChange}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<FormInputButton
|
|
|
|
|
kind={kinds.DEFAULT}
|
|
|
|
|
spinnerIcon={icons.REFRESH}
|
|
|
|
|
canSpin={true}
|
|
|
|
|
isSpinning={isFetching}
|
|
|
|
|
onPress={this.onRefreshPress}
|
|
|
|
|
>
|
|
|
|
|
<Icon name={icons.REFRESH} />
|
|
|
|
|
</FormInputButton>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className={styles.results}>
|
|
|
|
|
{
|
|
|
|
|
items.map((item) => {
|
|
|
|
|
return (
|
|
|
|
|
<ImportSeriesSearchResultConnector
|
|
|
|
|
key={item.tvdbId}
|
|
|
|
|
tvdbId={item.tvdbId}
|
|
|
|
|
title={item.title}
|
|
|
|
|
year={item.year}
|
|
|
|
|
network={item.network}
|
|
|
|
|
onPress={this.onSeriesSelect}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
<div className={styles.results}>
|
|
|
|
|
{
|
|
|
|
|
items.map((item) => {
|
|
|
|
|
return (
|
|
|
|
|
<ImportSeriesSearchResultConnector
|
|
|
|
|
key={item.tvdbId}
|
|
|
|
|
tvdbId={item.tvdbId}
|
|
|
|
|
title={item.title}
|
|
|
|
|
year={item.year}
|
|
|
|
|
network={item.network}
|
|
|
|
|
onPress={this.onSeriesSelect}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</TetherComponent>
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|