|
|
|
@ -45,16 +45,16 @@ export class SearchResults extends React.Component |
|
|
|
|
this.props.searchResults.forEach( sr => { |
|
|
|
|
if ( sr._type === "publisher" ) { |
|
|
|
|
results.push( <PublisherSearchResult key={"publisher:"+sr.publ_id} data={sr} |
|
|
|
|
onDelete = { (n,v) => this.onDeleteSearchResult( n, v ) } |
|
|
|
|
onDelete = { (n,v,i) => this.onDeleteSearchResult( n, v, i ) } |
|
|
|
|
/> ) ; |
|
|
|
|
} else if ( sr._type === "publication" ) { |
|
|
|
|
results.push( <PublicationSearchResult key={"publication:"+sr.pub_id} data={sr} |
|
|
|
|
onDelete = { (n,v) => this.onDeleteSearchResult( n, v ) } |
|
|
|
|
onDelete = { (n,v,i) => this.onDeleteSearchResult( n, v, i ) } |
|
|
|
|
onArticleClick = { (a) => scrollToArticle(a) } |
|
|
|
|
/> ) ; |
|
|
|
|
} else if ( sr._type === "article" ) { |
|
|
|
|
results.push( <ArticleSearchResult key={"article:"+sr.article_id} data={sr} |
|
|
|
|
onDelete = { (n,v) => this.onDeleteSearchResult( n, v ) } |
|
|
|
|
onDelete = { (n,v,i) => this.onDeleteSearchResult( n, v, i ) } |
|
|
|
|
ref = { r => articleRefs[sr.article_id] = r } |
|
|
|
|
/> ) ; |
|
|
|
|
} else { |
|
|
|
@ -65,16 +65,26 @@ export class SearchResults extends React.Component |
|
|
|
|
return <div id="search-results" seqno={this.props.seqNo}> {results} </div> ; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onDeleteSearchResult( idName, idVal ) { |
|
|
|
|
onDeleteSearchResult( idName, idVal, ignoreNotFound ) { |
|
|
|
|
// look for the specified search result
|
|
|
|
|
for ( let i=0 ; i < this.props.searchResults.length ; ++i ) { |
|
|
|
|
const sr = this.props.searchResults[ i ] ; |
|
|
|
|
if ( sr[idName] === idVal ) { |
|
|
|
|
// found it - remove it the UI
|
|
|
|
|
this.props.searchResults.splice( i, 1 ) ; |
|
|
|
|
this.forceUpdate() ; |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
gAppRef.logInternalError( "Tried to delete an unknown search result.", idName+" = "+idVal ) ; |
|
|
|
|
// the search result wasn't found
|
|
|
|
|
// NOTE: This would normally indicate an internal coding error, but there is one case where
|
|
|
|
|
// it can happen: when a publisher or publication is deleted, we want to also delete all
|
|
|
|
|
// their child objects, but they may not necessarily be on-screen.
|
|
|
|
|
if ( ! ignoreNotFound ) { |
|
|
|
|
gAppRef.logInternalError( |
|
|
|
|
"Tried to delete an unknown search result.", idName+" = "+idVal |
|
|
|
|
) ; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|