Add confirm dialog to reminder button.
Add a show function in alertStore so we can use alerts in a defined way everywhere. #12 #33
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
import { options } from '@coders-tm/vue-number-format';
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export interface AlertOptions {
|
||||
cancelText?: string;
|
||||
onCancel?: () => void;
|
||||
actionText?: string;
|
||||
actionVariant?: "action" | "destructive";
|
||||
onAction?: () => void;
|
||||
}
|
||||
|
||||
export const alertStore = defineStore('alert', {
|
||||
state: () => {
|
||||
return {
|
||||
open: false,
|
||||
title: "",
|
||||
message: "",
|
||||
message: "" as string | null,
|
||||
cancelText: "Abbrechen",
|
||||
onCancel: () => { },
|
||||
actionText: "Ok",
|
||||
@@ -13,5 +22,25 @@ export const alertStore = defineStore('alert', {
|
||||
onAction: () => { }
|
||||
}
|
||||
},
|
||||
actions: {}
|
||||
|
||||
actions: {
|
||||
show(title: string, message: string | null, options?: AlertOptions) {
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.cancelText = options?.cancelText ? options.cancelText : "Abbrechen"
|
||||
this.onCancel = options?.onCancel ? options.onCancel : () => { }
|
||||
this.actionText = options?.actionText ? options.actionText : "Ok"
|
||||
this.actionVariant = options?.actionVariant ? options.actionVariant : "action"
|
||||
this.onAction = options?.onAction ? options.onAction : () => { }
|
||||
this.open = true;
|
||||
},
|
||||
cancel() {
|
||||
this.onCancel();
|
||||
this.open = false;
|
||||
},
|
||||
action() {
|
||||
this.onAction();
|
||||
this.open = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user