From 38224c1240dc78ddf2f5ae32adb6748a5d1fe461 Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Tue, 12 Nov 2024 11:06:16 -0800 Subject: [PATCH] allow URL and DOI in feedback form associated articles related bibcodes --- .../AssociatedArticlesForm.tsx | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/components/FeedbackForms/AssociatedArticles/AssociatedArticlesForm.tsx b/src/components/FeedbackForms/AssociatedArticles/AssociatedArticlesForm.tsx index 1f350474c..5aac690c0 100644 --- a/src/components/FeedbackForms/AssociatedArticles/AssociatedArticlesForm.tsx +++ b/src/components/FeedbackForms/AssociatedArticles/AssociatedArticlesForm.tsx @@ -7,6 +7,7 @@ import { Flex, FormControl, FormErrorMessage, + FormHelperText, FormLabel, HStack, IconButton, @@ -121,10 +122,16 @@ export const AssociatedArticlesForm = ({ setParams(null); closePreview(); } else if (state === 'submitting') { - const { mainBibcode, associatedBibcodes } = getValues(); + const { mainBibcode, associatedBibcodes, relationship } = getValues(); // validate bibcodes - const bibsSet = new Set([mainBibcode, ...associatedBibcodes.map((b) => b.value)]); + + // if relationship is 'other', associated bibcodes could be DOI or URL, these do not need to be validated + const relatedBibcodes = + relationship === 'other' + ? associatedBibcodes.filter((b) => !b.value.includes('/')) // if string has '/' assume it's URL or DOI + : associatedBibcodes; + const bibsSet = new Set([mainBibcode, ...relatedBibcodes.map((b) => b.value)]); setAllBibcodes(Array.from(bibsSet)); } else if (state === 'validate-bibcodes' && allBibcodes) { void bibcodesRefetch(); @@ -375,19 +382,24 @@ export const AssociatedTable = () => { - {`${ - relationship === 'errata' - ? 'Errata ' - : relationship === 'addenda' - ? 'Addenda ' - : relationship === 'series' - ? 'Series of articles ' - : relationship === 'arxiv' - ? 'Main paper ' - : relationship === 'duplicate' - ? 'Duplicate ' - : 'Related ' - }Bibcode(s)`} + + {`${ + relationship === 'errata' + ? 'Errata ' + : relationship === 'addenda' + ? 'Addenda ' + : relationship === 'series' + ? 'Series of articles ' + : relationship === 'arxiv' + ? 'Main paper ' + : relationship === 'duplicate' + ? 'Duplicate ' + : 'Related ' + }${relationship === 'other' ? 'Bibcode, Associated URL, or DOI without prefix' : 'Bibcode(s)'}`} + + {relationship === 'other' && ( + i.e. https://doi.org/10.1093/mnras/stae2140, 10.1093/mnras/stae2140 + )} {associatedBibcodes.map((b, index) => (