Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentauger committed Dec 12, 2024
1 parent 760af27 commit e052ee5
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 43 deletions.
3 changes: 2 additions & 1 deletion resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,8 @@
"publication-updated-successfully": "Publication updated successfully",
"title": "Publication",
"attach-supplementary-files": "Supplementary Files",
"attach-supplementary-files-details": "Please upload all relevant supplementary files for your publications."
"attach-supplementary-files-details": "Please upload all relevant supplementary files for your publications.",
"no-supplementary-files": "No supplementary files attached."
},
"publications-view": {
"all-published-publications-details": "All published publications",
Expand Down
5 changes: 3 additions & 2 deletions resources/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"unique-id": "Identifiant unique",
"unknown": "Inconnue",
"update": "Mettre à jour",
"updated-successfully": "Mis à jour réussie ",
"updated-successfully": "mise à jour réussie ",
"upload": "Télécharger",
"user": "Utilisateur",
"validation": {
Expand Down Expand Up @@ -651,7 +651,8 @@
"publication-updated-successfully": "Publication mise à jour avec succès",
"title": "Publication",
"attach-supplementary-files": "Fichiers supplémentaires",
"attach-supplementary-files-details": "Veuillez télécharger tous les fichiers supplémentaires pertinents pour vos publications."
"attach-supplementary-files-details": "Veuillez télécharger tous les fichiers supplémentaires pertinents pour vos publications.",
"no-supplementary-files": "Aucun fichier supplémentaire joint."
},
"publications-view": {
"all-published-publications-details": "Toutes les publications publiées",
Expand Down
16 changes: 16 additions & 0 deletions resources/src/models/ManuscriptRecord/ManuscriptRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,17 @@ export type ManuscriptRecordSummary = Omit<
| 'can_attach_manuscript'
>

export interface ManuscriptRecordMetadata {
id: number
ulid: string
region_id: number
reviewed_at: string | null
}

export type ManuscriptRecordResource = Resource<ManuscriptRecord>
export type ManuscriptRecordResourceList = ResourceList<ManuscriptRecord>
export type ManuscriptRecordSummaryResource = Resource<ManuscriptRecordSummary>
export type ManuscriptRecordMetadataResource = Resource<ManuscriptRecordMetadata>
export type ManuscriptRecordSummaryResourceList =
ResourceList<ManuscriptRecordSummary>

Expand All @@ -96,6 +104,14 @@ export class ManuscriptRecordService {
return response.data
}

/** Get a manuscript record metadata */
public static async metadata(id: number) {
const response = await http.get<ManuscriptRecordMetadataResource>(
`${this.baseURL}/${id}/metadata`,
)
return response.data
}

/**
* Create a manuscript record.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
import type { SupplementaryFileOption, SupplementaryFileType } from '../supplementaryFileOptions'
import { useSupplementaryFileOptions } from '../supplementaryFileOptions'
const props = defineProps<{
hideMrf?: boolean
}>()
const model = defineModel<SupplementaryFileType | null>()
const options = useSupplementaryFileOptions()
const options = useSupplementaryFileOptions(props.hideMrf)
const localModel = ref<SupplementaryFileOption | null>(null)
const { t } = useI18n()
Expand Down
6 changes: 5 additions & 1 deletion resources/src/models/Media/supplementaryFileOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface SupplementaryFileOption {
description: string
}

export function useSupplementaryFileOptions() {
export function useSupplementaryFileOptions(hideMrf = false) {
const { t } = useI18n()

const options = computed<SupplementaryFileOption[]>(() => [
Expand All @@ -29,5 +29,9 @@ export function useSupplementaryFileOptions() {
{ label: () => t('supplementaryFileType.other'), value: 'other', description: t('supplementaryFileType.otherDescription') },
])

if (hideMrf) {
return computed(() => options.value.filter(option => option.value !== 'manuscript_record_form'))
}

return options
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Media, MediaResource, MediaResourceList } from '@/models/Media/Media'
import type { MediaResource, MediaResourceList } from '@/models/Media/Media'
import ContentCard from '@/components/ContentCard.vue'
import MediaListItem from '@/models/Media/components/MediaListItem.vue'
import { useQuasar } from 'quasar'
Expand Down Expand Up @@ -83,11 +83,11 @@ watch(publicationFile, () => {
<ContentCard class="q-mb-md" secondary>
<template #title>
{{
$t('publication-page.attach-publication')
t('publication-page.attach-publication')
}}
</template>
<p>
{{ $t('publication-page.attach-pub-details') }}
<p v-if="publication.can?.update">
{{ t('publication-page.attach-pub-details') }}
</p>
<template v-if="publicationResourceList?.data">
<q-card outlined class="q-mb-md">
Expand All @@ -112,7 +112,7 @@ watch(publicationFile, () => {
</template>
<template v-if="!publicationResource.can?.download" #side>
<span class="q-mr-sm">{{
$t(
t(
'common.publication-under-embargo',
)
}}</span>
Expand Down Expand Up @@ -150,7 +150,7 @@ watch(publicationFile, () => {
color="primary"
:loading="uploadingFile"
:disable="!publicationFile"
:label="$t('common.upload')"
:label="t('common.upload')"
@click="upload"
/>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function upload() {
const response = await PublicationService.attachSupplementaryFile(
supplementaryFile.value,
props.publication.data.id,
fileType.value,
fileType.value as SupplementaryFileType,
description.value,
)
Expand Down Expand Up @@ -111,17 +111,21 @@ const disableUpload = computed(() => {
}
return false
})
const hideMrf = computed(() => {
return props.publication.data.manuscript_record_id !== null
})
</script>

<template>
<ContentCard class="q-mb-md" secondary>
<template #title>
{{
$t('publication-page.attach-supplementary-files')
t('publication-page.attach-supplementary-files')
}}
</template>
<p>
{{ $t('publication-page.attach-supplementary-files-details') }}
<p v-if="publication.can?.update">
{{ t('publication-page.attach-supplementary-files-details') }}
</p>
<template v-if="supplementaryFileResourceList?.data">
<q-card outlined class="q-mb-md">
Expand All @@ -136,18 +140,25 @@ const disableUpload = computed(() => {
</q-list>
</q-card>
</template>
<template v-if="supplementaryFileResourceList?.data.length === 0">
<q-card bordered class="q-mb-md">
<q-card-section class="text-center">
{{ t('publication-page.no-supplementary-files') }}
</q-card-section>
</q-card>
</template>
<q-card v-if="publication.can?.update" class="q-pa-md" flat bordered>
<p class="text-primary">
Upload a supplementary file for the publication
</p>
<div class="row q-col-gutter-md q-mb-md">
<SupplementaryFileTypeSelect v-model="fileType" class="col" />
<SupplementaryFileTypeSelect v-model="fileType" :hide-mrf="hideMrf" class="col" />
<q-file
v-model="supplementaryFile"
class="col-lg-8 col-md-12"
outlined
use-chips
:label="$t('common.select-file')"
:label="t('common.select-file')"
:hint="t('mrf.upload-hint', { max: maxFileSizeMB })"
accept="application/pdf"
:max-file-size="maxFileSizeMB * 1e6"
Expand Down Expand Up @@ -176,7 +187,7 @@ const disableUpload = computed(() => {
color="primary"
:loading="uploadingFile"
:disable="disableUpload"
:label="$t('common.upload')"
:label="t('common.upload')"
@click="upload"
/>
</div>
Expand Down
Loading

0 comments on commit e052ee5

Please sign in to comment.