Skip to content

Commit

Permalink
Merge pull request #764 from aholachek/loading-views
Browse files Browse the repository at this point in the history
Loading views
  • Loading branch information
aholachek committed Jan 21, 2016
2 parents ad2a6c7 + d59c1d6 commit 266b627
Show file tree
Hide file tree
Showing 16 changed files with 259 additions and 148 deletions.
3 changes: 2 additions & 1 deletion common-patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ var pubsub = that.getBeeHive().getPubSub();
msg: "Logged in to ADS",
type: "success",
modal : true
}));
}));

92 changes: 45 additions & 47 deletions src/js/modules/orcid/widget/templates/container-template.html
Original file line number Diff line number Diff line change
@@ -1,71 +1,69 @@

<div class="row s-results-control-row-container" style="text-align: center">
<div class="col-sm-10 col-sm-offset-1" >
<!--static orcid info-->
<div style="margin-top: 20px;">
<img src="../../styles/img/ads-orcid.svg" alt="the ORCID logo combined with ADS logo" style="max-width: 150px;"/>
</div>
<div class="row s-results-control-row-container" style="text-align: center">
<div class="col-sm-10 col-sm-offset-1" >
<!--static orcid info-->
<div style="margin-top: 20px;">
<img src="../../styles/img/ads-orcid.svg" alt="the ORCID logo combined with ADS logo" style="max-width: 150px;"/>
</div>
<!--loading user data-->
{{#if loading}}
<p><i class="icon-loading"></i> Loading...</p>
{{else}}
<h3> You are signed in to ORCID as <b>{{orcidUserName}}</b></h3>
<p class="leader-text" style="margin-bottom: 0">
<a href="#orcid-instructions">Learn more about using ORCID with ADS.</a>
</p>

<br/>
{{/if}}

</div>
</div>
<div class="row s-darker-background">
<div class="col-sm-10 col-sm-offset-1 s-main-content-container" style="margin-top:20px;">
</div>
<div class="row s-darker-background">
<div class="col-sm-10 col-sm-offset-1 s-main-content-container" style="margin-top:20px;">

<div class="s-list-controls">
<div class="s-list-controls">

<div class="s-results-border-bottom">
<div class="s-results-border-bottom">

<div class="col-sm-12">
<div class="col-sm-12">
{{#unless loading}}
<h3 style="margin:48px 6.5%;"> <span class="s-light-font">My ORCID Papers</h3>
{{#if orcidUserName}}
<div style="margin:-20px 0 20px 6.5%" class="leader-text"> To claim papers in ORCID and add to this list, <button class="btn sm btn-default search-author-name"><i class="fa fa-search"></i> click here to search your name in ADS</button></div>
{{else}}
<div style="margin:-20px 0 20px 6.5%" class="leader-text"> To claim papers in ORCID and add to this list, search your name in ADS</button></div>
<div style="margin:-20px 0 20px 6.5%" class="leader-text"> To claim papers in ORCID and add to this list, search your name in ADS</button></div>
{{/if}}
</div>

{{/unless}}
</div>
</div>

<div class="row">
</div>
</div>

{{#if title}}
<div class="col-sm-12">
<h2 class="s-article-title">{{{title}}}</h2>
<div class="row">
<ul class="col-sm-12 results-list s-results-list list-unstyled s-display-block" aria-label="list of results">
</ul>
</div>
{{#if pagination}}
<div class="row">
<div class="col-sm-12 pagination-controls s-pagination-controls">
<div class="col-sm-5 col-sm-offset-2">
<ul class="pagination">
{{#if showFirst}}
<li><a href="search/{{../currentQuery}}" data-paginate = "1" data-bypass>&laquo;</a></li>
{{/if}}
{{#each pageData}}
<li {{#if this.current}} class="active" {{/if}} >
<a href="{{this.link}}" data-bypass data-paginate = "{{this.p}}" >{{this.p}} </a>
</li>
{{/each}}
</ul>
</div>
{{/if}}

<ul class="col-sm-12 results-list s-results-list list-unstyled s-display-block" aria-label="list of results">
</ul>

</div>
{{#if pagination}}
<div class="row">
<div class="col-sm-12 pagination-controls s-pagination-controls">
<div class="col-sm-5 col-sm-offset-2">
<ul class="pagination">
{{#if showFirst}}
<li><a href="search/{{../currentQuery}}" data-paginate = "1" data-bypass>&laquo;</a></li>
{{/if}}
{{#each pageData}}
<li {{#if this.current}} class="active" {{/if}} >
<a href="{{this.link}}" data-bypass data-paginate = "{{this.p}}" >{{this.p}} </a>
</li>
{{/each}}
</ul>
</div>
<div class="col-sm-5 s-per-page-controls">
Show <input class="per-page" type="text" placeholder="{{perPage}}"/> per page
</div>
<div class="col-sm-5 s-per-page-controls">
Show <input class="per-page" type="text" placeholder="{{perPage}}"/> per page
</div>
</div>
{{/if}}

</div>
{{/if}}

</div>
</div>
10 changes: 7 additions & 3 deletions src/js/modules/orcid/widget/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ define([
this.listenTo(this.view, "search-author-name", function(searchTerm){
var pubsub = this.getPubSub(), query = new ApiQuery({q : searchTerm});
pubsub.publish(pubsub.START_SEARCH, query);
})
});

this.on('orcid-update-finished', this.mergeDuplicateRecords);
},
Expand Down Expand Up @@ -250,6 +250,8 @@ define([
if (!oApi.hasAccess())
return;

self.model.set("loading", true);

oApi.getOrcidProfileInAdsFormat()
.done(function(data) {
var response = new JsonResponse(data);
Expand All @@ -264,9 +266,11 @@ define([

response.setApiQuery(new ApiQuery(params));
self.processResponse(response);
self.model.set({orcidUserName : params.firstName + " " + params.lastName,
self.model.set({
orcidUserName : params.firstName + " " + params.lastName,
orcidFirstName : params.firstName,
orcidLastName : params.lastName
orcidLastName : params.lastName,
loading: false
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/widgets/preferences/templates/openurl.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="panel-heading"> Library Link Server </div>

<div class="panel-body">
{{#if error}}
<p>Sorry, the library link information for your account could not be retrieved. Please try again later.</p>
{{#if loading}}
<p><i class="icon-loading"></i> Loading...</p>
{{else}}

{{#if openURLName}}
Expand Down
110 changes: 60 additions & 50 deletions src/js/widgets/preferences/templates/orcid.html
Original file line number Diff line number Diff line change
@@ -1,61 +1,67 @@
<div class="panel-heading">

ORCID Settings
{{#if orcidLoggedIn}}
<h4>You are signed in to ORCID as <b>{{prettyOrcidName}}</b></h4>
{{#if loading}}
<div class="panel-heading">ORCID SETTINGS</div>
<div class="panel-body"> <p><i class="icon-loading"></i> Loading...</p></div>
{{else}}

<p> Not you?
<button class="btn btn-sm btn-default orcid-authenticate">Sign into ORCID as a different user</button>
</p>
{{/if}}
<div class="panel-heading">

</div>
<div class="panel-body">
ORCID Settings
{{#if orcidLoggedIn}}
<h4>You are signed in to ORCID as <b>{{prettyOrcidName}}</b></h4>

{{#if orcidLoggedIn}}
<p> Not you?
<button class="btn btn-sm btn-default orcid-authenticate">Sign into ORCID as a different user</button>
</p>
{{/if}}

<div class="form-group">
<h4>1. Your Current Academic Affiliation</h4>
<div class="form-group">
<label for="#aff-input" class="sr-only">your current academic affiliation</label>
<input type="text"
{{#if userSubmitted.currentAffiliation}} value="{{userSubmitted.currentAffiliation}}" {{/if}}
id="aff-input"
class="form-control"
placeholder="e.g. Wesleyan University"
style="width:300px">
</div>
</div>
<div class="panel-body">

<br>
<h4 id="name-variant-header">2. Names Under Which You Have Published</h4>
<p class="emphasis-text">
If you have published under a different surname, for example,
or using a middle name, please add those name variations here.
</p>

<div class="form-group well orcid-name-container clearfix" aria-labelledby="#name-variant-header">

<div class="input-list">
<div class="original-orcid-name">
<!--this isnt editable-->
<label for="original-orcid-name">ORCID name</label>
<input class="form-control input-list__input"
type="text"
id="original-orcid-name"
value="{{orcidName}}" disabled>
{{#if orcidLoggedIn}}

<div class="form-group">
<h4>1. Your Current Academic Affiliation</h4>
<div class="form-group">
<label for="#aff-input" class="sr-only">your current academic affiliation</label>
<input type="text"
{{#if userSubmitted.currentAffiliation}} value="{{userSubmitted.currentAffiliation}}" {{/if}}
id="aff-input"
class="form-control"
placeholder="e.g. Wesleyan University"
style="width:300px">
</div>
{{#each userSubmitted.nameVariations }}
<div class="orcid-name-row">
<input class="form-control input-list__input" type="text" placeholder="Last, First Middle" value="{{this}}">
</div>

<br>
<h4 id="name-variant-header">2. Names Under Which You Have Published</h4>
<p class="emphasis-text">
If you have published under a different surname, for example,
or using a middle name, please add those name variations here.
</p>

<div class="form-group well orcid-name-container clearfix" aria-labelledby="#name-variant-header">

<div class="input-list">
<div class="original-orcid-name">
<!--this isnt editable-->
<label for="original-orcid-name">ORCID name</label>
<input class="form-control input-list__input"
type="text"
id="original-orcid-name"
value="{{orcidName}}" disabled>
</div>
{{#each userSubmitted.nameVariations }}
<div class="orcid-name-row">
<input class="form-control input-list__input" type="text" placeholder="Last, First Middle" value="{{this}}">
<button class="btn btn-danger btn-inverse remove-name" title="remove this name"><i class="fa fa-minus-circle"></i></button>
</div>
{{/each}}
<button class="btn btn-primary-faded pull-right add-another-orcid-name"><i class="fa fa-plus"> </i> add a name</button>
</div>
{{/each}}
<button class="btn btn-primary-faded pull-right add-another-orcid-name"><i class="fa fa-plus"> </i> add a name</button>

<div class="warning {{#compare userSubmitted.authorizedUser false operator="!=="}} hidden {{/compare}}" style="clear:both;padding-top:15px" >
<i class="fa fa-lg fa-warning"></i>
To become an ADS-verified user and have the above name data used to enrich your ORCID matches in ADS, you must check the box below.
<div class="warning {{#compare userSubmitted.authorizedUser false operator="!=="}} hidden {{/compare}}" style="clear:both;padding-top:15px" >
<i class="fa fa-lg fa-warning"></i>
To become an ADS-verified user and have the above name data used to enrich your ORCID matches in ADS, you must check the box below.
</div>
</div>
</div>
Expand All @@ -67,7 +73,7 @@ <h4> 3. Permission for ADS to Record and Publish Claims</h4>
<label class="emphasis-text">
<input type="checkbox"
{{#if userSubmitted.authorizedUser}} checked {{/if}}
{{#compare userSubmitted.authorizedUser undefined}} checked {{/compare}}
{{#compare userSubmitted.authorizedUser undefined}} checked {{/compare}}
class="authorized-ads-user">
I allow the ADS to record my claims and to make them available publically for auditing and indexing.
<br>This makes me an "ADS Verified User" and allows ADS to validate my name(s) against author lists in papers.
Expand All @@ -86,4 +92,8 @@ <h4> 3. Permission for ADS to Record and Publish Claims</h4>
</button>

{{/if}}
</div>
</div>


{{/if}}

7 changes: 4 additions & 3 deletions src/js/widgets/preferences/views/openurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ define([
serializeData : function(){

var data = this.model.toJSON();
//probably a server error
if (!data.openURLConfig || data.openURLConfig.length === 0){
data.error = true;
//either user data or openurl data has yet to load
if (!data.openURLConfig || !data.user ){
data.loading = true;
return data
}

Expand All @@ -37,6 +37,7 @@ define([

modelEvents : {
"change:link_server" : "render",
"change:user" : "render",
"change:openURLConfig" : "render"
},

Expand Down
6 changes: 4 additions & 2 deletions src/js/widgets/preferences/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define([
defaults : function(){
return {
openURLConfig : undefined,
orcidLoggedIn : undefined
orcidLoggedIn : undefined,
}
}

Expand Down Expand Up @@ -114,11 +114,12 @@ define([
var that = this;

this.model.set("orcidLoggedIn", this.getBeeHive().getService("OrcidApi").hasAccess());

/*right now only orcid view needs extra data */

if (subView === "orcid" && this.model.get("orcidLoggedIn") ){

this.model.set("loading", true);

//get main orcid name
var orcidProfile = this.getBeeHive().getService("OrcidApi").getUserProfile();
var adsOrcidUserInfo = this.getBeeHive().getService("OrcidApi").getADSUserData();
Expand All @@ -136,6 +137,7 @@ define([
data.orcidName = "unknown";
data.prettyOrcidName = "unknown";
}
data.loading = false;
that.model.set(data);
});
}
Expand Down
Loading

0 comments on commit 266b627

Please sign in to comment.