From 4ba7e05c65e9a09179b76bf094577bbf7e48d4d6 Mon Sep 17 00:00:00 2001 From: frozenhelium Date: Tue, 4 Jul 2023 08:28:41 +0545 Subject: [PATCH 1/3] Move Journal Details section above Contacts section --- .../documents/single-view/document-body.js | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/app/assets/scripts/components/documents/single-view/document-body.js b/app/assets/scripts/components/documents/single-view/document-body.js index 8bdcb0eb..b0019ad1 100644 --- a/app/assets/scripts/components/documents/single-view/document-body.js +++ b/app/assets/scripts/components/documents/single-view/document-body.js @@ -905,42 +905,6 @@ const htmlAtbdContentSections = [ } ] }, - { - label: 'Contacts', - id: 'contacts', - render: ({ element, children, atbd, printMode }) => ( - - {React.Children.count(children) ? ( - children - ) : ( -

There are no contacts associated with this document

- )} -
- ), - children: ({ atbd }) => { - const contactsLink = atbd?.contacts_link || []; - return contactsLink.map(({ contact, roles, affiliations }, idx) => ({ - label: getContactName(contact), - id: `contacts_${idx + 1}`, - render: ({ element }) => ( - - ) - })); - } - }, { label: 'Journal Details', id: 'journal_details', @@ -1041,6 +1005,42 @@ const htmlAtbdContentSections = [ } ] }, + { + label: 'Contacts', + id: 'contacts', + render: ({ element, children, atbd, printMode }) => ( + + {React.Children.count(children) ? ( + children + ) : ( +

There are no contacts associated with this document

+ )} +
+ ), + children: ({ atbd }) => { + const contactsLink = atbd?.contacts_link || []; + return contactsLink.map(({ contact, roles, affiliations }, idx) => ({ + label: getContactName(contact), + id: `contacts_${idx + 1}`, + render: ({ element }) => ( + + ) + })); + } + }, { label: 'References', id: 'references', From 08b58e4e4c95300790a848e15fc4134823317a8d Mon Sep 17 00:00:00 2001 From: frozenhelium Date: Thu, 6 Jul 2023 13:47:07 +0545 Subject: [PATCH 2/3] Fix empty message in significance discussion section for pdf --- .../components/documents/single-view/document-body.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/scripts/components/documents/single-view/document-body.js b/app/assets/scripts/components/documents/single-view/document-body.js index b0019ad1..2576c714 100644 --- a/app/assets/scripts/components/documents/single-view/document-body.js +++ b/app/assets/scripts/components/documents/single-view/document-body.js @@ -174,7 +174,7 @@ const FragmentWithOptionalEditor = ({ atbd }} value={value} - whenEmpty={} + whenEmpty={} /> )} {children} @@ -299,7 +299,9 @@ const ContactItem = ({ id, label, contact, roles, affiliations }) => ( ); -const EmptySection = () =>

No content available.

; +const EmptySection = ({ className }) => ( +

No content available.

+); /** * Renders each element of the given array (by calling their `render` function) @@ -943,7 +945,7 @@ const htmlAtbdContentSections = [ } + whenEmpty={} /> ) From c6ad83d88e69fabe04fa9d1fa0c125ba87140310 Mon Sep 17 00:00:00 2001 From: frozenhelium Date: Thu, 20 Jul 2023 14:36:17 +0545 Subject: [PATCH 3/3] Add stricter check to check if significance discussion is empty --- .../documents/single-view/document-body.js | 56 +++++++++++++------ 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/app/assets/scripts/components/documents/single-view/document-body.js b/app/assets/scripts/components/documents/single-view/document-body.js index 2576c714..59357e4e 100644 --- a/app/assets/scripts/components/documents/single-view/document-body.js +++ b/app/assets/scripts/components/documents/single-view/document-body.js @@ -911,23 +911,45 @@ const htmlAtbdContentSections = [ label: 'Journal Details', id: 'journal_details', shouldRender: ({ atbd }) => isJournalPublicationIntended(atbd), - render: ({ element, children, atbd, printMode }) => ( - -

- - If provided, the journal details are included only in the Journal - PDF. - -

- {children} -
- ), + render: ({ element, children, atbd, printMode, document }) => { + function isJournalDiscussionEmpty() { + if ( + !document.journal_discussion || + !document.journal_discussion.children + ) { + return true; + } + + return document.journal_discussion.children.every((node) => { + if (node.type === 'p' && node.children?.every(({ text }) => !text)) { + return true; + } + + return false; + }); + } + + return ( + +

+ + If provided, the journal details are included only in the Journal + PDF. + +

+ {children} +
+ ); + }, children: [ { label: 'Key Points',