Skip to content

Commit d1433cb

Browse files
committed
Merge branch 'release/0.106.0'
2 parents b52bf4b + d310c80 commit d1433cb

33 files changed

+634
-252
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ install:
2020
- ./node_modules/bower/bin/bower install --config.interactive=false
2121

2222
script:
23-
- yarn test
23+
- yarn test:cover
24+
25+
after_success:
26+
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
`develop` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-preprints.svg?branch=develop)](https://travis-ci.org/CenterForOpenScience/ember-preprints)
66

7+
[![Coverage Status](https://coveralls.io/repos/github/CenterForOpenScience/ember-preprints/badge.svg?branch=develop)](https://coveralls.io/github/CenterForOpenScience/ember-preprints?branch=develop)
8+
79
This is the codebase for OSF preprints.
810
This guide will help you get started if you're interested.
911

app/components/preprint-form-authors.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import Analytics from '../mixins/analytics';
3838
export default CpPanelBodyComponent.extend(Analytics, {
3939
valid: Ember.computed.alias('newContributorId'),
4040
authorModification: false,
41+
currentPage: 1,
4142
// Permissions labels for dropdown
4243
permissionOptions: permissionSelector,
4344
parentContributorsAdded: false,
@@ -266,6 +267,20 @@ export default CpPanelBodyComponent.extend(Analytics, {
266267
this.get('toast').error('Could not reorder contributors');
267268
draggedContrib.rollbackAttributes();
268269
});
270+
},
271+
// Action used by the pagination-pager component to the handle user-click event.
272+
pageChanged(current) {
273+
let query = this.get('query');
274+
if (query) {
275+
this.attrs.findContributors(query, current).then(() => {
276+
this.set('addState', 'searchView');
277+
this.set('currentPage', current);
278+
})
279+
.catch(() => {
280+
this.get('toast').error('Could not perform search query.');
281+
this.highlightSuccessOrFailure('author-search-box', this, 'error');
282+
});
283+
}
269284
}
270285
},
271286
// TODO find alternative to jquery selectors. Temporary popover content for authors page.

app/components/search-result.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ export default Ember.Component.extend(Analytics, {
4343
return result.description.slice();
4444
}),
4545

46+
justContributors: Ember.computed('result', function() {
47+
return this.get('result.contributors').filter(item => !!item.users.bibliographic);
48+
}),
49+
50+
shortContributorList: Ember.computed('justContributors', function() {
51+
return this.get('justContributors').slice(0, Math.min(10, this.get('justContributors').length));
52+
}),
53+
54+
hasMoreContributors: Ember.computed('justContributors', 'shortContributorList', function () {
55+
return this.get('shortContributorList').length < this.get('justContributors').length;
56+
}),
57+
4658
osfID: Ember.computed('result', function() {
4759
let re = /osf.io\/(\w+)\/$/;
4860
// NOTE / TODO : This will have to be removed later. Currently the only "true" preprints are solely from the OSF

app/components/supplementary-file-browser.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Ember from 'ember';
22
import loadAll from 'ember-osf/utils/load-relationship';
33
import Analytics from '../mixins/analytics';
4+
import fileDownloadPath from '../utils/file-download-path';
5+
46
/**
57
* @module ember-preprints
68
* @submodule components
@@ -57,6 +59,10 @@ export default Ember.Component.extend(Analytics, {
5759
});
5860
}.observes('preprint'),
5961

62+
fileDownloadURL: Ember.computed('selectedFile', function() {
63+
return fileDownloadPath(this.get('selectedFile'), this.get('node'));
64+
}),
65+
6066
init() {
6167
this._super(...arguments);
6268
this.__files();

app/controllers/content.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import loadAll from 'ember-osf/utils/load-relationship';
33
import config from 'ember-get-config';
44
import Analytics from '../mixins/analytics';
55
import permissions from 'ember-osf/const/permissions';
6+
import fileDownloadPath from '../utils/file-download-path';
67

78
/**
89
* Takes an object with query parameter name as the key and value, or [value, maxLength] as the values.
@@ -54,6 +55,7 @@ export default Ember.Controller.extend(Analytics, {
5455
fullScreenMFR: false,
5556
expandedAuthors: true,
5657
showLicenseText: false,
58+
fileDownloadURL: '',
5759
expandedAbstract: false,
5860
isAdmin: Ember.computed('node', function() {
5961
// True if the current user has admin permissions for the node that contains the preprint
@@ -137,6 +139,12 @@ export default Ember.Controller.extend(Analytics, {
137139
return text;
138140
}),
139141

142+
_fileDownloadURL: Ember.observer('model.primaryFile', function() {
143+
this.get('model.primaryFile').then(file => {
144+
this.set('fileDownloadURL', fileDownloadPath(file, this.get('node')));
145+
});
146+
}),
147+
140148
useShortenedDescription: Ember.computed('node.description', function() {
141149
return this.get('node.description') ? this.get('node.description').length > 350 : false;
142150
}),
@@ -184,25 +192,20 @@ export default Ember.Controller.extend(Analytics, {
184192
chooseFile(fileItem) {
185193
this.set('activeFile', fileItem);
186194
},
187-
shareLink(href, network, action) {
195+
shareLink(href, category, action, label) {
188196
const metrics = Ember.get(this, 'metrics');
189197

190-
if (network.includes('email')) {
191-
metrics.trackEvent({
192-
category: 'link',
193-
action,
194-
label: `Preprints - Content - Email ${window.location.href}`
195-
});
196-
} else {
197-
window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400');
198-
// TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. For now, we'll use trackEvent.
199-
metrics.trackEvent({
200-
category: network,
201-
action,
202-
label: `Preprints - Content - ${window.location.href}`
203-
});
204-
}
198+
// TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. For now, we'll use trackEvent.
199+
metrics.trackEvent({
200+
category,
201+
action,
202+
label
203+
});
204+
205+
if (label.includes('email'))
206+
return;
205207

208+
window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400');
206209
return false;
207210
}
208211
},

app/controllers/discover.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default Ember.Controller.extend(Analytics, {
5050
subjectFilter: null,
5151
queryBody: {},
5252
providersPassed: false,
53-
53+
pageNumbers: [],
5454
sortByOptions: ['Relevance', 'Upload date (oldest to newest)', 'Upload date (newest to oldest)'],
5555

5656
treeSubjects: Ember.computed('activeFilters', function() {
@@ -237,9 +237,21 @@ export default Ember.Controller.extend(Analytics, {
237237
return this.set('results', results);
238238
});
239239
},
240+
totalPages: Ember.computed('numberOfResults', 'size', function() {
241+
return Math.ceil(this.get('numberOfResults') / this.get('size'));
242+
}),
243+
240244
maxPages: Ember.computed('numberOfResults', function() {
241245
return ((this.get('numberOfResults') / this.get('size')) | 0) + (this.get('numberOfResults') % 10 === 0 ? 0 : 1);
242246
}),
247+
248+
// TODO update this property if a solution is found for the elastic search limitation.
249+
// Ticket: SHARE-595
250+
numPages: Ember.computed('size', 'totalPages', function() {
251+
let maxPages = Math.ceil(10000 / this.get('size'));
252+
return this.get('totalPages') < maxPages ? this.get('totalPages') : maxPages;
253+
}),
254+
243255
getQueryBody() {
244256
const facetFilters = this.get('activeFilters');
245257

@@ -355,6 +367,11 @@ export default Ember.Controller.extend(Analytics, {
355367
}
356368
},
357369

370+
setLoadPage(pageNumber) {
371+
this.set('page', pageNumber);
372+
this.loadPage();
373+
},
374+
358375
clearFilters() {
359376
this._clearFilters();
360377

@@ -399,5 +416,6 @@ export default Ember.Controller.extend(Analytics, {
399416
label: `Preprints - Discover - ${filterType} ${item}`
400417
});
401418
},
419+
402420
},
403421
});

app/controllers/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,23 @@ export default Ember.Controller.extend(Analytics, {
6060

6161
this.set('currentDate', new Date());
6262
},
63+
64+
actions: {
65+
contactLink(href, category, action, label) {
66+
const metrics = Ember.get(this, 'metrics');
67+
68+
// TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. For now, we'll use trackEvent.
69+
metrics.trackEvent({
70+
category,
71+
action,
72+
label
73+
});
74+
75+
if (label.includes('email'))
76+
return;
77+
78+
window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400');
79+
return false;
80+
}
81+
}
6382
});

app/controllers/submit.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import TaggableMixin from 'ember-osf/mixins/taggable-mixin';
1010

1111
import loadAll from 'ember-osf/utils/load-relationship';
1212

13+
import fixSpecialChar from 'ember-osf/utils/fix-special-char';
14+
1315
// Enum of available upload states > New project or existing project?
1416
export const State = Object.freeze(Ember.Object.create({
1517
START: 'start',
@@ -268,15 +270,19 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
268270
basicsTags: Ember.computed('node', function() {
269271
// Pending tags
270272
let node = this.get('node');
271-
return node ? node.get('tags') : Ember.A();
273+
let newTags = null;
274+
if (node != null) {
275+
newTags = node.get('tags').slice(0).map(fixSpecialChar);
276+
}
277+
return node ? newTags : Ember.A();
272278
}),
273279
tagsChanged: Ember.computed('basicsTags', 'node.tags', function() {
274280
// Does the list of pending tags differ from the saved tags in the db?
275281
let basicsTags = this.get('basicsTags');
276282
let nodeTags = this.get('node.tags');
277283
let changed = false;
278284
if (basicsTags && nodeTags) {
279-
changed = !(basicsTags.length === nodeTags.length && basicsTags.every((v, i)=> v === nodeTags[i]));
285+
changed = !(basicsTags.length === nodeTags.length && basicsTags.every((v, i)=> fixSpecialChar(v) === fixSpecialChar(nodeTags[i])));
280286
}
281287
return changed;
282288
}),
@@ -502,6 +508,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
502508
});
503509
let node = this.get('node');
504510
this.set('basicsAbstract', this.get('node.description') || null);
511+
505512
if (node.get('title') !== this.get('nodeTitle')) {
506513
let currentTitle = node.get('title');
507514
node.set('title', this.get('nodeTitle'));
@@ -615,8 +622,10 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
615622
let currentFile = this.get('store').peekRecord('file', this.get('model.primaryFile.id'));
616623
this.set('file', null);
617624
this.set('selectedFile', currentFile);
625+
618626
this.set('nodeTitle', this.get('node.title'));
619627
this.set('titleValid', true);
628+
620629
},
621630
clearDownstreamFields(section) {
622631
//If user goes back and changes a section inside Upload, all fields downstream of that section need to clear.
@@ -658,7 +667,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
658667
action: 'click',
659668
label: `Preprints - ${this.get('editMode') ? 'Edit' : 'Submit'} - Discard Basics Changes`
660669
});
661-
this.set('basicsTags', this.get('node.tags').slice(0));
670+
this.set('basicsTags', this.get('node.tags').slice(0).map(fixSpecialChar));
662671
this.set('basicsAbstract', this.get('node.description'));
663672
this.set('basicsDOI', this.get('model.doi'));
664673
let date = new Date();
@@ -779,6 +788,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
779788
});
780789
let tags = this.get('basicsTags').slice(0);
781790
Ember.A(tags);
791+
782792
tags.pushObject(tag);
783793
this.set('basicsTags', tags);
784794
return tags;
@@ -801,7 +811,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
801811

802812
/*
803813
Discipline section
804-
*/
814+
*/
805815
setSubjects(subjects) {
806816
// Sets subjectsList with pending subjects. Does not save.
807817
this.toggleProperty('disciplineModifiedToggle'); // Need to observe if discipline in nested array has changed. Toggling this will force 'disciplineChanged' to be recalculated

app/mixins/setup-submit-controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import permissions from 'ember-osf/const/permissions';
1313
*
1414
* @class SetupSubmitControllerMixin
1515
*/
16+
1617
export default Ember.Mixin.create({
1718
theme: Ember.inject.service(),
1819
panelActions: Ember.inject.service('panelActions'),

0 commit comments

Comments
 (0)