mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
2 years ago
|
<script lang="ts" setup>
|
||
2 years ago
|
import { message } from 'ant-design-vue'
|
||
2 years ago
|
import { useI18n } from 'vue-i18n'
|
||
2 years ago
|
import { extractSdkResponseErrorMsg } from '~/utils'
|
||
2 years ago
|
import { onKeyStroke, useApi, useNuxtApp, useVModel } from '#imports'
|
||
2 years ago
|
|
||
2 years ago
|
const props = defineProps<Props>()
|
||
|
const emits = defineEmits<Emits>()
|
||
|
const { t } = useI18n()
|
||
2 years ago
|
interface Props {
|
||
|
modelValue: boolean
|
||
|
view?: Record<string, any>
|
||
|
}
|
||
|
|
||
|
interface Emits {
|
||
|
(event: 'update:modelValue', data: boolean): void
|
||
|
(event: 'deleted'): void
|
||
|
}
|
||
|
|
||
|
const vModel = useVModel(props, 'modelValue', emits)
|
||
|
|
||
|
const { api, isLoading } = useApi()
|
||
|
|
||
|
const { $e } = useNuxtApp()
|
||
|
|
||
2 years ago
|
onKeyStroke('Escape', () => (vModel.value = false))
|
||
|
|
||
|
onKeyStroke('Enter', () => onDelete())
|
||
|
|
||
2 years ago
|
/** Delete a view */
|
||
|
async function onDelete() {
|
||
|
if (!props.view) return
|
||
|
|
||
|
try {
|
||
|
await api.dbView.delete(props.view.id)
|
||
|
|
||
2 years ago
|
// View deleted successfully
|
||
|
message.success(t('msg.success.viewDeleted'))
|
||
2 years ago
|
} catch (e: any) {
|
||
2 years ago
|
message.error(await extractSdkResponseErrorMsg(e))
|
||
2 years ago
|
}
|
||
|
|
||
|
emits('deleted')
|
||
|
|
||
|
// telemetry event
|
||
|
$e('a:view:delete', { view: props.view.type })
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<a-modal v-model:visible="vModel" class="!top-[35%]" :confirm-loading="isLoading">
|
||
2 years ago
|
<template #title> {{ $t('general.delete') }} {{ $t('objects.view') }} </template>
|
||
|
|
||
2 years ago
|
{{ $t('msg.info.deleteViewConfirmation') }}
|
||
2 years ago
|
|
||
|
<template #footer>
|
||
|
<a-button key="back" @click="vModel = false">{{ $t('general.cancel') }}</a-button>
|
||
2 years ago
|
<a-button key="submit" danger html-type="submit" :loading="isLoading" @click="onDelete">{{
|
||
|
$t('general.submit')
|
||
|
}}</a-button>
|
||
2 years ago
|
</template>
|
||
|
</a-modal>
|
||
|
</template>
|