2017-05-21 20:43:58 +00:00
|
|
|
'use strict'
|
|
|
|
|
2017-05-28 02:24:46 +00:00
|
|
|
import debounce from 'lodash/debounce'
|
2017-05-21 20:43:58 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
state: {
|
|
|
|
shown: false,
|
|
|
|
style: 'green',
|
|
|
|
icon: 'check',
|
|
|
|
msg: ''
|
|
|
|
},
|
|
|
|
getters: {},
|
|
|
|
mutations: {
|
|
|
|
alertChange: (state, opts) => {
|
|
|
|
state.shown = (opts.shown === true)
|
|
|
|
state.style = opts.style || 'green'
|
|
|
|
state.icon = opts.icon || 'check'
|
|
|
|
state.msg = opts.msg || ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
alert({ commit, dispatch }, opts) {
|
|
|
|
opts.shown = true
|
|
|
|
commit('alertChange', opts)
|
|
|
|
dispatch('alertDismiss')
|
|
|
|
},
|
2017-05-28 02:24:46 +00:00
|
|
|
alertDismiss: debounce(({ commit }) => {
|
2017-05-21 20:43:58 +00:00
|
|
|
let opts = { shown: false }
|
|
|
|
commit('alertChange', opts)
|
|
|
|
}, 3000)
|
|
|
|
}
|
|
|
|
}
|