-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nuxt-admin): add modal delete confirmation
- Loading branch information
Showing
2 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script setup lang="ts"> | ||
import {useVModel} from '@vueuse/core'; | ||
interface Props { | ||
modelValue?: boolean; | ||
message?: string; | ||
yesText?: string; | ||
noText?: string; | ||
title?: string; | ||
} | ||
const props = withDefaults(defineProps<Props>(), { | ||
modelValue: false, | ||
message: 'Are you sure want to delete this item?', | ||
yesText: 'Yes, delete it!', | ||
noText: 'Cancel', | ||
title: 'Delete Confirmation', | ||
}); | ||
const emit = | ||
defineEmits<{ | ||
(e: 'update:modelValue', value: boolean): void; | ||
(e: 'yes'): void; | ||
(e: 'no'): void; | ||
}>(); | ||
const isOpen = useVModel(props, 'modelValue', emit); | ||
const yes = () => { | ||
emit('yes'); | ||
isOpen.value = false; | ||
}; | ||
const no = () => { | ||
emit('no'); | ||
isOpen.value = false; | ||
}; | ||
</script> | ||
|
||
<template> | ||
<VModal v-model="isOpen" :title="title" hide-x-button> | ||
{{ message }} | ||
<template #footer> | ||
<VBtn @click="no"> {{ noText }}</VBtn> | ||
<VBtn color="error" @click="yes"> {{ yesText }}</VBtn> | ||
</template> | ||
</VModal> | ||
</template> |
77a6669
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for gits-nuxt-admin ready!
✅ Preview
https://gits-nuxt-admin-hupoxf74a-gravitano.vercel.app
Built with commit 77a6669.
This pull request is being automatically deployed with vercel-action