Show the parent publisher/publication in the UI.

master
Pacman Ghost 5 years ago
parent 4ddd071f3b
commit 2c4e1bbd4a
  1. 4
      asl_articles/tests/test_publications.py
  2. 4
      asl_articles/tests/test_publishers.py
  3. 2
      web/src/ArticleSearchResult.js
  4. 2
      web/src/PublicationSearchResult.js
  5. 2
      web/src/SearchResults.css

@ -144,14 +144,14 @@ def test_cascading_deletes( webdriver, flask_app, dbconn ):
results = do_search( "" )
# delete the specified publication
results = [ r for r in results if find_child(".name",r).text == pub_name ]
results = [ r for r in results if find_child( ".name", r ).text == pub_name ]
assert len( results ) == 1
find_child( ".delete", results[0] ).click()
check_ask_dialog( ( "Delete this publication?", pub_name, expected_warning ), "ok" )
# check that deleted associated articles were removed from the UI
def check_articles( results ):
results = [ find_child(".name",r).text for r in results ]
results = [ find_child( ".name span", r ).text for r in results ]
articles = [ r for r in results if r.startswith( "article" ) ]
assert articles == expected_articles
check_articles( find_children( "#search-results .search-result" ) )

@ -135,7 +135,7 @@ def test_cascading_deletes( webdriver, flask_app, dbconn ):
def check_results( results, sr_type, expected, expected_deletions ):
expected = [ "{} {}".format( sr_type, p ) for p in expected ]
expected = [ e for e in expected if e not in expected_deletions ]
results = [ find_child(".name",r).text for r in results ]
results = [ find_child( ".name span", r ).text for r in results ]
results = [ r for r in results if r.startswith( sr_type ) ]
assert results == expected
@ -146,7 +146,7 @@ def test_cascading_deletes( webdriver, flask_app, dbconn ):
results = do_search( "" )
# delete the specified publisher
results = [ r for r in results if find_child(".name",r).text == publ_name ]
results = [ r for r in results if find_child( ".name", r ).text == publ_name ]
assert len( results ) == 1
find_child( ".delete", results[0] ).click()
check_ask_dialog( ( "Delete this publisher?", publ_name, expected_warning ), "ok" )

@ -12,10 +12,12 @@ export class ArticleSearchResult extends React.Component
{
render() {
const pub = gAppRef.caches.publications[ this.props.data.pub_id ] ;
// 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.
return ( <div className="search-result article">
<div className="title name"> { makeOptionalLink( this.props.data.article_title, this.props.data.article_url ) }
{ pub && <span className="publication"> ({pub.pub_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." />
{ this.props.data.article_subtitle && <div className="subtitle" dangerouslySetInnerHTML={{ __html: this.props.data.article_subtitle }} /> }

@ -12,8 +12,10 @@ export class PublicationSearchResult extends React.Component
{
render() {
const publ = gAppRef.caches.publishers[ this.props.data.publ_id ] ;
return ( <div className="search-result publication">
<div className="name"> { makeOptionalLink( this._makeDisplayName(), this.props.data.pub_url ) }
{ publ && <span className="publisher"> ({publ.publ_name}) </span> }
<img src="/images/edit.png" className="edit" onClick={this.onEditPublication.bind(this)} alt="Edit this publication." />
<img src="/images/delete.png" className="delete" onClick={this.onDeletePublication.bind(this)} alt="Delete this publication." />
</div>

@ -8,6 +8,8 @@
.search-result .name { padding: 2px 5px ; }
.search-result .name a { font-weight: bold ; text-decoration: none ; }
.search-result .name .publisher { font-size: 80% ; font-style: italic ; }
.search-result .name .publication { font-size: 80% ; font-style: italic ; }
.search-result .name img.edit { margin-left: 0.5em ; height: 0.8em ; cursor: pointer ; }
.search-result .name img.delete { float: right ; margin: 0.2em 0 0 0.5em ; height: 0.8em ; cursor: pointer ; }
.search-result .description { font-size: 80% ; padding: 2px 5px ; }

Loading…
Cancel
Save