| 
									
										
										
										
											2024-04-17 23:00:37 +02:00
										 |  |  | <script setup> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | import { ref } from "vue"; | 
					
						
							|  |  |  | import {onClickOutside} from '@vueuse/core' | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  | import {uploadFile, postResearch, fetchAllResearchers} from "@/rest/ScientificPublications/ManageResearch.js"; | 
					
						
							|  |  |  | const allResearcher = ref(await fetchAllResearchers()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const coAuthors = ref([]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let toPost = Object.assign({}, {coAuthors:[]}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const props = defineProps({ | 
					
						
							|  |  |  |   isOpen: Boolean, | 
					
						
							|  |  |  |   researcher: ref(Object) | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | async function uploadResearchPdf(pdf){ | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  |   const data = await uploadFile(pdf); | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |   toPost.pdfLocation = data.url; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-04-20 01:12:37 +02:00
										 |  |  | async function uploadBibTex(pdf){ | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  |   const data = await uploadFile(pdf); | 
					
						
							| 
									
										
										
										
											2024-04-20 01:12:37 +02:00
										 |  |  |   toPost.bibTexLocation = data.url; | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 16:17:16 +02:00
										 |  |  | async function postNewResearch(){ | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |   toPost.releaseDate = new Date() | 
					
						
							|  |  |  |   toPost.author = props.researcher | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  |   toPost.coAuthors = coAuthors.value | 
					
						
							|  |  |  |   console.log() | 
					
						
							| 
									
										
										
										
											2024-04-18 16:17:16 +02:00
										 |  |  |   //the Pdf and a title are required
 | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |   if (toPost.pdfLocation == null || toPost.title == null || toPost.title === "") { | 
					
						
							|  |  |  |     emit("modal-close") | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-04-18 16:17:16 +02:00
										 |  |  |   await postResearch(toPost) | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |   toPost = Object.assign({}, {}); | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  |   coAuthors.value = [] | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |   emit("modal-close") | 
					
						
							| 
									
										
										
										
											2024-04-18 16:17:16 +02:00
										 |  |  |   emit("posted") | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function cancelPost(){ | 
					
						
							|  |  |  |   emit("modal-close") | 
					
						
							|  |  |  |   toPost = Object.assign({}, {}); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-04-18 16:17:16 +02:00
										 |  |  | const emit = defineEmits(["modal-close","posted"]); | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const target = ref(null) | 
					
						
							|  |  |  | onClickOutside(target, ()=>emit('modal-close')) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-17 23:00:37 +02:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <template> | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |   <div v-if="isOpen" class="modal-mask"> | 
					
						
							|  |  |  |     <div class="modal-wrapper"> | 
					
						
							|  |  |  |       <div class="modal-container" ref="target"> | 
					
						
							|  |  |  |         <div ><ul> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           <li>Title : <input v-model="toPost.title"></li> | 
					
						
							|  |  |  |           <li>Summary : <input v-model="toPost.summary"></li> | 
					
						
							|  |  |  |           <li>Language : <input v-model="toPost.language"></li> | 
					
						
							|  |  |  |           <li>Domain : <input v-model="toPost.domain"></li> | 
					
						
							|  |  |  |           <li>PaperType :  <select  id="classed-select" v-model="toPost.paperType"> | 
					
						
							|  |  |  |             <option value="Article">Article</option> | 
					
						
							|  |  |  |             <option value="Book">Book</option> | 
					
						
							|  |  |  |             <option value="BookChapter">Book Chapter</option> | 
					
						
							|  |  |  |             <option value="Paper">Paper</option> | 
					
						
							|  |  |  |           </select></li> | 
					
						
							|  |  |  |           <li>Access : <select  id="classed-select" v-model="toPost.access"> | 
					
						
							|  |  |  |             <option value="OpenSource">OpenSource</option> | 
					
						
							|  |  |  |             <option value="Restricted">Restricted</option> | 
					
						
							|  |  |  |             <option value="Private">Private</option> | 
					
						
							|  |  |  |           </select></li> | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |           <li> Research Pdf : | 
					
						
							|  |  |  |             <form novalidate enctype="multipart/form-data" class="inputBox"> | 
					
						
							|  |  |  |             <input type="file" @change="uploadResearchPdf($event.target.files);" accept="application/pdf"> | 
					
						
							|  |  |  |           </form></li> | 
					
						
							|  |  |  |           <li> Research BibTex : | 
					
						
							|  |  |  |           <form novalidate enctype="multipart/form-data" class="inputBox"> | 
					
						
							|  |  |  |             <input type="file" @change="uploadBibTex($event.target.files);" accept=".bib"> | 
					
						
							|  |  |  |           </form></li> | 
					
						
							|  |  |  |         </ul> | 
					
						
							|  |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  |         <div id="CoAuthorList"> Co-Authors List: | 
					
						
							|  |  |  |         <ul style="list-style-type: none;" v-for="n in allResearcher"> | 
					
						
							|  |  |  |           <li v-if="n.id !== props.researcher.id"> <input type="checkbox" :value=n v-model="coAuthors"> {{n.id}} : {{n.user.firstName}} {{n.user.lastName}}</li> | 
					
						
							|  |  |  |         </ul> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |         <div></div> | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |         <div> | 
					
						
							|  |  |  |           <button id="confirmButton" @click="postNewResearch">Confirm Publish</button> | 
					
						
							|  |  |  |           <button id="cancelButton" @click="cancelPost">Cancel Publish</button> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </div> | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |     </div> | 
					
						
							|  |  |  |   </div> | 
					
						
							| 
									
										
										
										
											2024-04-17 23:00:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style scoped> | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | .modal-mask { | 
					
						
							|  |  |  |   position: fixed; | 
					
						
							|  |  |  |   z-index: 9998; | 
					
						
							|  |  |  |   top: 0; | 
					
						
							|  |  |  |   left: 0; | 
					
						
							|  |  |  |   width: 100%; | 
					
						
							|  |  |  |   height: 100%; | 
					
						
							|  |  |  |   background-color: rgba(0, 0, 0, 0.5); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .modal-container { | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  |   display: grid; | 
					
						
							|  |  |  |   grid-template-columns: 40% 60%; | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  |   width: 70%; | 
					
						
							|  |  |  |   margin: 150px auto; | 
					
						
							|  |  |  |   padding: 20px 30px; | 
					
						
							|  |  |  |   background: rgba(157, 99, 205); | 
					
						
							|  |  |  |   border-radius: 12px; | 
					
						
							|  |  |  |   box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .modal-container ul{ | 
					
						
							|  |  |  |   margin-top: 9px; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-20 19:07:27 +02:00
										 |  |  | #coAuthorList{ | 
					
						
							|  |  |  |   overflow: scroll; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | #downloads button { | 
					
						
							|  |  |  |   align-self: center; | 
					
						
							|  |  |  |   margin-left: 2px; | 
					
						
							|  |  |  |   font-size: large; | 
					
						
							|  |  |  |   color: white; | 
					
						
							|  |  |  |   background: rgba(191, 64, 191,0.5); | 
					
						
							|  |  |  |   border:2px solid black; | 
					
						
							|  |  |  |   border-radius: 5px; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #downloads button:hover{ | 
					
						
							|  |  |  |   background: rgba(191, 64, 191); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #cancelButton{ | 
					
						
							|  |  |  |   align-self: center; | 
					
						
							|  |  |  |   text-align: center; | 
					
						
							|  |  |  |   border: 2px solid black; | 
					
						
							|  |  |  |   color: white; | 
					
						
							|  |  |  |   font-size: x-large; | 
					
						
							|  |  |  |   background-color:rgba(191, 64, 191,0.5); | 
					
						
							|  |  |  |   border-radius: 20px; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #cancelButton:hover{ | 
					
						
							|  |  |  |   background:rgba(191,64,191) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-04-17 23:00:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 14:53:17 +02:00
										 |  |  | #confirmButton{ | 
					
						
							|  |  |  |   align-self: center; | 
					
						
							|  |  |  |   text-align: center; | 
					
						
							|  |  |  |   border: 2px solid black; | 
					
						
							|  |  |  |   color: white; | 
					
						
							|  |  |  |   font-size: x-large; | 
					
						
							|  |  |  |   background-color: #07bc0c; | 
					
						
							|  |  |  |   border-radius: 20px; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #confirmButton:hover{ | 
					
						
							|  |  |  |   background: #4cd964; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | </style> |