mirror of https://github.com/requarks/wiki
parent
7e344fc6fa
commit
6e303ac648
@ -1,93 +1,96 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
q-dialog(ref='dialog', @hide='onDialogHide')
|
q-dialog(ref='dialogRef', @hide='onDialogHide')
|
||||||
q-card(style='min-width: 350px; max-width: 450px;')
|
q-card(style='min-width: 350px; max-width: 450px;')
|
||||||
q-card-section.card-header
|
q-card-section.card-header
|
||||||
q-icon(name='img:/_assets/icons/fluent-delete-bin.svg', left, size='sm')
|
q-icon(name='img:/_assets/icons/fluent-delete-bin.svg', left, size='sm')
|
||||||
span {{$t(`admin.groups.delete`)}}
|
span {{t(`admin.groups.delete`)}}
|
||||||
q-card-section
|
q-card-section
|
||||||
.text-body2
|
.text-body2
|
||||||
i18n-t(keypath='admin.groups.deleteConfirm')
|
i18n-t(keypath='admin.groups.deleteConfirm')
|
||||||
template(#groupName)
|
template(#groupName)
|
||||||
strong {{group.name}}
|
strong {{props.group.name}}
|
||||||
.text-body2.q-mt-md
|
.text-body2.q-mt-md
|
||||||
strong.text-negative {{$t(`admin.groups.deleteConfirmWarn`)}}
|
strong.text-negative {{t(`admin.groups.deleteConfirmWarn`)}}
|
||||||
q-card-actions.card-actions
|
q-card-actions.card-actions
|
||||||
q-space
|
q-space
|
||||||
q-btn.acrylic-btn(
|
q-btn.acrylic-btn(
|
||||||
flat
|
flat
|
||||||
:label='$t(`common.actions.cancel`)'
|
:label='t(`common.actions.cancel`)'
|
||||||
color='grey'
|
color='grey'
|
||||||
padding='xs md'
|
padding='xs md'
|
||||||
@click='hide'
|
@click='onDialogCancel'
|
||||||
)
|
)
|
||||||
q-btn(
|
q-btn(
|
||||||
unelevated
|
unelevated
|
||||||
:label='$t(`common.actions.delete`)'
|
:label='t(`common.actions.delete`)'
|
||||||
color='negative'
|
color='negative'
|
||||||
padding='xs md'
|
padding='xs md'
|
||||||
@click='confirm'
|
@click='confirm'
|
||||||
)
|
)
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { useDialogPluginComponent, useQuasar } from 'quasar'
|
||||||
|
|
||||||
export default {
|
// PROPS
|
||||||
props: {
|
|
||||||
group: {
|
const props = defineProps({
|
||||||
type: Object,
|
group: {
|
||||||
required: true
|
type: Object,
|
||||||
}
|
required: true
|
||||||
},
|
}
|
||||||
emits: ['ok', 'hide'],
|
})
|
||||||
data () {
|
|
||||||
return {
|
// EMITS
|
||||||
}
|
|
||||||
},
|
defineEmits([
|
||||||
methods: {
|
...useDialogPluginComponent.emits
|
||||||
show () {
|
])
|
||||||
this.$refs.dialog.show()
|
|
||||||
},
|
// QUASAR
|
||||||
hide () {
|
|
||||||
this.$refs.dialog.hide()
|
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
|
||||||
},
|
const $q = useQuasar()
|
||||||
onDialogHide () {
|
|
||||||
this.$emit('hide')
|
// I18N
|
||||||
},
|
|
||||||
async confirm () {
|
const { t } = useI18n()
|
||||||
try {
|
|
||||||
const resp = await this.$apollo.mutate({
|
// METHODS
|
||||||
mutation: gql`
|
|
||||||
mutation deleteGroup ($id: UUID!) {
|
async function confirm () {
|
||||||
deleteGroup(id: $id) {
|
try {
|
||||||
status {
|
const resp = await APOLLO_CLIENT.mutate({
|
||||||
succeeded
|
mutation: gql`
|
||||||
message
|
mutation deleteGroup ($id: UUID!) {
|
||||||
}
|
deleteGroup(id: $id) {
|
||||||
}
|
operation {
|
||||||
|
succeeded
|
||||||
|
message
|
||||||
}
|
}
|
||||||
`,
|
|
||||||
variables: {
|
|
||||||
id: this.group.id
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
if (resp?.data?.deleteGroup?.status?.succeeded) {
|
|
||||||
this.$q.notify({
|
|
||||||
type: 'positive',
|
|
||||||
message: this.$t('admin.groups.deleteSuccess')
|
|
||||||
})
|
|
||||||
this.$emit('ok')
|
|
||||||
this.hide()
|
|
||||||
} else {
|
|
||||||
throw new Error(resp?.data?.deleteGroup?.status?.message || 'An unexpected error occured.')
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
`,
|
||||||
this.$q.notify({
|
variables: {
|
||||||
type: 'negative',
|
id: props.group.id
|
||||||
message: err.message
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
if (resp?.data?.deleteGroup?.operation?.succeeded) {
|
||||||
|
$q.notify({
|
||||||
|
type: 'positive',
|
||||||
|
message: t('admin.groups.deleteSuccess')
|
||||||
|
})
|
||||||
|
onDialogOK()
|
||||||
|
} else {
|
||||||
|
throw new Error(resp?.data?.deleteGroup?.operation?.message || 'An unexpected error occured.')
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
$q.notify({
|
||||||
|
type: 'negative',
|
||||||
|
message: err.message
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue