Include the edition# when showing publication names in the UI.

master
Pacman Ghost 4 years ago
parent b84d0bc7da
commit c3cc81f552
  1. 4
      asl_articles/tests/test_articles.py
  2. 4
      web/src/ArticleSearchResult.js
  3. 14
      web/src/ArticleSearchResult2.js
  4. 13
      web/src/PublicationSearchResult.js

@ -236,7 +236,7 @@ def test_parent_publisher( webdriver, flask_app, dbconn ):
nonlocal article_sr
elem = find_child( ".title .publication", article_sr )
if expected_parent:
assert elem.text == "({})".format( expected_parent[1] )
assert elem.text == "[{}]".format( expected_parent[1] )
else:
assert elem is None
@ -255,7 +255,7 @@ def test_parent_publisher( webdriver, flask_app, dbconn ):
article_sr = results[0]
elem = find_child( ".title .publication", article_sr )
if expected_parent:
assert elem.text == "({})".format( expected_parent[1] )
assert elem.text == "[{}]".format( expected_parent[1] )
else:
assert elem is None

@ -1,5 +1,6 @@
import React from "react" ;
import { ArticleSearchResult2 } from "./ArticleSearchResult2.js" ;
import { PublicationSearchResult } from "./PublicationSearchResult.js" ;
import { gAppRef } from "./index.js" ;
import { makeScenarioDisplayName, applyUpdatedVals, removeSpecialFields, makeOptionalLink, makeCommaList } from "./utils.js" ;
@ -60,13 +61,14 @@ export class ArticleSearchResult extends React.Component
}
// NOTE: The "title" field is also given the CSS class "name" so that the normal CSS will apply to it.
// Some tests also look for a generic ".name" class name when checking search results.
const pub_display_name = pub ? PublicationSearchResult.makeDisplayName( pub ) : null ;
return ( <div className="search-result article"
ref = { r => gAppRef.setTestAttribute( r, "article_id", this.props.data.article_id ) }
>
<div className="title name">
{ image_url && <img src={image_url} className="image" alt="Article." /> }
{ makeOptionalLink( display_title, this.props.data.article_url ) }
{ pub && <span className="publication"> ({pub.pub_name}) </span> }
{ pub_display_name && <span className="publication"> [{pub_display_name}] </span> }
<img src="/images/edit.png" className="edit" onClick={this.onEditArticle.bind(this)} alt="Edit this article." />
<img src="/images/delete.png" className="delete" onClick={this.onDeleteArticle.bind(this)} alt="Delete this article." />
{ display_subtitle && <div className="subtitle" dangerouslySetInnerHTML={{ __html: display_subtitle }} /> }

@ -2,6 +2,7 @@ import React from "react" ;
import ReactDOMServer from "react-dom/server" ;
import Select from "react-select" ;
import CreatableSelect from "react-select/creatable" ;
import { PublicationSearchResult } from "./PublicationSearchResult.js" ;
import { gAppRef } from "./index.js" ;
import { ImageFileUploader } from "./FileUploader.js" ;
import { makeScenarioDisplayName, parseScenarioDisplayName, unloadCreatableSelect } from "./utils.js" ;
@ -44,18 +45,23 @@ export class ArticleSearchResult2
// initialize the publications
let publications = [ { value: null, label: <i>(none)</i> } ] ;
let currPub = 0 ;
for ( let p of Object.entries(gAppRef.caches.publications) ) {
const pub_display_name = PublicationSearchResult.makeDisplayName( p[1] ) ;
publications.push( {
value: p[1].pub_id,
label: <span dangerouslySetInnerHTML={{__html: p[1].pub_name}} />
label: <span dangerouslySetInnerHTML={{__html: pub_display_name}} />
} ) ;
if ( p[1].pub_id === vals.pub_id )
currPub = publications.length - 1 ;
}
publications.sort( (lhs,rhs) => {
return ReactDOMServer.renderToStaticMarkup( lhs.label ).localeCompare( ReactDOMServer.renderToStaticMarkup( rhs.label ) ) ;
} ) ;
let currPub = 0 ;
for ( let i=1; i < publications.length ; ++i ) {
if ( publications[i].value === vals.pub_id ) {
currPub = i ;
break ;
}
}
// initialize the authors
let allAuthors = [] ;

@ -148,16 +148,17 @@ export class PublicationSearchResult extends React.Component
} ) ;
}
_makeDisplayName( allowAlternateContent ) {
static makeDisplayName( vals, allowAlternateContent ) {
let pub_name = null ;
if ( allowAlternateContent && this.props.data["pub_name!"] )
pub_name = this.props.data[ "pub_name!" ] ;
if ( allowAlternateContent && vals["pub_name!"] )
pub_name = vals[ "pub_name!" ] ;
if ( ! pub_name )
pub_name = this.props.data.pub_name ;
if ( this.props.data.pub_edition )
return pub_name + " (" + this.props.data.pub_edition + ")" ;
pub_name = vals.pub_name ;
if ( vals.pub_edition )
return pub_name + " (" + vals.pub_edition + ")" ;
else
return pub_name ;
}
_makeDisplayName( allowAlternateContent ) { return PublicationSearchResult.makeDisplayName( this.props.data, allowAlternateContent ) ; }
}

Loading…
Cancel
Save