Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-4460] Toggle assertions based on preprint-provider flag #756

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions app/controllers/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
/**
* @class Submit Controller
*/
export default Controller.extend(Analytics, BasicsValidations, COIValidations, NodeActionsMixin, TaggableMixin, {

Check warning on line 162 in app/controllers/submit.js

View workflow job for this annotation

GitHub Actions / test-with-coverage

Line 162 exceeds the maximum line length of 100
features: service(),
i18n: service(),
store: service(),
Expand Down Expand Up @@ -260,6 +260,7 @@
doiValid: alias('validations.attrs.basicsDOI.isValid'),
originalPublicationDateValid: alias('validations.attrs.basicsOriginalPublicationDate.isValid'),

assertionsEnabled: alias('selectedProvider.assertionsEnabled'),
coiStatementValid: alias('validations.attrs.coiStatement.isValid'),

// Basics fields that are being validated are abstract, license and doi
Expand Down Expand Up @@ -299,28 +300,36 @@
}),

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

Check warning on line 303 in app/controllers/submit.js

View workflow job for this annotation

GitHub Actions / test-with-coverage

The "uploadChanged" single-line function should be above the "savedAuthorAssertions" multi-line function on line 298

basicsDOI: computed.or('model.doi'),

Check warning on line 305 in app/controllers/submit.js

View workflow job for this annotation

GitHub Actions / test-with-coverage

The "basicsDOI" single-line function should be above the "savedAuthorAssertions" multi-line function on line 298

// This is done to initialize basicsOriginalPublicationDate to the date fetched
// from an existing preprint, similar to how basicsDOI is initialized.
basicsOriginalPublicationDate: computed.or('model.originalPublicationDate'),

Check warning on line 309 in app/controllers/submit.js

View workflow job for this annotation

GitHub Actions / test-with-coverage

The "basicsOriginalPublicationDate" single-line function should be above the "savedAuthorAssertions" multi-line function on line 298

// Are there any unsaved changes in the basics section?
basicsChanged: computed.or('tagsChanged', 'abstractChanged', 'doiChanged', 'licenseChanged', 'originalPublicationDateChanged'),

Check warning on line 312 in app/controllers/submit.js

View workflow job for this annotation

GitHub Actions / test-with-coverage

The "basicsChanged" single-line function should be above the "savedAuthorAssertions" multi-line function on line 298

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

Check warning on line 315 in app/controllers/submit.js

View workflow job for this annotation

GitHub Actions / test-with-coverage

The "coiChanged" single-line function should be above the "savedAuthorAssertions" multi-line function on line 298

moderationType: alias('currentProvider.reviewsWorkflow'),

Check warning on line 317 in app/controllers/submit.js

View workflow job for this annotation

GitHub Actions / test-with-coverage

The "moderationType" single-line function should be above the "savedAuthorAssertions" multi-line function on line 298

_names: ['Server', 'File', 'Assertions', 'Basics', 'Discipline', 'Authors', 'COI', 'Supplemental'],
_names: computed('assertionsEnabled', function () {
if (this.get('assertionsEnabled')) {
return ['Server', 'File', 'Assertions', 'Basics', 'Discipline', 'Authors', 'COI', 'Supplemental'];
}
return ['Server', 'File', 'Basics', 'Discipline', 'Authors', 'Supplemental'];
}),

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

supplementalChanged: computed('supplementalProjectTitle', 'pendingSupplementalProjectTitle', 'selectedSupplementalProject', 'node', function() {
Expand Down Expand Up @@ -1418,14 +1427,16 @@
label: `${this.get('editMode') ? 'Edit' : 'Submit'} - Save and Continue Author Assertions Section`,
});
const model = this.get('model');
model.set('hasDataLinks', this.get('hasDataLinks'));
model.set('dataLinks', this.get('dataLinks'));
model.set('whyNoData', this.get('whyNoData'));

model.set('hasPreregLinks', this.get('hasPreregLinks'));
model.set('preregLinks', this.get('preregLinks'));
model.set('preregLinkInfo', this.get('preregLinkInfo'));
model.set('whyNoPrereg', this.get('whyNoPrereg'));
if (this.get('assertionsEnabled')) {
model.set('hasDataLinks', this.get('hasDataLinks'));
model.set('dataLinks', this.get('dataLinks'));
model.set('whyNoData', this.get('whyNoData'));

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));
Expand Down
Loading
Loading