-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added library sidebar widget to abstract page
- Loading branch information
Showing
13 changed files
with
185 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{{#if loggedIn}} | ||
<div class="s-library-area"> | ||
<div class="s-library-add-title library-add-title" type="button" data-toggle="collapse" data-target="#library-console" aria-expanded="false" aria-controls="collapseExample"> | ||
<i class="fa fa-book fa-lg"></i> Add this paper to library <i class="fa fa-lg fa-caret-down"></i> | ||
</div> | ||
<div class="collapse {{#if libraryDrawerOpen }} in {{/if}}" id="library-console"> | ||
|
||
<div class="libraries-container"> | ||
{{#if libraries}} | ||
<div style="margin-top: 8px" class=""> | ||
<label for="#library-select">to an <b>existing library:</b></label> | ||
<select id="library-select" name="library-select" class="form-control input-sm s-library-select"> | ||
{{#each libraries}} | ||
<option value="{{this.id}}" {{#compare id ../selectedLibrary}} selected="true" {{/compare}}>{{this.name}}</option> | ||
{{/each}} | ||
</select> | ||
<button class="btn btn-sm btn-success submit-add-to-library">submit</button> | ||
</div> | ||
<div style="margin:10px 0 4px 0"> | ||
OR | ||
</div> | ||
<label style="width: 200px;font-weight:500">create a new library | ||
<input class="form-control input-sm new-library-name s-display-inline" type="text" name="new-library-name" placeholder="New Library Name" value="{{newLibraryName}}"/> | ||
</label> | ||
<button class="btn btn-sm btn-success submit-create-library"></i>submit</button> | ||
{{else}} | ||
<label style="width:200px;font-weight:500"> create a new library | ||
<input class="form-control input-sm new-library-name s-display-inline" type="text" name="new-library-name" placeholder="New Library Name" value="{{newLibraryName}}"/> | ||
</label> | ||
<button class="btn btn-sm btn-success submit-create-library"></i>submit</button> | ||
{{/if}} | ||
|
||
</div> | ||
|
||
<div style="margin-top:6px" class="feedback s-feedback"> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
{{#if feedback}} | ||
|
||
{{#if feedback.success}} | ||
|
||
<div class="alert alert-success alert-dismissable" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
{{#if feedback.create}} | ||
<a href="#/user/libraries/{{feedback.id}}"> Library <b>{{feedback.name}}</b></a> was successfully created and {{feedback.numRecords}} new records were added. | ||
{{else}} | ||
{{feedback.numRecords}} new records were added to <a href="#/user/libraries/{{feedback.id}}"> library <b>{{feedback.name}}</b></a>. | ||
{{#if feedback.numAlreadyInLib}} | ||
({{feedback.numAlreadyInLib}} were already in the library). | ||
{{/if}} | ||
{{/if}} | ||
</div> | ||
|
||
{{else}} | ||
|
||
<div class="alert alert-danger alert-dismissable" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
{{#if feedback.create}} | ||
<b>{{feedback.name}}</b> was not created, error occured. | ||
<em>{{feedback.error}}</em> | ||
{{else}} | ||
Records were not added to <b>{{feedback.name}}</b>, error occurred. | ||
<em>{{feedback.error}}</em> | ||
{{/if}} | ||
</div> | ||
|
||
{{/if}} | ||
|
||
{{/if}} | ||
|
||
<!--end 'library area' if user is signed in--> | ||
</div> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
define([ | ||
"js/widgets/query_info/query_info_widget", | ||
"js/widgets/base/base_widget", | ||
"hbs!./template" | ||
], | ||
function( | ||
QueryInfoWidget, | ||
BaseWidget, | ||
template | ||
){ | ||
|
||
var AbstractLibraryWidget = QueryInfoWidget.extend({ | ||
|
||
//flag for functions that send bibs to library | ||
abstractPage : true, | ||
|
||
//add new template | ||
initialize: function(options) { | ||
options = options || {}; | ||
this.model = new this.modelConstructor(); | ||
this.view = new this.viewConstructor({model : this.model, template : template}); | ||
BaseWidget.prototype.initialize.call(this, options); | ||
}, | ||
|
||
//don't need to subscribe to storage paper update, do need to subscribe to display_documents | ||
activate: function(beehive) { | ||
|
||
this.setBeeHive(beehive); | ||
_.bindAll(this); | ||
|
||
var pubsub = this.getPubSub(); | ||
pubsub.subscribe(pubsub.LIBRARY_CHANGE, this.processLibraryInfo); | ||
pubsub.subscribe(pubsub.USER_ANNOUNCEMENT, this.handleUserAnnouncement); | ||
pubsub.subscribe(pubsub.DISPLAY_DOCUMENTS, this.onDisplayDocuments); | ||
|
||
//check if user is signed in (because widget was just instantiated, but app might have been running for a while | ||
if (this.getBeeHive().getObject("User").isLoggedIn()) { | ||
// know whether to show library panel | ||
this.model.set("loggedIn", true); | ||
//fetch list of libraries | ||
var libraryData = this.getBeeHive().getObject("LibraryController").getAllMetadata(); | ||
this.processLibraryInfo(libraryData); | ||
} | ||
|
||
}, | ||
|
||
onDisplayDocuments: function(apiQuery) { | ||
var bibcode = apiQuery.get('q'); | ||
if (bibcode.length > 0 && bibcode[0].indexOf('bibcode:') > -1) { | ||
bibcode = bibcode[0].replace('bibcode:', ''); | ||
this._bibcode = bibcode; | ||
} | ||
}, | ||
|
||
|
||
}); | ||
|
||
return AbstractLibraryWidget | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters