Skip to content

Commit

Permalink
feat: completes add supplementary files
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentauger committed Nov 28, 2024
1 parent 4bca404 commit 1e18966
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 17 deletions.
8 changes: 8 additions & 0 deletions app/Http/Controllers/PublicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function store(Request $request): JsonResource
'is_open_access' => 'boolean',
]);

if($validated['is_open_access']){
$validated['embargoed_until'] = null;
}

// create the publication
$publication = new Publication($validated);
$publication->user_id = $request->user()->id;
Expand Down Expand Up @@ -110,6 +114,10 @@ public function update(Request $request, Publication $publication): JsonResource
'is_open_access' => 'boolean',
]);

if($validated['is_open_access']){
$validated['embargoed_until'] = null;
}

// update the publication
$publication->update($validated);

Expand Down
5 changes: 3 additions & 2 deletions resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@
"document-type": "Document Type",
"select-file": "Select or drop file here",
"optional": "Optional",
"cant-download": "You are not authorized to download this file."
"cant-download": "You are not authorized to download this file.",
"publication-previous-version": "This is a previous version of the publication"
},
"create-author-dialog": {
"title": "Create a new author"
Expand Down Expand Up @@ -636,7 +637,7 @@
},
"publication-page": {
"attach-pub-details": "Please upload the most recent version of your publication in PDF format. Files in this section are subject to the applicable embargo period and can only be accessed by authorized users, such as the authors and managers, until the embargo has expired.",
"attach-publication": "Attach Publication",
"attach-publication": "Published Work",
"go-to-manuscript-record": "Go to Manuscript Record",
"mark-as-published": "Mark as Published",
"publication-date-pending": "Publication Date Pending",
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 @@ -273,7 +273,8 @@
"document-type": "Type de document",
"optional": "Facultatif",
"select-file": "Sélectionnez ou déposez le fichier ici",
"cant-download": "Vous n'êtes pas autorisé à télécharger ce fichier."
"cant-download": "Vous n'êtes pas autorisé à télécharger ce fichier.",
"publication-previous-version": "Ceci est une version précédente de la publication"
},
"create-author-dialog": {
"title": "Créer un nouvel auteur"
Expand Down Expand Up @@ -636,7 +637,7 @@
},
"publication-page": {
"attach-pub-details": "Veuillez télécharger la version la plus récente de votre publication au format PDF. \nLes fichiers de cette section sont soumis à la période d'embargo applicable et ne sont accessibles qu'aux utilisateurs autorisés, tels que les auteurs et les gestionnaires, jusqu'à l'expiration de l'embargo.",
"attach-publication": "Joindre la publication",
"attach-publication": "Travail publié",
"go-to-manuscript-record": "Aller au registre du manuscrit",
"mark-as-published": "Marquer comme publié",
"publication-date-pending": "Date de publication en attente",
Expand Down
4 changes: 2 additions & 2 deletions resources/src/models/Media/components/MediaListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ const { t } = useI18n()
<q-btn
icon="mdi-file-download-outline"
color="primary"
:disabled="!media.can?.download"
:disable="!media.can?.download"
:href="media.can?.download ? downloadUrl : undefined"
>
<q-tooltip>
<q-tooltip v-if="!media.can?.download">
{{ t('common.cant-download') }}
</q-tooltip></q-btn></span>
</q-item-section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function upload() {
props.publication.data.id,
)
publicationResourceList.value?.data.push(response)
publicationResourceList.value?.data.unshift(response)
uploadingFile.value = false
// clear file
Expand Down Expand Up @@ -93,12 +93,23 @@ watch(publicationFile, () => {
<q-card outlined class="q-mb-md">
<q-list separator>
<MediaListItem
v-for="publicationResource in publicationResourceList.data"
v-for="(publicationResource, index) in publicationResourceList.data"
:key="publicationResource.data.uuid"
:media="publicationResource"
:download-url="`api/publications/${props.publication.data.id}/files/${publicationResource.data.uuid}?download=true`"
@delete="deleteFile"
>
<template v-if="index !== 0" #prepend>
<q-item-section avatar>
<q-icon name="mdi-history" color="secondary">
<q-tooltip>
{{
t('common.publication-previous-version')
}}
</q-tooltip>
</q-icon>
</q-item-section>
</template>
<template v-if="!publicationResource.can?.download" #side>
<span class="q-mr-sm">{{
$t(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function upload() {
description.value,
)
supplementaryFileResourceList.value?.data.push(response)
supplementaryFileResourceList.value?.data.unshift(response)
uploadingFile.value = false
// clear file
Expand Down
16 changes: 8 additions & 8 deletions resources/src/models/Publication/views/PublicationsView.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<script setup lang="ts">
import PublicationList from '../components/PublicationList.vue'
import type {
PublicationResourceList,
} from '../Publication'
import {
PublicationQuery,
PublicationService,
} from '../Publication'
import ContentCard from '@/components/ContentCard.vue'
import SearchInput from '@/components/SearchInput.vue'
import MainPageLayout from '@/layouts/MainPageLayout.vue'
import NoResultFoundDiv from '@/components/NoResultsFoundDiv.vue'
import PaginationDiv from '@/components/PaginationDiv.vue'
import JournalSelect from '@/models/Journal/components/JournalSelect.vue'
import SearchInput from '@/components/SearchInput.vue'
import MainPageLayout from '@/layouts/MainPageLayout.vue'
import AuthorSelect from '@/models/Author/components/AuthorSelect.vue'
import JournalSelect from '@/models/Journal/components/JournalSelect.vue'
import PublicationList from '../components/PublicationList.vue'
import {
PublicationQuery,
PublicationService,
} from '../Publication'
const publications = ref<PublicationResourceList>()
const { t } = useI18n()
Expand Down

0 comments on commit 1e18966

Please sign in to comment.