Got filtering working for standard Select droplists.

master
Pacman Ghost 2 years ago
parent a0410f5960
commit d81a02317f
  1. 12
      web/src/ArticleSearchResult2.js
  2. 7
      web/src/PublicationSearchResult2.js

@ -74,13 +74,14 @@ export class ArticleSearchResult2
} ;
// initialize the publications
let publications = [ { value: null, label: <i>(none)</i> } ] ;
let publications = [ { value: null, label: <i>(none)</i>, textLabel: "" } ] ;
let mostRecentPub = null ;
for ( let p of Object.entries( gAppRef.dataCache.data.publications ) ) {
const pub_display_name = PublicationSearchResult.makeDisplayName( p[1] ) ;
const pub = {
value: p[1].pub_id,
label: <span dangerouslySetInnerHTML={{__html: pub_display_name}} />,
textLabel: pub_display_name,
} ;
publications.push( pub ) ;
if ( mostRecentPub === null || p[1].time_created > mostRecentPub[1] )
@ -107,12 +108,13 @@ export class ArticleSearchResult2
}
// initialize the publishers
let publishers = [ { value: null, label: <i>(none)</i> } ] ;
let publishers = [ { value: null, label: <i>(none)</i>, textLabel: "" } ] ;
let currPubl = publishers[0] ;
for ( let p of Object.entries( gAppRef.dataCache.data.publishers ) ) {
publishers.push( {
value: p[1].publ_id,
label: <span dangerouslySetInnerHTML={{__html: p[1].publ_name}} />
label: <span dangerouslySetInnerHTML={{__html: p[1].publ_name}} />,
textLabel: p[1].publ_name,
} ) ;
if ( p[1].publ_id === vals.publ_id )
currPubl = publishers[ publishers.length-1 ] ;
@ -190,7 +192,7 @@ export class ArticleSearchResult2
title = "Click to associate this article with a publisher."
onClick = {onPublisherParent}
> Publication: </label>
<Select className="react-select" classNamePrefix="react-select" options={publications} isSearchable={true}
<Select className="react-select" classNamePrefix="react-select" options={publications} isSearchable={true} getOptionValue={o => o.textLabel}
defaultValue = {currPub}
ref = { r => refs.pub_id=r }
/>
@ -201,7 +203,7 @@ export class ArticleSearchResult2
title="Click to associate this article with a publication."
onClick = {onPublicationParent}
> Publisher: </label>
<Select className="react-select" classNamePrefix="react-select" options={publishers} isSearchable={true}
<Select className="react-select" classNamePrefix="react-select" options={publishers} isSearchable={true} getOptionValue={o => o.textLabel}
defaultValue = {currPubl}
ref = { r => refs.publ_id=r }
/>

@ -60,12 +60,13 @@ export class PublicationSearchResult2
} ;
// initialize the publishers
let publishers = [ { value: null, label: <i>(none)</i> } ] ;
let publishers = [ { value: null, label: <i>(none)</i>, textLabel: "" } ] ;
let currPubl = publishers[0] ;
for ( let p of Object.entries( gAppRef.dataCache.data.publishers ) ) {
publishers.push( {
value: p[1].publ_id,
label: <span dangerouslySetInnerHTML={{__html: p[1].publ_name}} />
label: <span dangerouslySetInnerHTML={{__html: p[1].publ_name}} />,
textLabel: p[1].publ_name
} ) ;
if ( p[1].publ_id === vals.publ_id )
currPubl = publishers[ publishers.length-1 ] ;
@ -153,7 +154,7 @@ export class PublicationSearchResult2
<input className="pub_date" type="text" defaultValue={vals.pub_date} ref={r => refs.pub_date=r} />
</div>
<div className="row publisher"> <label className="select top"> Publisher: </label>
<Select className="react-select" classNamePrefix="react-select" options={publishers} isSearchable={true}
<Select className="react-select" classNamePrefix="react-select" options={publishers} isSearchable={true} getOptionValue={o => o.textLabel}
defaultValue = {currPubl}
ref = { r => refs.publ_id=r }
/>

Loading…
Cancel
Save