Skip to content

Commit

Permalink
Merge branch 'develop' into fix/numbering
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/assets/scripts/components/documents/single-view/document-body.js
  • Loading branch information
vgeorge committed Oct 13, 2023
2 parents 71cf6af + d5c62f8 commit 1af63c3
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,38 +427,58 @@ function JournalPdfPreview() {
const hasAffiliation =
contactAffiliations && contactAffiliations.length > 0;

let contactEmail = contact.mechanisms.find(
(mechanism) => mechanism.mechanism_type === 'Email'
)?.mechanism_value;

const item = (
<span key={contact.id}>
<strong>
{getContactName(contact, { full: true })}
{contactEmail && ` (${contactEmail})`}
{hasAffiliation &&
contactAffiliations.map((affiliation, j) => {
return (
<>
<sup>
{Array.from(affiliations).indexOf(affiliation) + 1}
</sup>
<sup>
{j < contactAffiliations.length - 1 && <span>, </span>}
</sup>
</>
);
})}
{i < contacts_link.length - 1 && <span>, </span>}
{i === contacts_link.length - 2 && <span>and </span>}
</strong>
{hasAffiliation &&
contactAffiliations.map((affiliation, j) => {
return (
<>
<sup>
{Array.from(affiliations).indexOf(affiliation) + 1}
</sup>
<sup>
{j < contactAffiliations.length - 1 && <span>, </span>}
</sup>
</>
);
})}
{i < contacts_link.length - 1 && <span>, </span>}
{i === contacts_link.length - 2 && <span>and </span>}
</span>
);
contacts.push(item);
}
);

// create corresponding authors list component
const correspondingAuthors =
contacts_link
?.filter((c) =>
c.roles?.find((r) => r.toLowerCase() === 'corresponding author')
)
.map(({ contact }) => {
let contactEmail = contact.mechanisms.find(
(mechanism) => mechanism.mechanism_type === 'Email'
)?.mechanism_value;

let contactName = getContactName(contact, { full: true });

return `${contactName} ${contactEmail ? `(${contactEmail})` : ''}`;
}) || [];

const correspondingAuthorsString = correspondingAuthors.map((author, i) => (
<>
{author}
{i < correspondingAuthors.length - 1 && <span>, </span>}
{i === correspondingAuthors.length - 2 && <span>and </span>}
</>
));
return {
items: contacts,
correspondingAuthors: correspondingAuthorsString,
affiliations_list: Array.from(affiliations),
maxIndex: (contacts_link?.length ?? 0) - 1
};
Expand Down Expand Up @@ -581,6 +601,14 @@ function JournalPdfPreview() {
</div>
))}
</div>
<div>
{contacts?.correspondingAuthors?.length > 0 && (
<div>
<strong>Corresponding Author(s): </strong>
{contacts?.correspondingAuthors}
</div>
)}
</div>
</AuthorsSection>
<Section id='key_points' title='Key Points:' skipNumbering>
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const roleTypes = [
'Supervision',
'Investigation',
'Funding acquisition',
'Corresponding Author'
'Corresponding Author',
'Document Reviewer'
];

const emptyAffiliation = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import React, { useCallback, useEffect } from 'react';
import T from 'prop-types';
import set from 'lodash.set';
import get from 'lodash.get';
import { FieldArray, Formik, Form as FormikForm } from 'formik';
import { Formik, Form as FormikForm } from 'formik';
import { Form } from '@devseed-ui/form';
import { GlobalLoading } from '@devseed-ui/global-loading';
import { glsp } from '@devseed-ui/theme-provider';
import styled from 'styled-components';

import { Inpage, InpageBody } from '../../../../styles/inpage';
import {
FormBlock,
FormBlockHeading,
FormSectionNotes
} from '../../../../styles/form-block';
import {
FormikSectionFieldset,
SectionFieldset
} from '../../../common/forms/section-fieldset';
import { FormikSectionFieldset } from '../../../common/forms/section-fieldset';
import ContactsList from './contacts-list';
import { Link } from '../../../../styles/clean/link';

Expand All @@ -29,17 +23,6 @@ import { getDocumentSectionLabel } from '../sections';
import { documentEdit } from '../../../../utils/url-creator';
import { LocalStore } from '../local-store';
import { FormikUnloadPrompt } from '../../../common/unload-prompt';
import { FormikInputText } from '../../../common/forms/input-text';
import { DeletableFieldset } from '../../../common/forms/deletable-fieldset';
import { FieldMultiItem } from '../../../common/forms/field-multi-item';

const emptyAffiliation = '';

const BasicInfoSection = styled.div`
display: grid;
grid-gap: ${glsp()};
grid-template-columns: 1fr 1fr;
`;

export default function StepContacts(props) {
const { renderInpageHeader, renderFormFooter, atbd, id, version, step } =
Expand Down Expand Up @@ -148,58 +131,6 @@ export default function StepContacts(props) {
</FormSectionNotes>
<ContactsList contactsList={contacts.data} />
</FormikSectionFieldset>
<SectionFieldset
label={getDocumentSectionLabel('reviewer_info')}
>
<BasicInfoSection>
<FormikInputText
id='reviewer_info.first_name'
name='reviewer_info.first_name'
label='First name'
/>
<FormikInputText
id='reviewer_info.last_name'
name='reviewer_info.last_name'
label='Last name'
/>
<FormikInputText
id='reviewer_info.email'
name='reviewer_info.email'
label='Email'
/>
</BasicInfoSection>
<FieldArray
name='reviewer_info.affiliations'
render={({ remove, push, form, name: affFieldName }) => {
const fieldValues = get(form.values, affFieldName) || [];
return (
<FieldMultiItem
id={affFieldName}
label='Affiliations relevant to this document'
emptyMessage='There are no affiliations. You can start by adding one.'
onAddClick={() => push(emptyAffiliation)}
>
{fieldValues.map((field, index) => (
<DeletableFieldset
/* eslint-disable-next-line react/no-array-index-key */
key={index}
id={`${affFieldName}-${index}`}
label={`Entry #${index + 1}`}
onDeleteClick={() => remove(index)}
>
<FormikInputText
id={`${affFieldName}-${index}`}
name={`${affFieldName}.${index}`}
label='Name'
labelHint='(required)'
/>
</DeletableFieldset>
))}
</FieldMultiItem>
);
}}
/>
</SectionFieldset>
{renderFormFooter()}
</Form>
</FormBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const STEP_CONTACTS = {
// affiliations: []
// }
],
reviewer_info: atbd?.reviewer_info,
sections_completed: {
contacts: 'incomplete'
}
Expand Down
Loading

0 comments on commit 1af63c3

Please sign in to comment.