mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-16 18:32:55 -05:00
init crater
This commit is contained in:
28
resources/assets/js/store/modules/modal/actions.js
Normal file
28
resources/assets/js/store/modules/modal/actions.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const openModal = ({ commit, dispatch, state }, payload) => {
|
||||
commit(types.SET_COMPONENT_NAME, payload.componentName)
|
||||
commit(types.SHOW_MODAL, true)
|
||||
|
||||
if (payload.id) {
|
||||
commit(types.SET_ID, payload.id)
|
||||
}
|
||||
commit(types.SET_TITLE, payload.title)
|
||||
|
||||
if (payload.data) {
|
||||
commit(types.SET_DATA, payload.data)
|
||||
}
|
||||
|
||||
if (payload.size) {
|
||||
commit(types.SET_SIZE, payload.size)
|
||||
}
|
||||
}
|
||||
|
||||
export const closeModal = ({ commit, dispatch, state }) => {
|
||||
commit(types.RESET_DATA)
|
||||
commit(types.HIDE_MODAL, false)
|
||||
}
|
||||
|
||||
export const resetModalData = ({ commit, dispatch, state }) => {
|
||||
commit(types.RESET_DATA)
|
||||
}
|
||||
6
resources/assets/js/store/modules/modal/getters.js
Normal file
6
resources/assets/js/store/modules/modal/getters.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export const modalActive = state => state.active
|
||||
export const modalTitle = state => state.title
|
||||
export const componentName = state => state.componentName
|
||||
export const modalDataID = state => state.id
|
||||
export const modalData = state => state.data
|
||||
export const modalSize = state => state.size
|
||||
25
resources/assets/js/store/modules/modal/index.js
Normal file
25
resources/assets/js/store/modules/modal/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
active: false,
|
||||
content: '',
|
||||
title: '',
|
||||
componentName: '',
|
||||
id: '',
|
||||
size: 'md',
|
||||
data: null
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export const SHOW_MODAL = 'SHOW_MODAL'
|
||||
export const SET_TITLE = 'SET_TITLE'
|
||||
export const SET_COMPONENT_NAME = 'SET_COMPONENT_NAME'
|
||||
export const HIDE_MODAL = 'HIDE_MODAL'
|
||||
export const SET_ID = 'SET_ID'
|
||||
export const SET_SIZE = 'SET_SIZE'
|
||||
export const SET_DATA = 'SET_DATA'
|
||||
export const RESET_DATA = 'RESET_DATA'
|
||||
40
resources/assets/js/store/modules/modal/mutations.js
Normal file
40
resources/assets/js/store/modules/modal/mutations.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SHOW_MODAL] (state, data) {
|
||||
state.active = data
|
||||
},
|
||||
|
||||
[types.HIDE_MODAL] (state, data) {
|
||||
state.active = data
|
||||
},
|
||||
|
||||
[types.SET_TITLE] (state, data) {
|
||||
state.title = data
|
||||
},
|
||||
|
||||
[types.SET_COMPONENT_NAME] (state, data) {
|
||||
state.componentName = data
|
||||
},
|
||||
|
||||
[types.SET_ID] (state, data) {
|
||||
state.id = data
|
||||
},
|
||||
|
||||
[types.SET_DATA] (state, data) {
|
||||
state.data = data
|
||||
},
|
||||
|
||||
[types.SET_SIZE] (state, size) {
|
||||
state.size = size
|
||||
},
|
||||
|
||||
[types.RESET_DATA] (state) {
|
||||
state.active = false
|
||||
state.content = ''
|
||||
state.title = ''
|
||||
state.componentName = ''
|
||||
state.id = ''
|
||||
state.data = null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user