Added cancel action for dialog create
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { PhX } from '@phosphor-icons/vue';
|
||||||
import type { World } from '~/models/World';
|
import type { World } from '~/models/World';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -11,6 +12,12 @@ const calendarSkeletonName = ref<string>('')
|
|||||||
function onChangedName(newName: string) {
|
function onChangedName(newName: string) {
|
||||||
calendarSkeletonName.value = newName
|
calendarSkeletonName.value = newName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['on-close'])
|
||||||
|
|
||||||
|
function handleCancel() {
|
||||||
|
emit('on-close')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -18,7 +25,8 @@ function onChangedName(newName: string) {
|
|||||||
<UiAlertDialogContent class="grid grid-rows-[auto_1fr_auto] items-start min-h-[66vh] max-w-4xl gap-6">
|
<UiAlertDialogContent class="grid grid-rows-[auto_1fr_auto] items-start min-h-[66vh] max-w-4xl gap-6">
|
||||||
<UiAlertDialogTitle>
|
<UiAlertDialogTitle>
|
||||||
<span class="text-2xl">
|
<span class="text-2xl">
|
||||||
<strong class="font-bold">{{ world.name }}</strong> —
|
<strong class="font-bold">{{ world.name }}</strong>
|
||||||
|
<span class="opacity-30"> — </span>
|
||||||
<span v-if="calendarSkeletonName">
|
<span v-if="calendarSkeletonName">
|
||||||
{{ calendarSkeletonName }}
|
{{ calendarSkeletonName }}
|
||||||
</span>
|
</span>
|
||||||
@@ -26,7 +34,11 @@ function onChangedName(newName: string) {
|
|||||||
</span>
|
</span>
|
||||||
</UiAlertDialogTitle>
|
</UiAlertDialogTitle>
|
||||||
|
|
||||||
<CalendarFormCreate @changed-name="onChangedName" />
|
<UiButton size="icon" variant="ghost" class="absolute top-4 right-4" title="Fermer la fenêtre" @click="handleCancel">
|
||||||
|
<PhX size="20" />
|
||||||
|
</UiButton>
|
||||||
|
|
||||||
|
<CalendarFormCreate @on-changed-name="onChangedName" @on-cancel="handleCancel" />
|
||||||
</UiAlertDialogContent>
|
</UiAlertDialogContent>
|
||||||
</UiAlertDialog>
|
</UiAlertDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ onMounted(() => {
|
|||||||
type FormTabs = 'global' | 'months' | 'today'
|
type FormTabs = 'global' | 'months' | 'today'
|
||||||
const activeTab = ref<FormTabs>('global')
|
const activeTab = ref<FormTabs>('global')
|
||||||
|
|
||||||
/**
|
|
||||||
* === Months list handling ===
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* === Current date ===
|
* === Current date ===
|
||||||
*/
|
*/
|
||||||
@@ -48,13 +44,19 @@ async function handleSubmit() {
|
|||||||
*/
|
*/
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
(e: 'changed-name', calendarName: string): void
|
(e: 'on-changed-name', calendarName: string): void
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
(e: 'on-cancel'): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
/** Hook to emit a debounced event for the changed skeleton name */
|
/** Hook to emit a debounced event for the changed skeleton name */
|
||||||
const handleNameChange = useDebounceFn(() => {
|
const handleNameChange = useDebounceFn(() => {
|
||||||
emit('changed-name', calendarSkeleton.value.name)
|
emit('on-changed-name', calendarSkeleton.value.name)
|
||||||
}, 400)
|
}, 400)
|
||||||
|
|
||||||
|
function handleFormCancel() {
|
||||||
|
emit('on-cancel')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -101,7 +103,10 @@ const handleNameChange = useDebounceFn(() => {
|
|||||||
</UiTabsContent>
|
</UiTabsContent>
|
||||||
</UiTabs>
|
</UiTabs>
|
||||||
|
|
||||||
<footer class="text-right mt-6">
|
<footer class="flex justify-end gap-2 mt-6">
|
||||||
|
<UiButton type="button" variant="destructive" @click="handleFormCancel">
|
||||||
|
Annuler
|
||||||
|
</UiButton>
|
||||||
<UiButton type="submit" :disabled="!validSkeleton">
|
<UiButton type="submit" :disabled="!validSkeleton">
|
||||||
Créer
|
Créer
|
||||||
</UiButton>
|
</UiButton>
|
||||||
|
|||||||
0
components/ui/alert-dialog/AlertDialogClose.vue
Normal file
0
components/ui/alert-dialog/AlertDialogClose.vue
Normal file
@@ -26,6 +26,10 @@ watch(user, (n, _o) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const alertModalOpened = ref<boolean>(false)
|
const alertModalOpened = ref<boolean>(false)
|
||||||
|
|
||||||
|
function handleDialogClose() {
|
||||||
|
alertModalOpened.value = false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -54,7 +58,7 @@ const alertModalOpened = ref<boolean>(false)
|
|||||||
<PhPlus size="17"/>
|
<PhPlus size="17"/>
|
||||||
</UiButton>
|
</UiButton>
|
||||||
</UiTooltipTrigger>
|
</UiTooltipTrigger>
|
||||||
<UiTooltipContent>
|
<UiTooltipContent :side-offset="10">
|
||||||
<p>Ajouter un calendrier</p>
|
<p>Ajouter un calendrier</p>
|
||||||
</UiTooltipContent>
|
</UiTooltipContent>
|
||||||
</UiTooltip>
|
</UiTooltip>
|
||||||
@@ -87,6 +91,6 @@ const alertModalOpened = ref<boolean>(false)
|
|||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<CalendarDialogCreate :world :modal-state="alertModalOpened" />
|
<CalendarDialogCreate :world :modal-state="alertModalOpened" @on-close="handleDialogClose" />
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user