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

Make journal selection optional #1227

Merged
merged 7 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 0 additions & 3 deletions app/components/workflow-basics/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@
<div>
<label>
Journal
<span class="text-muted">
(required)
</span>
</label>
{{#if this.contactUrl}}
<a class="btn btn-link pull-right pr-0" href="{{this.contactUrl}}">
Expand Down
12 changes: 9 additions & 3 deletions app/components/workflow-basics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ export default class WorkflowBasics extends Component {

/**
* Publication should be set/overwritten if there is no current publication, if the current
* publication has no DOI or Title, or it the current publication has no journal with a
* journalName
* publication has no DOI or Title, or it the current publication has no journal or no journal
* with a journalName
*/
shouldSetPublication() {
const publication = this.publication;
return !publication || !publication.doi || !publication.title || !get(publication, 'journal.journalName');
return (
!publication ||
!publication.doi ||
!publication.title ||
!publication.journal ||
!get(publication, 'journal.journalName')
);
}

constructor() {
Expand Down
23 changes: 16 additions & 7 deletions app/components/workflow-metadata/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
<h4 class="font-weight-light pull-right form-step-header">
{{concat "Form" " " this.displayFormStep " " "of" " " this.schemas.length}}
</h4>
{{#if this.currentSchema}}
<MetadataForm
@schema={{this.currentSchema}}
@nextForm={{this.nextForm}}
@previousForm={{this.previousForm}}
@cancel={{this.cancel}}
/>

{{#if this.missingRequiredJournal}}
<h2>Missing required journal</h2>
<p>
A repository requires information about the journal associated with the submission.
Please <LinkTo @route="submissions.new.basics">go back and enter a journal</LinkTo>.
</p>
{{else}}
{{#if this.currentSchema}}
<MetadataForm
@schema={{this.currentSchema}}
@nextForm={{this.nextForm}}
@previousForm={{this.previousForm}}
@cancel={{this.cancel}}
/>
{{/if}}
{{/if}}
</div>
{{yield}}
5 changes: 5 additions & 0 deletions app/components/workflow-metadata/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class WorkflowMetadata extends Component {
@tracked readOnlyProperties = [];
@tracked schemas = undefined;
@tracked metadata = {};
@tracked missingRequiredJournal = false;
@tracked currentFormStep = 0; // Current step #

/**
Expand Down Expand Up @@ -83,9 +84,13 @@ export default class WorkflowMetadata extends Component {
try {
const schemas = yield this.metadataSchema.getMetadataSchemas(repos);

const requiresJournal =
schemas.findIndex((schema) => 'required' in schema && schema.required.includes('journal-title')) != -1;
const doiInfo = this.doiInfo;
const journal = yield get(this, 'args.publication.journal');

set(this, 'missingRequiredJournal', requiresJournal && !journal);
jaredgalanis marked this conversation as resolved.
Show resolved Hide resolved

// Add relevant fields from DOI data to submission metadata
const metadataFromDoi = this.doi.doiToMetadata(doiInfo, journal, this.metadataSchema.getFields(schemas));

Expand Down
6 changes: 1 addition & 5 deletions app/controllers/submissions/new/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,8 @@ export default class SubmissionsNewBasics extends Controller {
set(this, 'titleError', true);
this.flashMessages.warning('The title must not be left blank');
}
if (this.journalIsInvalid) {
set(this, 'journalError', true);
this.flashMessages.warning('The journal must not be left blank');
}

if (this.titleIsInvalid || this.journalIsInvalid) return; // end here
if (this.titleIsInvalid) return; // end here

// non proxy submission will always have current user as submitter, so only need to validate this for proxy submission
if (get(this, 'submission.isProxySubmission')) {
Expand Down
47 changes: 25 additions & 22 deletions app/services/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,32 @@ export default class DoiService extends Service {

// Add issns key in expected format by parsing journal issns.
doiCopy.issns = [];
if (isArray(journal.get('issns'))) {
journal.get('issns').forEach((s) => {
let i = s.indexOf(':');
let value = {};

if (i == -1) {
value.issn = s;
} else {
let prefix = s.substring(0, i);

if (prefix === 'Print') {
value.pubType = 'Print';
} else if (prefix === 'Online') {
value.pubType = 'Online';
}

value.issn = s.substring(i + 1);
}
if (journal) {
if (isArray(journal.get('issns'))) {
journal.get('issns').forEach((s) => {
let i = s.indexOf(':');
let value = {};

if (value.issn.length > 0) {
doiCopy.issns.push(value);
}
});
if (i == -1) {
value.issn = s;
} else {
let prefix = s.substring(0, i);

if (prefix === 'Print') {
value.pubType = 'Print';
} else if (prefix === 'Online') {
value.pubType = 'Online';
}

value.issn = s.substring(i + 1);
}

if (value.issn.length > 0) {
doiCopy.issns.push(value);
}
});
}
}

// Massage 'authors' information
Expand All @@ -138,7 +141,7 @@ export default class DoiService extends Service {
// Misc manual translation
if (doiCopy.nlmta) {
doiCopy['journal-NLMTA-ID'] = doiCopy.nlmta;
} else if (journal.get('nlmta')) {
} else if (journal && journal.get('nlmta')) {
doiCopy['journal-NLMTA-ID'] = journal.get('nlmta');
}
if (doiCopy['container-title-short']) {
Expand Down