Skip to content

Commit

Permalink
Merge branch 'release/0.132.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabmiz committed Jun 4, 2020
2 parents d0dfdbb + e1938ea commit 70f922e
Show file tree
Hide file tree
Showing 13 changed files with 499 additions and 70 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.132.0] - 2020-06-03
### Added
- support for `public data links` and `preregistration links` (Sloan Phase II)

## [0.131.3] - 2020-05-06
### Changed
- Update assets
Expand Down
20 changes: 17 additions & 3 deletions app/components/multiple-textbox-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { computed } from '@ember/object';
import Analytics from 'ember-osf/mixins/analytics';

export default Component.extend(Analytics, {
legend: 'Text Fields',
textFields: null, // passed in array of text fields on invocation, default to null
model: null,
textFields: null,
textFieldsLastIndex: computed('textFields.[]', function() {
return this.get('textFields').length - 1;
}),

didReceiveAttrs() {
if (!this.textFields) {
const valuesFromModel = this.model;
if (valuesFromModel && valuesFromModel.length > 0) {
this.set('textFields', valuesFromModel.map((value) => {
return { value };
}));
} else {
this.set('textFields', [{ value: '' }]);
}
},
Expand All @@ -28,6 +33,15 @@ export default Component.extend(Analytics, {
const fields = this.get('textFields');
fields.removeAt(index);
this.set('textFields', fields);
this.send('onChange');
},
onChange() {
this.set('model', this.get('textFields').filter((item) => {
if (!item.value) {
return false;
}
return true;
}).map(x => x.value));
},
},
});
186 changes: 179 additions & 7 deletions app/controllers/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ const ACTION = {
},
};

const PREREG_LINK_INFO_CHOICES = [
'prereg_designs',
'prereg_analysis',
'prereg_both',
];

function subjectIdMap(subjectArray) {
// Maps array of arrays of disciplines into array of arrays of discipline ids.
return subjectArray.map(subjectBlock => subjectBlock.map(subject => subject.id));
Expand All @@ -161,7 +167,6 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N

// Data for project picker; tracked internally on load
user: null,

_State: State,
// Project that preprint file was copied from, or supplemental project (in edit mode)
// Same variable used for both.
Expand Down Expand Up @@ -202,6 +207,8 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
authorsSaveState: false,
// True temporarily when changes have been saved in coi section
coiSaveState: false,
// True temporarily when changes have been saved in author assertions section
assertionsSaveState: false,
// True temporarily when changes have been saved in the supplemental section
supplementalSaveState: false,
// Preprint node's osfStorage object
Expand All @@ -228,6 +235,8 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
preprintSaved: false,
submitAction: null,

preregLinkInfoChoices: PREREG_LINK_INFO_CHOICES,

// Validation rules and changed states for form sections

providerChanged: true,
Expand Down Expand Up @@ -288,6 +297,16 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
// Does preprint have saved coi?
savedCoi: computed.notEmpty('model.hasCoi'),

// Does preprint have saved hasDataLinks and hasPreregLinks?
savedAuthorAssertions: computed('model.{hasDataLinks,hasPreregLinks}', 'sloanDataInputEnabled', 'sloanPreregInputEnabled', function() {
if (this.get('sloanDataInputEnabled') && !this.get('sloanPreregInputEnabled')) {
return this.get('model.hasDataLinks');
}
if (this.get('sloanDataInputEnabled') && this.get('sloanPreregInputEnabled')) {
return this.get('model.hasDataLinks') && this.get('model.hasPreregLinks');
}
}),

// Are there any unsaved changes in the upload section?
uploadChanged: computed.or('preprintFileChanged', 'titleChanged'),

Expand All @@ -301,7 +320,7 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
basicsChanged: computed.or('tagsChanged', 'abstractChanged', 'doiChanged', 'licenseChanged', 'originalPublicationDateChanged'),

// Are there any unsaved changes in the coi section?
coiChanged: computed.or('coiStatementChanged', 'coiOptionChanged'),
coiChanged: computed.or('coiStatementChanged', 'hasCoiChanged'),

moderationType: alias('currentProvider.reviewsWorkflow'),

Expand All @@ -324,11 +343,14 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
}),

// Preprint can be published once all required sections have been saved.
allSectionsValid: computed('savedTitle', 'savedFile', 'savedAbstract', 'savedSubjects', 'authorsValid', 'savedCoi', function() {
allSectionsValid: computed('savedTitle', 'savedFile', 'savedAbstract', 'savedSubjects', 'authorsValid', 'savedCoi', 'savedAuthorAssertions', function() {
const allSectionsValid = this.get('savedTitle') && this.get('savedFile') && this.get('savedAbstract') && this.get('savedSubjects') && this.get('authorsValid');
if (this.get('shouldShowCoiPanel')) {
if (this.get('shouldShowCoiPanel') && !this.get('shouldShowAuthorAssertionsPanel')) {
return allSectionsValid && this.get('savedCoi');
}
if (this.get('shouldShowCoiPanel') && this.get('shouldShowAuthorAssertionsPanel')) {
return allSectionsValid && this.get('savedCoi') && this.get('savedAuthorAssertions');
}
return allSectionsValid;
}),

Expand Down Expand Up @@ -579,7 +601,7 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
hasCoi: computed('model.hasCoi', function() {
return this.get('model.hasCoi');
}),
coiOptionChanged: computed('hasCoi', 'model.hasCoi', function() {
hasCoiChanged: computed('hasCoi', 'model.hasCoi', function() {
const hasCoi = this.get('hasCoi');
return hasCoi !== undefined && hasCoi !== this.get('model.hasCoi');
}),
Expand All @@ -597,6 +619,103 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N

return false;
}),
hasDataLinks: computed('model.hasDataLinks', function() {
return this.get('model.hasDataLinks');
}),
hasDataLinksChanged: computed('hasDataLinks', 'model.hasDataLinks', function() {
const hasDataLinks = this.get('hasDataLinks');
return hasDataLinks !== this.get('model.hasDataLinks');
}),
dataLinks: computed('model.dataLinks', function() {
return this.get('model.dataLinks');
}),
dataLinksChanged: computed('dataLinks', 'model.dataLinks', function() {
const dataLinks = this.get('dataLinks');
return dataLinks !== this.get('model.dataLinks');
}),
whyNoData: computed('model.whyNoData', function() {
return this.get('model.whyNoData');
}),
whyNoDataChanged: computed('whyNoData', 'model.whyNoData', function() {
const whyNoData = this.get('whyNoData');
return whyNoData !== this.get('model.whyNoData');
}),
hasPreregLinks: computed('model.hasPreregLinks', function() {
return this.get('model.hasPreregLinks');
}),
hasPreregLinksChanged: computed('hasPreregLinks', 'model.hasPreregLinks', function() {
const hasPreregLinks = this.get('hasPreregLinks');
return hasPreregLinks !== this.get('model.hasPreregLinks');
}),
preregLinks: computed('model.preregLinks', function() {
return this.get('model.preregLinks');
}),
preregLinksChanged: computed('preregLinks', 'model.preregLinks', function() {
const preregLinks = this.get('preregLinks');
return preregLinks !== this.get('model.preregLinks');
}),
preregLinkInfo: computed('model.preregLinkInfo', function() {
return this.get('model.preregLinkInfo');
}),
preregLinkInfoChanged: computed('preregLinkInfo', 'model.preregLinkInfo', function() {
const preregLinkInfo = this.get('preregLinkInfo');
return preregLinkInfo !== this.get('model.preregLinkInfo');
}),
whyNoPrereg: computed('model.whyNoPrereg', function() {
return this.get('model.whyNoPrereg');
}),
whyNoPreregChanged: computed('whyNoPrereg', 'model.whyNoPrereg', function() {
const whyNoPrereg = this.get('whyNoPrereg');
return whyNoPrereg !== this.get('model.whyNoPrereg');
}),
authorAssertionsChanged: computed('hasDataLinksChanged', 'dataLinksChanged', 'whyNoPreregChanged', 'hasPreregLinksChanged', 'preregLinksChanged', 'preregLinkInfoChanged', 'whyNoPreregChanged', function() {
return this.get('hasDataLinksChanged') || this.get('dataLinksChanged') || this.get('whyNoDataChanged')
|| this.get('hasPreregLinksChanged') || this.get('preregLinksChanged') || this.get('preregLinkInfoChanged') || this.get('whyNoPreregChanged');
}),
dataLinksValid: computed('dataLinks', function() {
const dataLinks = this.get('dataLinks');
if (dataLinks && dataLinks.length > 0) {
return true;
}
return false;
}),
publicDataSectionValid: computed('hasDataLinks', 'dataLinksValid', function() {
const hasDataLinks = this.get('hasDataLinks');
if (hasDataLinks === 'no' || hasDataLinks === 'not_applicable') {
return true;
} else if (hasDataLinks === 'available') {
return this.get('dataLinksValid');
}
return false;
}),
preregLinksValid: computed('preregLinks', function() {
const preregLinks = this.get('preregLinks');
if (preregLinks && preregLinks.length > 0) {
return true;
}
return false;
}),
preregLinkInfoValid: computed('preregLinkInfo', function() {
const preregLinkInfo = this.get('preregLinkInfo');
return this.preregLinkInfoChoices.includes(preregLinkInfo);
}),
preregSectionValid: computed('hasPreregLinks', 'preregLinksValid', 'preregLinkInfoValid', function() {
const hasPreregLinks = this.get('hasPreregLinks');
if (hasPreregLinks === 'no' || hasPreregLinks === 'not_applicable') {
return true;
} else if (hasPreregLinks === 'available') {
return this.get('preregLinksValid') && this.get('preregLinkInfoValid');
}
return false;
}),
authorAssertionsValid: computed('publicDataSectionValid', 'preregSectionValid', 'sloanDataInputEnabled', 'sloanPreregInputEnabled', function() {
if (this.get('sloanDataInputEnabled') && !this.get('sloanPreregInputEnabled')) {
return this.get('publicDataSectionValid');
}
if (this.get('sloanDataInputEnabled') && this.get('sloanPreregInputEnabled')) {
return this.get('publicDataSectionValid') && this.get('preregSectionValid');
}
}),

actions: {
getProjectContributors(node) {
Expand Down Expand Up @@ -1027,7 +1146,7 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
/*
Update Author Assertion Sections
*/
updateCoi(val) {
updateHasCoi(val) {
this.set('hasCoi', val);
},
discardCoi() {
Expand Down Expand Up @@ -1068,6 +1187,18 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
.then(this._moveFromCoi.bind(this))
.catch(this._failMoveFromCoi.bind(this));
},
updateHasDataLinks(value) {
this.set('hasDataLinks', value);
this.set('dataLinks', []);
},
updateHasPreregLinks(value) {
this.set('hasPreregLinks', value);
this.set('preregLinks', []);
this.set('preregLinkInfo', '');
},
updatePreregLinkInfo(value) {
this.set('preregLinkInfo', value);
},
/*
Supplemental Project Section
*/
Expand Down Expand Up @@ -1315,6 +1446,37 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
this.set('selectedProvider', this.get('currentProvider'));
this.set('providerChanged', false);
},
saveAuthorAssertions() {
this.get('metrics')
.trackEvent({
category: 'button',
action: 'click',
label: `${this.get('editMode') ? 'Edit' : 'Submit'} - Save and Continue Author Assertions Section`,
});
const model = this.get('model');
if (this.get('sloanDataInputEnabled')) {
model.set('hasDataLinks', this.get('hasDataLinks'));
model.set('dataLinks', this.get('dataLinks'));
model.set('whyNoData', this.get('whyNoData'));
}
if (this.get('sloanPreregInputEnabled')) {
model.set('hasPreregLinks', this.get('hasPreregLinks'));
model.set('preregLinks', this.get('preregLinks'));
model.set('preregLinkInfo', this.get('preregLinkInfo'));
model.set('whyNoPrereg', this.get('whyNoPrereg'));
}
model.save().then(this._moveFromAuthorAssertions.bind(this))
.catch(error => this._failMoveFromAuthorAssertions.bind(this)(error));
},
discardAuthorAssertions() {
this.set('hasDataLinks', this.get('model.hasDataLinks'));
this.set('dataLinks', this.get('model.dataLinks'));
this.set('whyNoData', this.get('model.whyNoData'));
this.set('hasPreregLinks', this.get('model.hasPreregLinks'));
this.set('preregLinks', this.get('model.preregLinks'));
this.set('preregLinkInfo', this.get('model.preregLinkInfo'));
this.set('whyNoPrereg', this.get('model.whyNoPrereg'));
},
},

_setCurrentProvider() {
Expand Down Expand Up @@ -1458,7 +1620,16 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
_moveFromBasics() {
this.send('next', 'Basics');
},

_moveFromAuthorAssertions() {
this.send('next', 'Assertions');
},
_failMoveFromAuthorAssertions(error) {
if (error.errors[0].detail) {
this.get('toast').error(error.errors[0].detail);
} else {
this.get('toast').error(this.get('i18n').t('submit.author_assertions_error'));
}
},
_moveFromCoi() {
this.send('next', 'COI');
},
Expand Down Expand Up @@ -1666,6 +1837,7 @@ export default Controller.extend(Analytics, BasicsValidations, COIValidations, N
basicsSaveState: false,
authorsSaveState: false,
coiSaveState: false,
assertionsSaveState: false,
supplementalSaveState: false,
osfStorageProvider: null,
osfProviderLoaded: false,
Expand Down
14 changes: 13 additions & 1 deletion app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export default {
basics_error: 'Error saving basics fields.',
disciplines_error: 'Error saving discipline(s).',
coi_error: 'Error saving COI field(s).',
author_assertions_error: 'Error saving Author Assertions field(s).',
search_contributors_error: 'Could not perform search query.',
server_locked: 'You cannot change the paper service after a file has been uploaded',
please_select_server: 'Please select a paper service before continuing',
Expand Down Expand Up @@ -430,6 +431,7 @@ export default {
Discipline: 'Discipline',
Basics: 'Basics',
Authors: 'Authors',
Assertions: 'Author Assertions',
COI: 'Conflict of Interest',
Submit: 'Submit',
Update: 'Update',
Expand Down Expand Up @@ -486,26 +488,36 @@ export default {
},
},
'author-assertions': {
header_label: 'Author Assertions',
describe: 'Describe',
available: {
yes: 'Yes',
no: 'No',
available: 'Available',
not_applicable: 'Not applicable',
},
header_label: 'Author Assertions',
conflict_of_interest: {
title: 'Conflict of Interest',
no: 'Author asserted no Conflict of Interest',
},
public_data: {
linksToData: 'Links to data',
title: 'Public Data',
no: 'No additional information provided by author.',
'not-applicable': 'Author asserted there is no data associated with this {{documentType.singular}}.',
description: 'Data refers to raw and/or processed information (quantitative or qualitative) used for the analyses, case studies, and/or descriptive interpretation in the {{documentType.singular}}. Public data could include data posted to open-access repositories, public archival library collection, or government archive. For data that is available under limited circumstances (e.g., after signing a data sharing agreement), choose the ‘No’ option and use the comment box to explain how others could access the data.',
},
prereg: {
links: 'Links',
title: 'Preregistration',
type: 'Type',
chooseOne: 'Choose one',
no: 'No additional information provided by author.',
prereg_designs: 'Study Design',
prereg_analysis: 'Analysis Plan',
prereg_both: 'Both',
'not-applicable': 'Author asserted that preregistration was not applicable because no data collection, extraction, or analysis is reported in this {{documentType.singular}}.',
description: 'A preregistration is a description of the research design and/or analysis plan that is created and registered before researchers collected data or before they have seen/interacted with preexisting data. The description should appear in a public registry (e.g., clinicaltrials.gov, OSF, AEA registry).',
},
},
'search-preprints': {
Expand Down
Loading

0 comments on commit 70f922e

Please sign in to comment.