1
0
forked from PGL/Clyde

added reactivity to post delete and patch

This commit is contained in:
Bartha Maxime 2024-04-18 16:17:16 +02:00
parent 939b4f5492
commit 7394a23b45
3 changed files with 20 additions and 16 deletions

View File

@ -4,7 +4,6 @@ import FilterComponent from "@/Apps/ScientificPublications/FilterComponent.vue";
import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue"; import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue";
import {fetchResearches, } from "@/rest/ScientificPublications/ResearcherProfile.js"; import {fetchResearches, } from "@/rest/ScientificPublications/ResearcherProfile.js";
import {getSelf, patchProfile} from "@/rest/ScientificPublications/ManageResearcherProfile.js"; import {getSelf, patchProfile} from "@/rest/ScientificPublications/ManageResearcherProfile.js";
import {c, f} from "../../../dist/assets/_plugin-vue_export-helper-Bvj9NrzX.js";
import ResearchPostComponent from "@/Apps/ScientificPublications/ResearchPostComponent.vue"; import ResearchPostComponent from "@/Apps/ScientificPublications/ResearchPostComponent.vue";
const input = ref(""); const input = ref("");
const isFilterOpened = ref(false); const isFilterOpened = ref(false);
@ -43,7 +42,6 @@ const closeResearch = () => {
function openPostResearch(){ function openPostResearch(){
isPostResearchOpened.value = true isPostResearchOpened.value = true
} }
@ -81,12 +79,16 @@ function cancelChanges(){
changing.value = false changing.value = false
toModify= Object.assign({}, {}); toModify= Object.assign({}, {});
} }
function confirmChanges(){ async function confirmChanges(){
patchProfile(researcher.value.id, toModify) await patchProfile(researcher.value.id, toModify)
changing.value = false changing.value = false
toModify= Object.assign({}, {}); toModify= Object.assign({}, {});
researcher.value = await getSelf();
} }
async function modifiedResearch(){
researchList.value = await fetchResearches(researcher.value.id)
}
@ -94,8 +96,8 @@ function confirmChanges(){
<template> <div class="body"><div id="main"> <template> <div class="body"><div id="main">
<FilterComponent :isOpen="isFilterOpened" :allArticles="researchList" @modal-close="closeFilter" @submit="submitFilters()"></FilterComponent> <FilterComponent :isOpen="isFilterOpened" :allArticles="researchList" @modal-close="closeFilter" @submit="submitFilters()"></FilterComponent>
<ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" :manage="true" @modal-close="closeResearch"></ArticleComponent> <ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" :manage="true" @modal-close="closeResearch" @modified="modifiedResearch" ></ArticleComponent>
<ResearchPostComponent :researcher="researcher" :isOpen="isPostResearchOpened" @modal-close="isPostResearchOpened = false"></ResearchPostComponent> <ResearchPostComponent :researcher="researcher" :isOpen="isPostResearchOpened" @modal-close="isPostResearchOpened = false" @posted="modifiedResearch"></ResearchPostComponent>
<div id="profilePicture"> <div id="profilePicture">
<img src="/Clyde.png" /> <img src="/Clyde.png" />
</div> </div>

View File

@ -23,7 +23,7 @@ function format(date){
return day +"/"+ month +"/"+ year return day +"/"+ month +"/"+ year
} }
const emit = defineEmits(["modal-close","downloadPdf","downloadBibTex"]); const emit = defineEmits(["modal-close","downloadPdf","downloadBibTex","modified"]);
const target = ref(null) const target = ref(null)
onClickOutside(target, ()=>emit('modal-close')) onClickOutside(target, ()=>emit('modal-close'))
@ -34,15 +34,17 @@ function cancelChanges(){
toModify= Object.assign({}, {}); toModify= Object.assign({}, {});
emit('modal-close') emit('modal-close')
} }
function confirmChanges(){ async function confirmChanges(){
patchArticle(props.article.id, toModify) await patchArticle(props.article.id, toModify)
toModify= Object.assign({}, {}); toModify= Object.assign({}, {});
emit('modal-close') emit('modal-close')
emit("modified")
} }
function deleteThisArticle(){ async function deleteThisArticle(){
deleteArticle(props.article.id) await deleteArticle(props.article.id)
emit('modal-close') emit('modal-close')
emit("modified")
} }

View File

@ -23,25 +23,25 @@ async function uploadResearchBibTexPdf(pdf){
// Date when sent!! // Date when sent!!
function postNewResearch(){ async function postNewResearch(){
toPost.releaseDate = new Date() toPost.releaseDate = new Date()
toPost.author = props.researcher toPost.author = props.researcher
//the Pdf is required and a title //the Pdf and a title are required
console.log(!toPost.pdfLocation == null|| toPost.title == null || toPost.title === "")
if (toPost.pdfLocation == null || toPost.title == null || toPost.title === "") { if (toPost.pdfLocation == null || toPost.title == null || toPost.title === "") {
emit("modal-close") emit("modal-close")
return; return;
} }
postResearch(toPost) await postResearch(toPost)
toPost = Object.assign({}, {}); toPost = Object.assign({}, {});
emit("modal-close") emit("modal-close")
emit("posted")
} }
function cancelPost(){ function cancelPost(){
emit("modal-close") emit("modal-close")
toPost = Object.assign({}, {}); toPost = Object.assign({}, {});
} }
const emit = defineEmits(["modal-close"]); const emit = defineEmits(["modal-close","posted"]);
const target = ref(null) const target = ref(null)
onClickOutside(target, ()=>emit('modal-close')) onClickOutside(target, ()=>emit('modal-close'))