From 393f33ccbcd7853a16c2ca0fe54274954cfbd21d Mon Sep 17 00:00:00 2001 From: Arturo Manzoli Date: Thu, 6 Jun 2024 09:32:04 -0300 Subject: [PATCH] Components: Interaction-dialog: Add return to dialog actions Signed-off-by: Arturo Manzoli --- src/components/InteractionDialog.vue | 65 ++++++++++++++++++---- src/composables/interactionDialog.ts | 81 ++++++++++++++++++++-------- 2 files changed, 116 insertions(+), 30 deletions(-) diff --git a/src/components/InteractionDialog.vue b/src/components/InteractionDialog.vue index 251028369..26be7be3e 100644 --- a/src/components/InteractionDialog.vue +++ b/src/components/InteractionDialog.vue @@ -3,7 +3,7 @@
{{ title }} @@ -11,11 +11,11 @@
- {{ + {{ variant === 'info' ? 'mdi-information' : variant === 'warning' - ? 'mdi-alert' + ? 'mdi-alert-rhombus' : variant === 'error' ? 'mdi-alert-circle' : 'mdi-check-circle' @@ -43,13 +43,13 @@ :color="button.color || undefined" :class="button.class || undefined" :disabled="button.disabled || false" - @click="button.action" + @click="handleAction(button.action)" > {{ button.text }}
- Close + Close
@@ -63,24 +63,65 @@ import { useInteractionDialog } from '@/composables/interactionDialog' const { closeDialog } = useInteractionDialog() -/* eslint-disable jsdoc/require-jsdoc */ +/** + * + */ interface Action { + /** + * + */ text: string + /** + * + */ size?: string + /** + * + */ color?: string + /** + * + */ class?: string + /** + * + */ disabled?: boolean + /** + * + */ action: () => void } const props = withDefaults( defineProps<{ + /** + * + */ showDialog: boolean + /** + * + */ title: string + /** + * + */ contentComponent: string + /** + * + */ maxWidth: number + /** + * + */ actions: Action[] + /** + * + */ variant: string + /** + * + */ message: string }>(), { @@ -94,7 +135,7 @@ const props = withDefaults( } ) -const emit = defineEmits(['update:showDialog']) +const emit = defineEmits(['update:showDialog', 'confirmed', 'dismissed']) const internalShowDialog = ref(props.showDialog) @@ -109,15 +150,21 @@ watch(internalShowDialog, (newVal) => { if (!newVal) { closeDialog() emit('update:showDialog', newVal) + emit('dismissed') } }) + +const handleAction = (action: () => void): void => { + action() + emit('confirmed') +}