2024-04-09 17:58:02 +02:00
<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2024-04-10 11:50:17 +02:00
File : ResearchComponent . vue
2024-04-09 17:58:02 +02:00
Author : Maxime Bartha
Scope : Extension Publicatons scientifiquess
2024-04-21 01:37:30 +02:00
Description : Pop Up summarizing a research infos
2024-04-09 17:58:02 +02:00
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - >
2024-04-17 23:00:37 +02:00
< script setup xmlns = "http://www.w3.org/1999/html" >
2024-04-21 15:10:17 +02:00
import { ref , watch } from "vue" ;
2024-04-09 17:32:04 +02:00
import { onClickOutside } from '@vueuse/core'
2024-04-21 15:10:17 +02:00
import {
patchArticle ,
deleteArticle ,
addView ,
} from "@/rest/ScientificPublications/ManageResearch.js" ;
2024-04-21 01:37:30 +02:00
import i18n from "../../i18n.js" ;
2024-04-21 15:10:17 +02:00
const coAuthors = ref ( )
2024-04-19 17:13:15 +02:00
const restURL = import . meta . env . VITE _CLYDE _MODE === 'container' ? "http://localhost:8000" : import . meta . env . DEV ? "http://localhost:5173" : "https://clyde.herisson.ovh/api"
2024-04-09 17:32:04 +02:00
const props = defineProps ( {
isOpen : Boolean ,
2024-04-17 23:00:37 +02:00
article : ref ( Object ) ,
manage : Boolean ,
2024-04-21 15:10:17 +02:00
allResearcher : ref ( )
2024-04-09 17:32:04 +02:00
} ) ;
2024-04-19 17:13:15 +02:00
2024-04-21 15:10:17 +02:00
watch (
( ) => props . article ,
( newValue ) => {
if ( newValue !== null )
coAuthors . value = newValue . coAuthors
}
) ;
2024-04-15 23:35:05 +02:00
function format ( date ) {
let split = date . split ( "-" )
let month = split [ 1 ]
let day = split [ 2 ] . split ( "T" ) [ 0 ]
let year = split [ 0 ]
return day + "/" + month + "/" + year
}
2024-04-19 17:13:15 +02:00
const emit = defineEmits ( [ "modal-close" , "modified" ] ) ;
2024-04-09 17:32:04 +02:00
const target = ref ( null )
2024-04-21 15:10:17 +02:00
onClickOutside ( target , ( ) => { emit ( 'modal-close' ) ; } )
2024-04-09 17:32:04 +02:00
2024-04-17 23:00:37 +02:00
let toModify = Object . assign ( { } , { } ) ;
function cancelChanges ( ) {
toModify = Object . assign ( { } , { } ) ;
emit ( 'modal-close' )
}
2024-04-19 17:13:15 +02:00
2024-04-18 16:17:16 +02:00
async function confirmChanges ( ) {
2024-04-21 15:10:17 +02:00
let coAuthorsId = [ ]
coAuthors . value . forEach ( n => ( coAuthorsId . push ( n . id ) ) )
toModify . coAuthors = coAuthorsId
2024-04-18 16:17:16 +02:00
await patchArticle ( props . article . id , toModify )
2024-04-17 23:00:37 +02:00
toModify = Object . assign ( { } , { } ) ;
emit ( 'modal-close' )
2024-04-18 16:17:16 +02:00
emit ( "modified" )
2024-04-17 23:00:37 +02:00
}
2024-04-18 16:17:16 +02:00
async function deleteThisArticle ( ) {
await deleteArticle ( props . article . id )
2024-04-17 23:00:37 +02:00
emit ( 'modal-close' )
2024-04-18 16:17:16 +02:00
emit ( "modified" )
2024-04-17 23:00:37 +02:00
}
2024-04-19 17:13:15 +02:00
function downloadPdf ( ) {
return ( restURL + "/" + props . article . pdfLocation )
}
2024-04-17 23:00:37 +02:00
2024-04-19 17:13:15 +02:00
function downloadBibTex ( ) {
return ( restURL + "/" + props . article . bibTexLocation )
}
async function articleClicked ( ) {
await addView ( props . article . pdfLocation )
emit ( 'modal-close' )
2024-04-19 17:37:59 +02:00
emit ( 'modified' )
2024-04-19 17:13:15 +02:00
}
2024-04-09 17:32:04 +02:00
< / script >
< template >
< div v-if = "isOpen" class="modal-mask" >
< div class = "modal-wrapper" >
< div class = "modal-container" ref = "target" >
2024-04-21 15:10:17 +02:00
< div > < ul >
2024-04-21 01:37:30 +02:00
< li > { { i18n ( "Article.Id" ) } } : { { article . id } } < / li >
< li > { { i18n ( "Title" ) } } : { { article . title } } < / li >
< li > { { i18n ( "Author" ) } } : { { article . researcher . user . lastName + " " + article . researcher . user . firstName } } < / li >
< li > { { i18n ( "CoAuthors" ) } } : < ul id = "coAuthors" v-for = "n in article.coAuthors"> <li id="coAuthorsLi" > {{ n.user.firstName }} {{ n.user.lastName }} , < / li > < / ul > < / li >
< li > { { i18n ( "Summary" ) } } : { { article . summary } } < / li >
< li > { { i18n ( "ReleaseDate" ) } } : { { format ( article . releaseDate ) } } < / li >
< li > { { i18n ( "Language" ) } } : { { article . language } } < / li >
< li > { { i18n ( "PaperType" ) } } : { { article . paperType } } < / li >
< li > { { i18n ( "Domain" ) } } : { { article . domain } } < / li >
< li > { { i18n ( "Views" ) } } : { { article . views } } < / li >
< li > { { i18n ( "Access" ) } } : { { i18n ( article . access ) } } < / li >
2024-04-17 23:00:37 +02:00
< / ul >
2024-04-19 19:54:51 +02:00
< div id = "downloads" v-if = "article.pdfLocation !== null && !manage" >
2024-04-21 01:37:30 +02:00
< a : href = downloadPdf ( ) @click.stop ="articleClicked" target = "_blank" > { { i18n ( "See.Research" ) } } < / a >
< a v-if = "article.bibTexLocation !== null" :href=downloadBibTex() @click.stop="emit('modal-close')" target="_blank" > {{ i18n ( " See.BibTex " ) }} < / a > < / div >
2024-04-17 23:00:37 +02:00
< / div >
2024-04-21 15:10:17 +02:00
< div v-if = "manage" id="manage" >
2024-04-17 23:00:37 +02:00
< div >
< ul >
2024-04-21 01:37:30 +02:00
< li > { { i18n ( "Title" ) } } : < input v-model = "toModify.title" > < / li >
< li > { { i18n ( "Language" ) } } : < input v-model = "toModify.language" > < / li >
< li > { { i18n ( "Summary" ) } } : < input v-model = "toModify.summary" > < / li >
< li > { { i18n ( "Domain" ) } } : < input v-model = "toModify.domain" > < / li >
< li > { { i18n ( "Access" ) } } :
2024-04-18 14:53:17 +02:00
< select id = "classed-select" v-model = "toModify.access" >
2024-04-21 01:37:30 +02:00
< option value = "OpenSource" > { { i18n ( "Access.OpenSource" ) } } < / option >
< option value = "Restricted" > { { i18n ( "Access.Restricted" ) } } < / option >
< option value = "Private" > { { i18n ( "Access.Private" ) } } < / option >
2024-04-17 23:00:37 +02:00
< / select > < / li >
< / ul >
< / div >
2024-04-21 15:10:17 +02:00
< div > { { i18n ( "CoAuthors.List" ) } } :
< ul id = "coAuthorListUl" style = "list-style-type: none;" v-for = "n in props.allResearcher" >
< li v-if = "n.id !== props.article.researcher.id"> <input type="checkbox" :value=n v-model="coAuthors" > {{ n.id }} : {{ n.user.firstName }} {{ n.user.lastName }} < / li >
< / ul >
< / div >
< div >
2024-04-21 01:37:30 +02:00
< button id = "confirmButton" @click ="confirmChanges" > {{ i18n ( " Confirm.Changes " ) }} < / button >
< button id = "cancelButton" @click ="cancelChanges" > {{ i18n ( " Cancel.Changes " ) }} < / button >
2024-04-21 15:10:17 +02:00
< / div >
< div style = "text-align: end" >
< button id = "deleteButton" @click ="deleteThisArticle" > {{ i18n ( " Delete.Research " ) }} < / button >
< / div >
2024-04-09 17:32:04 +02:00
< / div >
< / div >
< / div >
< / div >
< / template >
< style scoped >
. modal - mask {
position : fixed ;
z - index : 9998 ;
top : 0 ;
left : 0 ;
width : 100 % ;
2024-04-20 19:07:27 +02:00
height : 120 % ;
2024-04-09 17:32:04 +02:00
background - color : rgba ( 0 , 0 , 0 , 0.5 ) ;
}
. modal - container {
width : 70 % ;
margin : 150 px auto ;
padding : 20 px 30 px ;
background : rgba ( 157 , 99 , 205 ) ;
border - radius : 12 px ;
box - shadow : 0 2 px 8 px rgba ( 0 , 0 , 0 , 0.33 ) ;
}
2024-04-15 23:35:05 +02:00
. modal - container ul {
margin - top : 9 px ;
}
2024-04-21 15:10:17 +02:00
# manage {
display : grid ;
grid - template - columns : auto auto ;
}
2024-04-15 23:35:05 +02:00
2024-04-20 19:07:27 +02:00
# coAuthors {
list - style : none ;
display : inline ;
padding : 0 ;
}
# coAuthorsLi {
display : inline ;
margin - right : 2 px ;
}
2024-04-09 17:32:04 +02:00
# downloads {
text - align : end ;
}
2024-04-21 15:10:17 +02:00
# coAuthorListUl {
overflow : scroll ;
}
2024-04-19 17:13:15 +02:00
# downloads a {
2024-04-09 17:32:04 +02:00
align - self : center ;
margin - left : 2 px ;
font - size : large ;
color : white ;
background : rgba ( 191 , 64 , 191 , 0.5 ) ;
border : 2 px solid black ;
border - radius : 5 px ;
2024-04-19 17:13:15 +02:00
text - underline - mode : none ;
text - decoration : none ;
2024-04-09 17:32:04 +02:00
}
2024-04-10 01:14:14 +02:00
# downloads button : hover {
background : rgba ( 191 , 64 , 191 ) ;
}
2024-04-09 17:32:04 +02:00
2024-04-17 23:00:37 +02:00
# deleteButton {
2024-04-21 15:10:17 +02:00
align - self : end ;
text - align : end ;
2024-04-17 23:00:37 +02:00
border : 2 px solid black ;
color : white ;
2024-04-21 15:10:17 +02:00
font - size : x - large ;
2024-04-17 23:00:37 +02:00
border - radius : 20 px ;
background - color : red ;
}
# deleteButton : hover {
background : # ff2d55 ;
}
# cancelButton {
align - self : center ;
text - align : center ;
border : 2 px solid black ;
color : white ;
font - size : x - large ;
background - color : rgba ( 191 , 64 , 191 , 0.5 ) ;
border - radius : 20 px ;
}
# cancelButton : hover {
background : rgba ( 191 , 64 , 191 )
}
# confirmButton {
align - self : center ;
text - align : center ;
border : 2 px solid black ;
color : white ;
font - size : x - large ;
background - color : # 07 bc0c ;
border - radius : 20 px ;
}
# confirmButton : hover {
background : # 4 cd964 ;
}
2024-04-09 17:32:04 +02:00
< / style >