This commit is contained in:
ogerly 2020-02-23 17:36:23 +01:00
parent 25b7f169e3
commit fdc0f492ad
3 changed files with 53 additions and 9 deletions

View File

@ -28,6 +28,7 @@
<section v-if="deleteEnabled" class="warning">
<p>{{ $t('settings.deleteUserAccount.accountWarning') }}</p>
</section>
<ds-text v-show="isAdmin || currentUser.role === 'admin'" color="danger">ACHTUNG! Du Bist Admin!!</ds-text>
<base-button
icon="trash"
danger
@ -52,14 +53,26 @@ export default {
deleteContributions: false,
deleteComments: false,
enableDeletionValue: null,
isAdmin: this.$store.getters['auth/isAdmin'],
}
},
mounted() {
if (this.isAdmin === true) {
this.deleteContributions = true,
this.deleteComments = true
}
// console.log('isAdmin', isAdmin)
// console.log('this.deleteContributions', this.deleteContributions)
// console.log(' this.deleteComments', this.deleteComments)
},
computed: {
...mapGetters({
currentUser: 'auth/user',
}),
deleteEnabled() {
if (this.isAdmin === true) {
return this.enableDeletionValue === this.currentUser.name
}
},
},
methods: {

View File

@ -1,7 +1,7 @@
<template>
<ds-modal :title="title" :is-open="isOpen" @cancel="cancel">
<!-- eslint-disable-next-line vue/no-v-html -->
<p v-html="message" />
<!-- <p v-html="message" /> -->
<delete-data />
<template slot="footer">
<base-button class="cancel" @click="cancel">löschen abbrechen</base-button>
@ -57,12 +57,41 @@ export default {
// TODO: Use the "modalData" structure introduced in "ConfirmModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!!
// await this.modalData.buttons.confirm.callback()
await this.$apollo.mutate({
mutation: gql`
/* mutation: gql`
mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
review(resourceId: $resourceId, disable: $disable, closed: $closed) {
disable
}
}
`, */
mutation: gql`
mutation {
DeleteUser(id: "u3", resource: [Post, Comment]) {
id
name
slug
about
deleted
contributions {
id
content
contentExcerpt
deleted
comments {
id
content
contentExcerpt
deleted
}
}
comments {
id
content
contentExcerpt
deleted
}
}
}
`,
variables: { resourceId: this.id, disable: false, closed: false },
})

View File

@ -49,7 +49,7 @@
{{ scope.row.createdAt | dateTime }}
</template>
<template slot="delete" slot-scope="scope">
<div @click="deleteUser(scope.row.id)">
<div @click="deleteUser({ id: scope.row.id, slug: scope.row.slug })">
<ds-icon name="trash"></ds-icon>
</div>
</template>
@ -164,13 +164,14 @@ export default {
},
},
methods: {
openModal() {
openModal(userdata) {
console.log("openModal", userdata)
this.$store.commit('modal/SET_OPEN', {
name: 'delete',
data: {
type: 'sss',
resource: 'dfdd',
modalData: {},
id: 'sss',
type: 'dfdd',
name: {},
},
})
},
@ -193,8 +194,9 @@ export default {
}
}
},
deleteUser(dd) {
this.openModal()
deleteUser(userdata) {
console.log("deleteUser", userdata)
this.openModal(userdata)
},
},
}