This commit is contained in:
2024-04-19 17:13:15 +02:00
parent a168d41aee
commit e998fb2ab4
3 changed files with 36 additions and 30 deletions

View File

@ -8,13 +8,17 @@
<script setup xmlns="http://www.w3.org/1999/html">
import {ref } from "vue";
import {onClickOutside} from '@vueuse/core'
import {patchArticle, deleteArticle} from "@/rest/ScientificPublications/ManageResearch.js";
import {patchArticle, deleteArticle, addView} from "@/rest/ScientificPublications/ManageResearch.js";
const restURL = import.meta.env.VITE_CLYDE_MODE === 'container' ? "http://localhost:8000": import.meta.env.DEV ? "http://localhost:5173" : "https://clyde.herisson.ovh/api"
const props = defineProps({
isOpen: Boolean,
article: ref(Object),
manage:Boolean,
});
function format(date){
let split = date.split("-")
let month = split[1]
@ -23,7 +27,7 @@ function format(date){
return day +"/"+ month +"/"+ year
}
const emit = defineEmits(["modal-close","downloadPdf","downloadBibTex","modified"]);
const emit = defineEmits(["modal-close","modified"]);
const target = ref(null)
onClickOutside(target, ()=>emit('modal-close'))
@ -34,6 +38,7 @@ function cancelChanges(){
toModify= Object.assign({}, {});
emit('modal-close')
}
async function confirmChanges(){
await patchArticle(props.article.id, toModify)
toModify= Object.assign({}, {});
@ -46,7 +51,26 @@ async function deleteThisArticle(){
emit('modal-close')
emit("modified")
}
function downloadPdf(){
return (restURL + "/" + props.article.pdfLocation)
}
function downloadBibTex(){
return (restURL + "/" + props.article.bibTexLocation)
}
async function articleClicked(){
await addView(props.article.pdfLocation)
emit('modal-close')
}
/**
function downloadCoAuthors(){
//todo
const data = JSON.stringify(researcher.value);
const blob = new Blob([data], {type:"application/json"});
return URL.createObjectURL(blob);
} **/
</script>
@ -55,7 +79,6 @@ async function deleteThisArticle(){
<div class="modal-wrapper">
<div class="modal-container" ref="target">
<div ><ul>
<li>Article Id : {{article.id}}</li>
<li>Title : {{article.title}}</li>
<li>Author : {{article.researcher.user.lastName + " " + article.researcher.user.firstName}}</li>
@ -67,11 +90,10 @@ async function deleteThisArticle(){
<li>Views : {{article.views}}</li>
<li>Access : {{article.access}}</li>
</ul>
<div id="downloads" v-if="article.pdfLocation !== null && !manage">
<button @click.stop="emit('downloadBibTex')">Download BibTex</button>
<button @click.stop="emit('downloadPdf')">Download Research</button>
</div>
<button @click="console.log(props.article)"> infos</button>
<div id="downloads" v-if="article !== null && !manage">
<a :href=downloadPdf() @click.stop="articleClicked" target="_blank">See Research</a>
<a :href=downloadBibTex() @click.stop="emit('modal-close')" target="_blank">See bibTex</a> </div>
</div>
<div v-if="manage">
<div>
@ -125,7 +147,7 @@ async function deleteThisArticle(){
#downloads {
text-align: end;
}
#downloads button {
#downloads a {
align-self: center;
margin-left: 2px;
font-size: large;
@ -133,6 +155,8 @@ async function deleteThisArticle(){
background: rgba(191, 64, 191,0.5);
border:2px solid black;
border-radius: 5px;
text-underline-mode: none;
text-decoration: none;
}
#downloads button:hover{
background: rgba(191, 64, 191);