-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add reference papers page to edit software section
- Loading branch information
1 parent
ce3dd54
commit 9ff7827
Showing
24 changed files
with
1,145 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-- SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
-- SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
-- SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
-- | ||
|
@@ -17,3 +18,61 @@ $$ | |
SELECT mention FROM reference_paper_for_software | ||
) | ||
$$; | ||
|
||
-- UNIQUE CITATIONS BY SOFTWARE ID | ||
CREATE FUNCTION citation_by_software() RETURNS TABLE ( | ||
software UUID, | ||
id UUID, | ||
doi CITEXT, | ||
url VARCHAR, | ||
title VARCHAR, | ||
authors VARCHAR, | ||
publisher VARCHAR, | ||
publication_year SMALLINT, | ||
journal VARCHAR, | ||
page VARCHAR, | ||
image_url VARCHAR, | ||
mention_type mention_type, | ||
source VARCHAR, | ||
reference_papers UUID[] | ||
)LANGUAGE sql STABLE AS | ||
$$ | ||
SELECT | ||
reference_paper_for_software.software, | ||
mention.id, | ||
mention.doi, | ||
mention.url, | ||
mention.title, | ||
mention.authors, | ||
mention.publisher, | ||
mention.publication_year, | ||
mention.journal, | ||
mention.page, | ||
mention.image_url, | ||
mention.mention_type, | ||
mention.source, | ||
ARRAY_AGG( | ||
reference_paper_for_software.mention | ||
) AS reference_paper | ||
FROM | ||
reference_paper_for_software | ||
INNER JOIN | ||
citation_for_mention ON citation_for_mention.mention = reference_paper_for_software.mention | ||
INNER JOIN | ||
mention ON mention.id = citation_for_mention.citation | ||
GROUP BY | ||
reference_paper_for_software.software, | ||
mention.id, | ||
mention.doi, | ||
mention.url, | ||
mention.title, | ||
mention.authors, | ||
mention.publisher, | ||
mention.publication_year, | ||
mention.journal, | ||
mention.page, | ||
mention.image_url, | ||
mention.mention_type, | ||
mention.source | ||
; | ||
$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
|
@@ -11,8 +12,8 @@ export type SearchTermInfo = { | |
term: string, | ||
type: 'doi' | 'title' | ||
} | ||
|
||
export function extractSearchTerm(query: string): SearchTermInfo{ | ||
|
||
const doiRegexMatch = query.match(doiRegex) | ||
if (doiRegexMatch != null) { | ||
return {term: doiRegexMatch[0], type: 'doi'} | ||
|
96 changes: 96 additions & 0 deletions
96
frontend/components/software/edit/reference-papers/CitationItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {MentionItemProps} from '~/types/Mention' | ||
import {getMentionType} from '~/components/mention/config' | ||
import MentionAuthors from '~/components/mention/MentionAuthors' | ||
import MentionDoi from '~/components/mention/MentionDoi' | ||
import {MentionTitle} from '~/components/mention/MentionItemBase' | ||
import MentionPublisherItem from '~/components/mention/MentionPublisherItem' | ||
import useEditMentionReducer from '~/components/mention/useEditMentionReducer' | ||
|
||
export type CitationItemProps = MentionItemProps & { | ||
reference_papers: string[] | ||
} | ||
|
||
function ReferencePapers({papers}:{papers:Readonly<string[]>}){ | ||
const {mentions} = useEditMentionReducer() | ||
const reference:{doi:string,url:string,title:string|null}[] =[] | ||
|
||
if (papers?.length===0 || mentions?.length===0){ | ||
return ( | ||
<div className="text-sm"> | ||
Referenced paper: | ||
</div> | ||
) | ||
} | ||
|
||
papers.forEach(uuid=>{ | ||
const found = mentions.find(item=>item.id === uuid) | ||
if (found?.doi && found.url) reference.push({doi:found.doi, url:found.url, title: found.title}) | ||
}) | ||
|
||
if (reference.length === 0){ | ||
return ( | ||
<div className="text-sm"> | ||
Referenced: <i>None</i> | ||
</div> | ||
) | ||
} | ||
|
||
return( | ||
<div className="flex flex-wrap gap-2 text-sm text-base-content-secondary"> | ||
Referenced: { | ||
reference.map(item=>{ | ||
return ( | ||
<a | ||
key={item.url} | ||
href={item.url} target="_blank" rel="noreferrer" | ||
title={item.title ?? item.doi} | ||
className="text-sm " | ||
> | ||
{item.doi} | ||
</a> | ||
) | ||
}) | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
|
||
export default function CitationItem({item}:{item:Readonly<CitationItemProps>}){ | ||
const title = getMentionType(item?.mention_type,'singular') | ||
return ( | ||
<div data-testid="citation-view-item-body" className="py-2 px-4 hover:bg-base-200"> | ||
<div className="text-base-content-disabled"> | ||
{title} | ||
</div> | ||
<MentionTitle | ||
title={item?.title ?? ''} | ||
role="list" | ||
url={item.url} | ||
className="text-base" | ||
/> | ||
<MentionAuthors | ||
authors={item.authors} | ||
className="text-sm text-base-content-secondary" | ||
/> | ||
<MentionPublisherItem | ||
publisher={item?.publisher ?? ''} | ||
page={item?.page ?? ''} | ||
publication_year={item.publication_year} | ||
journal = {item.journal} | ||
className="text-sm text-base-content-secondary" | ||
/> | ||
<MentionDoi | ||
url={item?.url} | ||
doi={item?.doi} | ||
className="text-sm" | ||
/> | ||
<ReferencePapers papers={item.reference_papers} /> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.