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

Award dois UI #1053

Merged
merged 4 commits into from
Sep 20, 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
10 changes: 8 additions & 2 deletions web/src/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,23 @@ interface PrincipalInvestigator {
orcid?: string;
}

export interface DOI {
type: string,
id:string,
}

export interface StudySearchResults extends BaseSearchResult {
principal_investigator_websites: string[];
principal_investigator_name: string;
principal_investigator_image_url: string;
image_url: string;
principal_investigator: PrincipalInvestigator;
doi: string;
award_dois: DOI[];
dataset_dois: DOI[],
doi_map: Record<string, {
type: string;
}>,
publication_dois: string[];
publication_dois: DOI[];
omics_counts: {
type: string;
count: number;
Expand Down
149 changes: 98 additions & 51 deletions web/src/views/IndividualResults/StudyPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Cite from 'citation-js';
import {
typeWithCardinality, valueCardinality, fieldDisplayName,
} from '@/util';
import { api, StudySearchResults } from '@/data/api';
import { api, StudySearchResults, DOI } from '@/data/api';
import { setUniqueCondition, setConditions } from '@/store';
import { useRouter } from '@/use/useRouter';
import AttributeItem from '@/components/Presentation/AttributeItem.vue';
Expand Down Expand Up @@ -43,8 +43,9 @@ export default defineComponent({

setup(props) {
const data = reactive({
doiCitation: '' as string | null,
publications: [] as any[],
awardDois: [] as DOI[],
publicationDois: [] as DOI[],
datasetDois: [] as DOI[],
});

const item = ref(null as StudySearchResults | null);
Expand Down Expand Up @@ -137,12 +138,16 @@ export default defineComponent({
watch(item, async (_item) => {
const doiMap = _item?.doi_map;
if (doiMap) {
data.doiCitation = null;
data.publications = [];
data.doiCitation = CitationOverrides[_item.doi] || formatAPA(new Cite(_item.doi));
data.publications = _item.publication_dois
.filter((doi) => doi in doiMap)
.map((doi) => formatAPA(new Cite(doiMap[doi])));
data.awardDois = [];
data.publicationDois = [];
data.datasetDois = [];
data.awardDois = _item.award_dois
.filter((doi) => doi.id in doiMap)
.map((doi) => formatAPA(new Cite(doi.id)));
// CitationOverrides[_item.award_doi] || formatAPA(new Cite(_item.award_doi));
naglepuff marked this conversation as resolved.
Show resolved Hide resolved
data.publicationDois = _item.publication_dois
.filter((doi) => doi.id in doiMap)
.map((doi) => formatAPA(new Cite(doiMap[doi.id])));
}
});

Expand Down Expand Up @@ -211,10 +216,6 @@ export default defineComponent({
Study Details
</div>
<v-list>
<AttributeItem
v-if="item.doi"
v-bind="{ item, field: 'doi' }"
/>
<AttributeItem
v-bind="{ item, field: 'id', bindClick: true }"
@click="seeStudyInContext"
Expand Down Expand Up @@ -306,50 +307,96 @@ export default defineComponent({
</v-col>
</v-col>
<v-col cols="5">
<div class="ma-4 pa-2 grey lighten-4">
<v-subheader v-if="item.doi">
Dataset Citation
</v-subheader>
<v-list
v-if="item.doi"
class="transparent"
<div
v-if="Object.keys(item.doi_map).length !== 0"
class="ma-4 pa-2 grey lighten-4"
>
<template v-if="item.award_dois.length > 0">
<v-subheader>
Award DOIs
</v-subheader>
<v-list
class="transparent"
>
<v-divider />
<v-list-item
v-for="(award, index) in data.awardDois"
:key="index"
>
<v-list-item-content>
{{ award }}
</v-list-item-content>
<v-list-item-action>
<v-tooltip top>
<template #activator="{ on }">
<v-btn
icon
v-on="on"
@click="openLink(`https://doi.org/${item.award_dois[index].id}`)"
>
<v-icon>mdi-open-in-new</v-icon>
</v-btn>
</template>
<span>Visit site</span>
</v-tooltip>
</v-list-item-action>
</v-list-item>
</v-list>
</template>
<template
v-if="data.publicationDois.length > 0"
>
<v-subheader>
Publications
</v-subheader>
<v-divider />
<v-list-item>
<v-list-item-content
v-text="data.doiCitation || item.doi"
/>
<v-list-item-action>
<v-tooltip top>
<template #activator="{ on }">
<v-btn
icon
v-on="on"
@click="openLink(`https://doi.org/${item.doi}`)"
>
<v-icon>mdi-open-in-new</v-icon>
</v-btn>
</template>
<span>Visit site</span>
</v-tooltip>
</v-list-item-action>
</v-list-item>
</v-list>
<v-subheader v-if="data.publications.length > 0">
Other publications
</v-subheader>
<v-list class="transparent">
<template v-for="(pub, pubIndex) in data.publications">
<v-divider :key="`${pubIndex}-divider`" />
<v-list-item :key="pubIndex">
<v-list-item-content v-text="pub" />
<v-list
class="
transparent"
>
<template v-for="(pub, pubIndex) in data.publicationDois">
<v-list-item :key="pubIndex">
<v-list-item-content v-text="pub" />
<v-list-item-action>
<v-tooltip top>
<template #activator="{ on }">
<v-btn
icon
v-on="on"
@click="openLink(`https://doi.org/${item.publication_dois[pubIndex].id}`)"
>
<v-icon>mdi-open-in-new</v-icon>
</v-btn>
</template>
<span>Visit site</span>
</v-tooltip>
</v-list-item-action>
</v-list-item>
</template>
</v-list>
</template>
<template v-if="item.dataset_dois.length > 0">
<v-subheader>
Data DOIs
</v-subheader>
<v-list
class="transparent"
>
<v-divider />
<v-list-item
v-for="(dataDOI, index) in data.datasetDois"
:key="index"
>
<v-list-item-content>
{{ dataDOI }}
</v-list-item-content>
<v-list-item-action>
<v-tooltip top>
<template #activator="{ on }">
<v-btn
icon
v-on="on"
@click="openLink(`https://doi.org/${item.publication_dois[pubIndex]}`)"
@click="openLink(`https://doi.org/${item.dataset_dois[index].id}`)"
>
<v-icon>mdi-open-in-new</v-icon>
</v-btn>
Expand All @@ -358,8 +405,8 @@ export default defineComponent({
</v-tooltip>
</v-list-item-action>
</v-list-item>
</template>
</v-list>
</v-list>
</template>
</div>
</v-col>
</v-row>
Expand Down
Loading