Wolfgang Huß b2e1873ade Refactored to modalData for Delete Comment and Posts
The error is gone with this.
2019-06-07 18:04:12 +02:00

80 lines
1.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="modal-wrapper">
<!-- Todo: Put all modals with 2 buttons and equal properties in one customiced 'danger-action-modal' -->
<disable-modal
v-if="open === 'disable'"
:id="data.resource.id"
:type="data.type"
:name="name"
@close="close"
/>
<release-modal
v-if="open === 'release'"
:id="data.resource.id"
:type="data.type"
:name="name"
@close="close"
/>
<report-modal
v-if="open === 'report'"
:id="data.resource.id"
:type="data.type"
:name="name"
@close="close"
/>
<delete-modal
v-if="open === 'delete'"
:id="data.resource.id"
:type="data.type"
:name="name"
:modalData="data.modalsData.delete"
@close="close"
/>
</div>
</template>
<script>
import DeleteModal from '~/components/Modal/DeleteModal'
import DisableModal from '~/components/Modal/DisableModal'
import ReleaseModal from '~/components/ReleaseModal/ReleaseModal.vue'
import ReportModal from '~/components/Modal/ReportModal'
import { mapGetters } from 'vuex'
export default {
name: 'Modal',
components: {
DisableModal,
ReleaseModal,
ReportModal,
DeleteModal,
},
computed: {
...mapGetters({
data: 'modal/data',
open: 'modal/open',
}),
name() {
if (!this.data || !this.data.resource) return ''
const {
resource: { name, title, author },
} = this.data
switch (this.data.type) {
case 'user':
return name
case 'contribution': // REFACTORING: In DeleteModal Already replaced "title" by "this.menuModalsData.delete.messageParams".
return title
case 'comment':
return author && author.name
default:
return null
}
},
},
methods: {
close() {
this.$store.commit('modal/SET_OPEN', {})
},
},
}
</script>