Skip to content

Commit

Permalink
Merge branch 'release/0.106.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Mar 3, 2017
2 parents b52bf4b + d310c80 commit d1433cb
Show file tree
Hide file tree
Showing 33 changed files with 634 additions and 252 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ install:
- ./node_modules/bower/bin/bower install --config.interactive=false

script:
- yarn test
- yarn test:cover

after_success:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

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

[![Coverage Status](https://coveralls.io/repos/github/CenterForOpenScience/ember-preprints/badge.svg?branch=develop)](https://coveralls.io/github/CenterForOpenScience/ember-preprints?branch=develop)

This is the codebase for OSF preprints.
This guide will help you get started if you're interested.

Expand Down
15 changes: 15 additions & 0 deletions app/components/preprint-form-authors.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Analytics from '../mixins/analytics';
export default CpPanelBodyComponent.extend(Analytics, {
valid: Ember.computed.alias('newContributorId'),
authorModification: false,
currentPage: 1,
// Permissions labels for dropdown
permissionOptions: permissionSelector,
parentContributorsAdded: false,
Expand Down Expand Up @@ -266,6 +267,20 @@ export default CpPanelBodyComponent.extend(Analytics, {
this.get('toast').error('Could not reorder contributors');
draggedContrib.rollbackAttributes();
});
},
// Action used by the pagination-pager component to the handle user-click event.
pageChanged(current) {
let query = this.get('query');
if (query) {
this.attrs.findContributors(query, current).then(() => {
this.set('addState', 'searchView');
this.set('currentPage', current);
})
.catch(() => {
this.get('toast').error('Could not perform search query.');
this.highlightSuccessOrFailure('author-search-box', this, 'error');
});
}
}
},
// TODO find alternative to jquery selectors. Temporary popover content for authors page.
Expand Down
12 changes: 12 additions & 0 deletions app/components/search-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ export default Ember.Component.extend(Analytics, {
return result.description.slice();
}),

justContributors: Ember.computed('result', function() {
return this.get('result.contributors').filter(item => !!item.users.bibliographic);
}),

shortContributorList: Ember.computed('justContributors', function() {
return this.get('justContributors').slice(0, Math.min(10, this.get('justContributors').length));
}),

hasMoreContributors: Ember.computed('justContributors', 'shortContributorList', function () {
return this.get('shortContributorList').length < this.get('justContributors').length;
}),

osfID: Ember.computed('result', function() {
let re = /osf.io\/(\w+)\/$/;
// NOTE / TODO : This will have to be removed later. Currently the only "true" preprints are solely from the OSF
Expand Down
6 changes: 6 additions & 0 deletions app/components/supplementary-file-browser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Ember from 'ember';
import loadAll from 'ember-osf/utils/load-relationship';
import Analytics from '../mixins/analytics';
import fileDownloadPath from '../utils/file-download-path';

/**
* @module ember-preprints
* @submodule components
Expand Down Expand Up @@ -57,6 +59,10 @@ export default Ember.Component.extend(Analytics, {
});
}.observes('preprint'),

fileDownloadURL: Ember.computed('selectedFile', function() {
return fileDownloadPath(this.get('selectedFile'), this.get('node'));
}),

init() {
this._super(...arguments);
this.__files();
Expand Down
35 changes: 19 additions & 16 deletions app/controllers/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import loadAll from 'ember-osf/utils/load-relationship';
import config from 'ember-get-config';
import Analytics from '../mixins/analytics';
import permissions from 'ember-osf/const/permissions';
import fileDownloadPath from '../utils/file-download-path';

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

_fileDownloadURL: Ember.observer('model.primaryFile', function() {
this.get('model.primaryFile').then(file => {
this.set('fileDownloadURL', fileDownloadPath(file, this.get('node')));
});
}),

useShortenedDescription: Ember.computed('node.description', function() {
return this.get('node.description') ? this.get('node.description').length > 350 : false;
}),
Expand Down Expand Up @@ -184,25 +192,20 @@ export default Ember.Controller.extend(Analytics, {
chooseFile(fileItem) {
this.set('activeFile', fileItem);
},
shareLink(href, network, action) {
shareLink(href, category, action, label) {
const metrics = Ember.get(this, 'metrics');

if (network.includes('email')) {
metrics.trackEvent({
category: 'link',
action,
label: `Preprints - Content - Email ${window.location.href}`
});
} else {
window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400');
// TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. For now, we'll use trackEvent.
metrics.trackEvent({
category: network,
action,
label: `Preprints - Content - ${window.location.href}`
});
}
// TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. For now, we'll use trackEvent.
metrics.trackEvent({
category,
action,
label
});

if (label.includes('email'))
return;

window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400');
return false;
}
},
Expand Down
20 changes: 19 additions & 1 deletion app/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default Ember.Controller.extend(Analytics, {
subjectFilter: null,
queryBody: {},
providersPassed: false,

pageNumbers: [],
sortByOptions: ['Relevance', 'Upload date (oldest to newest)', 'Upload date (newest to oldest)'],

treeSubjects: Ember.computed('activeFilters', function() {
Expand Down Expand Up @@ -237,9 +237,21 @@ export default Ember.Controller.extend(Analytics, {
return this.set('results', results);
});
},
totalPages: Ember.computed('numberOfResults', 'size', function() {
return Math.ceil(this.get('numberOfResults') / this.get('size'));
}),

maxPages: Ember.computed('numberOfResults', function() {
return ((this.get('numberOfResults') / this.get('size')) | 0) + (this.get('numberOfResults') % 10 === 0 ? 0 : 1);
}),

// TODO update this property if a solution is found for the elastic search limitation.
// Ticket: SHARE-595
numPages: Ember.computed('size', 'totalPages', function() {
let maxPages = Math.ceil(10000 / this.get('size'));
return this.get('totalPages') < maxPages ? this.get('totalPages') : maxPages;
}),

getQueryBody() {
const facetFilters = this.get('activeFilters');

Expand Down Expand Up @@ -355,6 +367,11 @@ export default Ember.Controller.extend(Analytics, {
}
},

setLoadPage(pageNumber) {
this.set('page', pageNumber);
this.loadPage();
},

clearFilters() {
this._clearFilters();

Expand Down Expand Up @@ -399,5 +416,6 @@ export default Ember.Controller.extend(Analytics, {
label: `Preprints - Discover - ${filterType} ${item}`
});
},

},
});
19 changes: 19 additions & 0 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,23 @@ export default Ember.Controller.extend(Analytics, {

this.set('currentDate', new Date());
},

actions: {
contactLink(href, category, action, label) {
const metrics = Ember.get(this, 'metrics');

// TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. For now, we'll use trackEvent.
metrics.trackEvent({
category,
action,
label
});

if (label.includes('email'))
return;

window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400');
return false;
}
}
});
18 changes: 14 additions & 4 deletions app/controllers/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import TaggableMixin from 'ember-osf/mixins/taggable-mixin';

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

import fixSpecialChar from 'ember-osf/utils/fix-special-char';

// Enum of available upload states > New project or existing project?
export const State = Object.freeze(Ember.Object.create({
START: 'start',
Expand Down Expand Up @@ -268,15 +270,19 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
basicsTags: Ember.computed('node', function() {
// Pending tags
let node = this.get('node');
return node ? node.get('tags') : Ember.A();
let newTags = null;
if (node != null) {
newTags = node.get('tags').slice(0).map(fixSpecialChar);
}
return node ? newTags : Ember.A();
}),
tagsChanged: Ember.computed('basicsTags', 'node.tags', function() {
// Does the list of pending tags differ from the saved tags in the db?
let basicsTags = this.get('basicsTags');
let nodeTags = this.get('node.tags');
let changed = false;
if (basicsTags && nodeTags) {
changed = !(basicsTags.length === nodeTags.length && basicsTags.every((v, i)=> v === nodeTags[i]));
changed = !(basicsTags.length === nodeTags.length && basicsTags.every((v, i)=> fixSpecialChar(v) === fixSpecialChar(nodeTags[i])));
}
return changed;
}),
Expand Down Expand Up @@ -502,6 +508,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
});
let node = this.get('node');
this.set('basicsAbstract', this.get('node.description') || null);

if (node.get('title') !== this.get('nodeTitle')) {
let currentTitle = node.get('title');
node.set('title', this.get('nodeTitle'));
Expand Down Expand Up @@ -615,8 +622,10 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
let currentFile = this.get('store').peekRecord('file', this.get('model.primaryFile.id'));
this.set('file', null);
this.set('selectedFile', currentFile);

this.set('nodeTitle', this.get('node.title'));
this.set('titleValid', true);

},
clearDownstreamFields(section) {
//If user goes back and changes a section inside Upload, all fields downstream of that section need to clear.
Expand Down Expand Up @@ -658,7 +667,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
action: 'click',
label: `Preprints - ${this.get('editMode') ? 'Edit' : 'Submit'} - Discard Basics Changes`
});
this.set('basicsTags', this.get('node.tags').slice(0));
this.set('basicsTags', this.get('node.tags').slice(0).map(fixSpecialChar));
this.set('basicsAbstract', this.get('node.description'));
this.set('basicsDOI', this.get('model.doi'));
let date = new Date();
Expand Down Expand Up @@ -779,6 +788,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
});
let tags = this.get('basicsTags').slice(0);
Ember.A(tags);

tags.pushObject(tag);
this.set('basicsTags', tags);
return tags;
Expand All @@ -801,7 +811,7 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions

/*
Discipline section
*/
*/
setSubjects(subjects) {
// Sets subjectsList with pending subjects. Does not save.
this.toggleProperty('disciplineModifiedToggle'); // Need to observe if discipline in nested array has changed. Toggling this will force 'disciplineChanged' to be recalculated
Expand Down
1 change: 1 addition & 0 deletions app/mixins/setup-submit-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import permissions from 'ember-osf/const/permissions';
*
* @class SetupSubmitControllerMixin
*/

export default Ember.Mixin.create({
theme: Ember.inject.service(),
panelActions: Ember.inject.service('panelActions'),
Expand Down
Loading

0 comments on commit d1433cb

Please sign in to comment.