From f826e337c0e942958448ee0f6c57bb97210a8f79 Mon Sep 17 00:00:00 2001 From: Tim Hostetler Date: Mon, 10 Dec 2018 13:49:26 -0500 Subject: [PATCH] Add pubnote to Abstract Pages Resolves #1658 --- .../abstract/templates/abstract_template.html | 27 ++++++++++-- src/js/widgets/abstract/widget.js | 42 ++++++++++++++++++- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/js/widgets/abstract/templates/abstract_template.html b/src/js/widgets/abstract/templates/abstract_template.html index 59841c999..4d2e950f6 100644 --- a/src/js/widgets/abstract/templates/abstract_template.html +++ b/src/js/widgets/abstract/templates/abstract_template.html @@ -60,7 +60,7 @@

Abstract

{{#if pub_raw}} -
Publication
+
Publication:
{{{pub_raw}}}
@@ -81,7 +81,7 @@

Abstract

{{/if}} -
Bibcode
+
Bibcode:
{{ bibcode }} @@ -91,7 +91,7 @@

Abstract

{{#if keyword}}
-
Keywords
+
Keywords:

diff --git a/src/js/widgets/abstract/widget.js b/src/js/widgets/abstract/widget.js index 1fb81d86d..278a87197 100644 --- a/src/js/widgets/abstract/widget.js +++ b/src/js/widgets/abstract/widget.js @@ -45,7 +45,8 @@ function ( 'pub_raw': undefined, 'doi': undefined, 'citation_count': undefined, - 'titleLink': undefined + 'titleLink': undefined, + 'pubnote': undefined }; }, @@ -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; } }); @@ -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', @@ -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(); @@ -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 },