mirror of https://github.com/nocodb/nocodb
63 lines
1.6 KiB
63 lines
1.6 KiB
<script lang="ts" setup> |
|
interface Props { |
|
modelValue: boolean |
|
view?: Record<string, any> |
|
} |
|
|
|
interface Emits { |
|
(event: 'update:modelValue', data: boolean): void |
|
(event: 'deleted'): void |
|
} |
|
|
|
const props = defineProps<Props>() |
|
|
|
const emits = defineEmits<Emits>() |
|
|
|
const { refreshCommandPalette } = useCommandPalette() |
|
|
|
const { view } = props |
|
|
|
const vModel = useVModel(props, 'modelValue', emits) |
|
|
|
const { api } = useApi() |
|
|
|
const { $e } = useNuxtApp() |
|
|
|
/** Delete a view */ |
|
async function onDelete() { |
|
if (!props.view) return |
|
|
|
try { |
|
await api.dbView.delete(props.view.id) |
|
|
|
vModel.value = false |
|
emits('deleted') |
|
$e('a:view:delete', { view: props.view.type }) |
|
} catch (e: any) { |
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
} finally { |
|
refreshCommandPalette() |
|
} |
|
|
|
// telemetry event |
|
} |
|
</script> |
|
|
|
<template> |
|
<GeneralDeleteModal v-model:visible="vModel" :entity-name="$t('objects.view')" :on-delete="onDelete"> |
|
<template #entity-preview> |
|
<div v-if="view" class="flex flex-row items-center py-2 px-3 bg-gray-50 rounded-lg text-gray-700"> |
|
<GeneralViewIcon :meta="props.view" class="nc-view-icon w-4 min-h-4"></GeneralViewIcon> |
|
<div |
|
class="capitalize text-ellipsis overflow-hidden select-none w-full pl-3" |
|
:style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }" |
|
> |
|
<span v-if="view.is_default">{{ $t('labels.defaultView') }}</span> |
|
<span v-else> |
|
{{ view.title }} |
|
</span> |
|
</div> |
|
</div> |
|
</template> |
|
</GeneralDeleteModal> |
|
</template>
|
|
|