Adds Content deletion
This commit is contained in:
@@ -112,6 +112,7 @@ import PostMessage from "@/views/messages/PostMessage.vue";
|
|||||||
import DonationButton from "@/views/creators/DonationButton.vue";
|
import DonationButton from "@/views/creators/DonationButton.vue";
|
||||||
import YoutubePlayer from './YoutubePlayer.vue';
|
import YoutubePlayer from './YoutubePlayer.vue';
|
||||||
import ImageViewer from './ImageViewer.vue';
|
import ImageViewer from './ImageViewer.vue';
|
||||||
|
import {useClient} from "@/plugins/api.js";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
content: {
|
content: {
|
||||||
@@ -120,6 +121,9 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emits = defineEmits(['content:deleted'])
|
||||||
|
|
||||||
|
const contentId = computed(() => props.content.id)
|
||||||
const creatorId = computed(() => props.content.createdBy)
|
const creatorId = computed(() => props.content.createdBy)
|
||||||
const creatorName = computed(() => props.content.createdByName)
|
const creatorName = computed(() => props.content.createdByName)
|
||||||
const creatorLogo = computed(() => props.content.createdByPortraitUrl)
|
const creatorLogo = computed(() => props.content.createdByPortraitUrl)
|
||||||
@@ -160,8 +164,12 @@ function editContent() {
|
|||||||
console.log('Modifier le contenu');
|
console.log('Modifier le contenu');
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteContent() {
|
async function deleteContent() {
|
||||||
console.log('Effacer le contenu');
|
const client = useClient()
|
||||||
|
const response = await client.delete(`/api/contents/${contentId.value}`)
|
||||||
|
if (response.status >= 200 && response.status < 300){
|
||||||
|
emits('content:deleted', contentId.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reportContent() {
|
function reportContent() {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<template v-for="content in contents" :key="content">
|
<template v-for="content in contents" :key="content">
|
||||||
<content-card :content="content"
|
<content-card :content="content"
|
||||||
class="my-1"
|
class="my-1"
|
||||||
|
@content:deleted="onContentDeleted"
|
||||||
></content-card>
|
></content-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -40,6 +41,10 @@ const page_size = 10
|
|||||||
const errorMessage = ref()
|
const errorMessage = ref()
|
||||||
let last_id = null
|
let last_id = null
|
||||||
|
|
||||||
|
async function onContentDeleted(contentId) {
|
||||||
|
contents.value = contents.value.filter(c => c.id !== contentId)
|
||||||
|
}
|
||||||
|
|
||||||
const creatorIdWatcher = watch(
|
const creatorIdWatcher = watch(
|
||||||
() => props.creatorId,
|
() => props.creatorId,
|
||||||
(newCreatorId) => {
|
(newCreatorId) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user