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

View File

@ -1,7 +1,7 @@
<template> <template>
<ds-modal :title="title" :is-open="isOpen" @cancel="cancel"> <ds-modal :title="title" :is-open="isOpen" @cancel="cancel">
<!-- eslint-disable-next-line vue/no-v-html --> <!-- eslint-disable-next-line vue/no-v-html -->
<p v-html="message" /> <!-- <p v-html="message" /> -->
<delete-data /> <delete-data />
<template slot="footer"> <template slot="footer">
<base-button class="cancel" @click="cancel">löschen abbrechen</base-button> <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 !!! // 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.modalData.buttons.confirm.callback()
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: gql` /* mutation: gql`
mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) { mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
review(resourceId: $resourceId, disable: $disable, closed: $closed) { review(resourceId: $resourceId, disable: $disable, closed: $closed) {
disable 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 }, variables: { resourceId: this.id, disable: false, closed: false },
}) })

View File

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