mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
# Conflicts: # webapp/components/Modal/DeleteModal.vue # webapp/components/PostCard/index.vue # webapp/components/comments/CommentList/index.vue # webapp/pages/index.vue # webapp/pages/post/_id/_slug/more-info.vue
80 lines
1.8 KiB
Vue
80 lines
1.8 KiB
Vue
<template>
|
|
<ds-modal :title="title" :is-open="isOpen" @cancel="cancel">
|
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
<p v-html="message" />
|
|
|
|
<template slot="footer">
|
|
<ds-button class="cancel" @click="cancel">
|
|
{{ $t('disable.cancel') }}
|
|
</ds-button>
|
|
|
|
<ds-button danger class="confirm" icon="exclamation-circle" @click="confirm">
|
|
{{ $t('disable.submit') }}
|
|
</ds-button>
|
|
</template>
|
|
</ds-modal>
|
|
</template>
|
|
|
|
<script>
|
|
import gql from 'graphql-tag'
|
|
|
|
export default {
|
|
name: 'DisableModal',
|
|
props: {
|
|
name: { type: String, default: '' },
|
|
type: { type: String, required: true },
|
|
callbacks: { type: Object, required: true },
|
|
id: { type: String, required: true },
|
|
},
|
|
data() {
|
|
return {
|
|
isOpen: true,
|
|
success: false,
|
|
loading: false,
|
|
}
|
|
},
|
|
computed: {
|
|
title() {
|
|
return this.$t(`disable.${this.type}.title`)
|
|
},
|
|
message() {
|
|
const name = this.$filters.truncate(this.name, 30)
|
|
return this.$t(`disable.${this.type}.message`, { name })
|
|
},
|
|
},
|
|
methods: {
|
|
async cancel() {
|
|
if (this.callbacks.cancel) {
|
|
await this.callbacks.cancel()
|
|
}
|
|
this.isOpen = false
|
|
setTimeout(() => {
|
|
this.$emit('close')
|
|
}, 1000)
|
|
},
|
|
async confirm() {
|
|
try {
|
|
if (this.callbacks.confirm) {
|
|
await this.callbacks.confirm()
|
|
}
|
|
await this.$apollo.mutate({
|
|
mutation: gql`
|
|
mutation($id: ID!) {
|
|
disable(id: $id)
|
|
}
|
|
`,
|
|
variables: { id: this.id },
|
|
})
|
|
this.$toast.success(this.$t('disable.success'))
|
|
this.isOpen = false
|
|
setTimeout(() => {
|
|
this.$emit('close')
|
|
}, 1000)
|
|
} catch (err) {
|
|
this.$toast.error(err.message)
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|