Moved to _dev
This commit is contained in:
49
crater/resources/scripts/stores/dialog.js
Normal file
49
crater/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)
|
||||
},
|
||||
},
|
||||
})()
|
||||
}
|
||||
77
crater/resources/scripts/stores/modal.js
Normal file
77
crater/resources/scripts/stores/modal.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useModalStore = (useWindow = false) => {
|
||||
const defineStoreFunc = useWindow ? window.pinia.defineStore : defineStore
|
||||
const { global } = window.i18n
|
||||
|
||||
return defineStoreFunc({
|
||||
id: 'modal',
|
||||
|
||||
state: () => ({
|
||||
active: false,
|
||||
content: '',
|
||||
title: '',
|
||||
componentName: '',
|
||||
id: '',
|
||||
size: 'md',
|
||||
data: null,
|
||||
refreshData: null,
|
||||
variant: '',
|
||||
}),
|
||||
|
||||
getters: {
|
||||
isEdit() {
|
||||
return (this.id ? true : false)
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
openModal(payload) {
|
||||
this.componentName = payload.componentName
|
||||
this.active = true
|
||||
|
||||
if (payload.id) {
|
||||
this.id = payload.id
|
||||
}
|
||||
|
||||
this.title = payload.title
|
||||
if (payload.content) {
|
||||
this.content = payload.content
|
||||
}
|
||||
|
||||
if (payload.data) {
|
||||
this.data = payload.data
|
||||
}
|
||||
|
||||
if (payload.refreshData) {
|
||||
this.refreshData = payload.refreshData
|
||||
}
|
||||
|
||||
if (payload.variant) {
|
||||
this.variant = payload.variant
|
||||
}
|
||||
|
||||
if (payload.size) {
|
||||
this.size = payload.size
|
||||
}
|
||||
},
|
||||
|
||||
resetModalData() {
|
||||
this.content = ''
|
||||
this.title = ''
|
||||
this.componentName = ''
|
||||
this.id = ''
|
||||
this.data = null
|
||||
this.refreshData = null
|
||||
},
|
||||
|
||||
closeModal() {
|
||||
this.active = false
|
||||
|
||||
setTimeout(() => {
|
||||
this.resetModalData()
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
})()
|
||||
}
|
||||
30
crater/resources/scripts/stores/notification.js
Normal file
30
crater/resources/scripts/stores/notification.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useNotificationStore = (useWindow = false) => {
|
||||
const defineStoreFunc = useWindow ? window.pinia.defineStore : defineStore
|
||||
|
||||
return defineStoreFunc({
|
||||
id: 'notification',
|
||||
|
||||
state: () => ({
|
||||
active: false,
|
||||
autoHide: true,
|
||||
notifications: [],
|
||||
}),
|
||||
|
||||
actions: {
|
||||
showNotification(notification) {
|
||||
this.notifications.push({
|
||||
...notification,
|
||||
id: (Math.random().toString(36) + Date.now().toString(36)).substr(2),
|
||||
})
|
||||
},
|
||||
|
||||
hideNotification(data) {
|
||||
this.notifications = this.notifications.filter((notification) => {
|
||||
return notification.id != data.id
|
||||
})
|
||||
}
|
||||
}
|
||||
})()
|
||||
}
|
||||
Reference in New Issue
Block a user