Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/js/modules/orcid/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,14 @@ define([

// get the new set of actions
var actions = self._getOrcidInfo(info);
var hasAdsMatch = !!info.isKnownToADS;

// if the record was created by ADS, we can update it now
if (info.sourcedByADS && _.isUndefined(work.source_name)) {
work.source_name = 'NASA Astrophysics Data System';
}
work.orcid = _.extend({}, work.orcid, actions, { pending: false });
work.hasAdsMatch = hasAdsMatch;

// make sure the doc has any information we gained
if (_.isUndefined(work.identifier)) {
Expand Down Expand Up @@ -287,6 +289,7 @@ define([

model.set({
orcid: actions,
hasAdsMatch: hasAdsMatch,
source_name: _.isArray(sources)
? sources.join('; ')
: model.get('source_name'),
Expand Down
18 changes: 14 additions & 4 deletions src/js/widgets/list_of_things/templates/item-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@
</div>

<div class="col-xs-4 col-sm-3 s-top-row-col identifier s-identifier">
<a href="#abs/{{encodedIdentifier}}/abstract" data-item-index="{{indexToShow}}" aria-label="bibcode" class="abs-redirect-link">
{{identifier}}
</a>
{{#if isOrcidWidget}}
{{#if (and encodedIdentifier hasAdsMatch)}}
<a href="#abs/{{encodedIdentifier}}/abstract" data-item-index="{{indexToShow}}" aria-label="bibcode" class="abs-redirect-link">
{{identifier}}
</a>
{{else}}
<span aria-label="bibcode">{{identifier}}</span>
{{/if}}
{{else}}
<a href="#abs/{{encodedIdentifier}}/abstract" data-item-index="{{indexToShow}}" aria-label="bibcode" class="abs-redirect-link">
{{identifier}}
</a>
Comment on lines +24 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this section suppose to be different from lines 17-19?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not different -- just makes the logic a little cleaner here since we section off the orcid widget items vs. regular list items.
We could combine the comparisons, do you think that would be a little cleaner vs. duplicating here?

{{/if}}
</div>
<div class="hidden-xs col-xs-1 col-md-1 col-md-offset-0 s-top-row-col print-visible-inline-1" aria-label="date published">
{{formattedDate}}
Expand Down Expand Up @@ -147,7 +157,7 @@

<div class="col-xs-10 col-xs-offset-1">
{{#if isOrcidWidget}}
{{#if encodedIdentifier}}
{{#if (and encodedIdentifier hasAdsMatch)}}
<a href="#abs/{{encodedIdentifier}}/abstract" data-item-index="{{indexToShow}}" class="abs-redirect-link">
<h3 class="s-results-title">{{{title}}}</h3>
</a>
Expand Down
53 changes: 53 additions & 0 deletions test/mocha/js/modules/orcid/orcid_widget.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,59 @@ define([
done();
});

it("should not make non-ADS ORCID works clickable", function (done) {

var orcidMode = true;

var fakeUser = {
getHardenedInstance : function(){return this},
getLocalStorage : function(){return { perPage : 50 }},
isOrcidModeOn: function() {
return orcidMode;
},
};
this.minsub.beehive.removeObject("User");
this.minsub.beehive.addObject("User", fakeUser);

var orcidApi = getOrcidApi(this.minsub.beehive);
sinon.stub(orcidApi, 'hasAccess', function() {return true});
sinon.stub(orcidApi, 'getRecordInfo', function(work) {
var deferred = $.Deferred();
var knownIds = ['2018CNSNS..56..270Q', '2018CNSNS..56..296S'];
var isKnown = knownIds.indexOf(work.identifier) > -1;
deferred.resolve({
isCreatedByADS: false,
isCreatedByOthers: !isKnown,
isKnownToADS: isKnown,
});
return deferred.promise();
});

var widget = _getWidget(this.minsub.beehive);

var bio = new Bio(helpers.getMock('bio'));
var bioResponse = new JsonResponse(bio.toADSFormat());

var profile = new Profile(helpers.getMock('profile'));
var response = new JsonResponse(profile.toADSFormat());

response.setApiQuery(new ApiQuery(bioResponse.get('responseHeader.params')));
widget.processResponse(response);

var $w = widget.render().$el;
$('#test').append($w);

setTimeout(function() {
var first = widget.view.children.findByIndex(0);
expect(first.$('.abs-redirect-link').length).to.be.above(0);

var third = widget.view.children.findByIndex(2);
expect(third.$('.abs-redirect-link').length).to.eql(0);
expect(third.$('h3.s-results-title').text().trim()).to.eql('Work # 1');
done();
}, 0);
});

it("should show a loading view before orcid profile is loaded", function(){

var orcidApi = getOrcidApi(this.minsub.beehive);
Expand Down