Skip to content

Commit

Permalink
Merge pull request #1667 from thostetler/add-pubnote-to-abstract-pages
Browse files Browse the repository at this point in the history
Add pubnote to Abstract Pages
  • Loading branch information
ehenneken authored Dec 11, 2018
2 parents 560237f + f826e33 commit 970441d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 6 deletions.
27 changes: 23 additions & 4 deletions src/js/widgets/abstract/templates/abstract_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h4 class="sr-only">Abstract</h4>
<dl class="s-abstract-dl-horizontal">

{{#if pub_raw}}
<dt>Publication</dt>
<dt>Publication:</dt>
<dd>
<div id="article-publication">{{{pub_raw}}}</div>
</dd>
Expand All @@ -81,7 +81,7 @@ <h4 class="sr-only">Abstract</h4>
</dd>
{{/if}}

<dt>Bibcode</dt>
<dt>Bibcode:</dt>
<dd>
<a href="#abs/{{bibcode}}/abstract">
{{ bibcode }}
Expand All @@ -91,7 +91,7 @@ <h4 class="sr-only">Abstract</h4>

{{#if keyword}}
<div id="keywords">
<dt>Keywords</dt>
<dt>Keywords:</dt>
<dd>
<ul class="list-inline">
{{#each keyword}}
Expand All @@ -108,7 +108,7 @@ <h4 class="sr-only">Abstract</h4>

{{#if comment}}
<div id="comment">
<dt>Comments</dt>
<dt>Comments:</dt>
<dd>
<ul class="list-unstyled">
{{#each commentList}}
Expand All @@ -126,6 +126,25 @@ <h4 class="sr-only">Abstract</h4>
</div>
{{/if}}

{{#if pubnote}}
<div id="pubnote">
<dt>E-Print Comments:</dt>
<dd>
<ul class="list-unstyled">
{{#each pubnoteList}}
<li>{{{this}}}</li>
{{/each}}
{{#if hasExtraPubnotes}}
{{#if showAllPubnotes}}
<li><a href="#" id="show-less-pubnotes">show less</a></li>
{{else}}
<li><a href="#" id="show-all-pubnotes">show all</a></li>
{{/if}}
{{/if}}
</ul>
</dd>
</div>
{{/if}}

</dl>
<br/>
Expand Down
42 changes: 40 additions & 2 deletions src/js/widgets/abstract/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function (
'pub_raw': undefined,
'doi': undefined,
'citation_count': undefined,
'titleLink': undefined
'titleLink': undefined,
'pubnote': undefined
};
},

Expand Down Expand Up @@ -127,6 +128,23 @@ function (
doc.commentList = _.first(doc.comment, MAX_COMMENTS);
}

if (doc.pubnote) {
if (!_.isArray(doc.pubnote)) {
doc.pubnote = [doc.pubnote];
}

var tmp = doc.pubnote;
// attempt to parse it out
try {
doc.pubnote = doc.pubnote[0].split(';');
} catch (e) {
// do nothing
doc.pubnote = tmp;
}
doc.hasExtraPubnotes = doc.pubnote.length > MAX_COMMENTS;
doc.pubnoteList = _.first(doc.pubnote, MAX_COMMENTS);
}

return doc;
}
});
Expand All @@ -146,6 +164,8 @@ function (
events: {
'click #show-all-comments': 'showAllComments',
'click #show-less-comments': 'showLessComments',
'click #show-all-pubnotes': 'showAllPubnotes',
'click #show-less-pubnotes': 'showLessPubnotes',
'click #toggle-aff': 'toggleAffiliation',
'click #toggle-more-authors': 'toggleMoreAuthors',
'click a[data-target="more-authors"]': 'toggleMoreAuthors',
Expand All @@ -171,6 +191,24 @@ function (
});
},

showAllPubnotes: function (e) {
e.preventDefault();
var m = this.model;
m.set({
pubnoteList: m.get('comment'),
showAllPubnotes: true
});
},

showLessPubnotes: function (e) {
e.preventDefault();
var m = this.model;
m.set({
pubnoteList: _.first(m.get('pubnote'), MAX_COMMENTS),
showAllPubnotes: false
});
},

toggleMoreAuthors: function (ev) {
if (ev) {
ev.stopPropagation();
Expand Down Expand Up @@ -240,7 +278,7 @@ function (
},

defaultQueryArguments: {
fl: 'title,abstract,comment,bibcode,author,keyword,id,citation_count,[citations],pub,aff,volume,pubdate,doi,pub_raw,page',
fl: 'title,abstract,comment,bibcode,author,keyword,id,citation_count,[citations],pub,pubnote,aff,volume,pubdate,doi,pub_raw,page',
rows: 1
},

Expand Down

0 comments on commit 970441d

Please sign in to comment.