-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41af0ba
commit c2ea61d
Showing
6 changed files
with
123 additions
and
29 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,15 @@ | ||
<template> | ||
<ConfirmationDialog /> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
import ConfirmationDialog from './Dialogs/ConfirmationDialog.vue'; | ||
export default defineComponent({ | ||
name: 'DialogComponent', | ||
components: { | ||
ConfirmationDialog | ||
} | ||
}) | ||
</script> |
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,51 @@ | ||
<template> | ||
<v-dialog | ||
v-model="isShowing" | ||
persistent | ||
> | ||
<v-card> | ||
<v-card-title class="headline"> | ||
{{ confirmationDialog.title }} | ||
</v-card-title> | ||
<v-card-text>{{ confirmationDialog.message }}</v-card-text> | ||
<v-card-actions> | ||
<v-spacer /> | ||
<v-btn | ||
rounded | ||
@click="isShowing = false" | ||
> | ||
Cancel | ||
</v-btn> | ||
<v-btn | ||
rounded | ||
@click="confirmationDialog.onConfirm" | ||
> | ||
Confirm | ||
</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</v-dialog> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
import { useDialogStore } from '../../stores/dialogs'; | ||
import { mapState } from 'pinia'; | ||
export default defineComponent({ | ||
name: 'ConfirmationDialog', | ||
computed: { | ||
isShowing: { | ||
get() { | ||
return this.confirmationDialog.isOpen; | ||
}, | ||
set(value: boolean) { | ||
if (value === false) { | ||
useDialogStore().closeConfirmationDialog(); | ||
} | ||
} | ||
}, | ||
...mapState(useDialogStore, ["confirmationDialog"]) | ||
} | ||
}) | ||
</script> |
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
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,33 @@ | ||
import { defineStore } from "pinia"; | ||
|
||
interface IDialogState { | ||
confirmationDialog: { | ||
isOpen: boolean; | ||
title: string; | ||
message: string; | ||
onConfirm: () => void; | ||
} | ||
} | ||
|
||
export const useDialogStore = defineStore('dialog', { | ||
state: (): IDialogState => ( | ||
{ | ||
confirmationDialog: { | ||
isOpen: false, | ||
title: "", | ||
message: "", | ||
onConfirm: () => { } | ||
} | ||
}), | ||
actions: { | ||
openConfirmationDialog({title, message, onConfirm}: {title: string, message: string, onConfirm: () => void}) { | ||
this.confirmationDialog.isOpen = true; | ||
this.confirmationDialog.title = title; | ||
this.confirmationDialog.message = message; | ||
this.confirmationDialog.onConfirm = onConfirm; | ||
}, | ||
closeConfirmationDialog() { | ||
this.confirmationDialog.isOpen = false; | ||
} | ||
} | ||
}); |