mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 20:21:10 -04:00
v5.0.0 update
This commit is contained in:
49
resources/scripts/stores/dialog.js
Normal file
49
resources/scripts/stores/dialog.js
Normal file
@ -0,0 +1,49 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useDialogStore = (useWindow = false) => {
|
||||
const defineStoreFunc = useWindow ? window.pinia.defineStore : defineStore
|
||||
const { global } = window.i18n
|
||||
|
||||
return defineStoreFunc({
|
||||
id: 'dialog',
|
||||
state: () => ({
|
||||
active: false,
|
||||
title: '',
|
||||
message: '',
|
||||
size: 'md',
|
||||
data: null,
|
||||
variant: 'danger', // primary || danger
|
||||
yesLabel: global.t('settings.custom_fields.yes'),
|
||||
noLabel: global.t('settings.custom_fields.no'),
|
||||
noLabel: 'No',
|
||||
resolve: null,
|
||||
hideNoButton: false,
|
||||
}),
|
||||
actions: {
|
||||
openDialog(data) {
|
||||
this.active = true
|
||||
this.title = data.title
|
||||
this.message = data.message
|
||||
this.size = data.size
|
||||
this.data = data.data
|
||||
this.variant = data.variant
|
||||
this.yesLabel = data.yesLabel
|
||||
this.noLabel = data.noLabel
|
||||
this.hideNoButton = data.hideNoButton
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.resolve = resolve
|
||||
})
|
||||
},
|
||||
closeDialog() {
|
||||
this.active = false
|
||||
|
||||
setTimeout(() => {
|
||||
this.title = ''
|
||||
this.message = ''
|
||||
this.data = null
|
||||
}, 300)
|
||||
},
|
||||
},
|
||||
})()
|
||||
}
|
||||
Reference in New Issue
Block a user