UNPKG

q42-cms-components

Version:

Front-end package that provides a UI on top of the QMS back-end

65 lines (54 loc) 1.06 kB
export const state = { all: [] } export const actions = { addWarning({ dispatch }, alert) { dispatch('add', { type: 'warning', html: alert }); }, addSuccess({ dispatch }, alert) { dispatch('add', { type: 'success', html: alert }); }, addInfo({ dispatch }, alert) { dispatch('add', { type: 'info', html: alert }); }, addError({ dispatch }, alert) { dispatch('add', { type: 'danger', html: alert }); }, add({ commit }, alert) { commit('add', alert); // auto-remove added alerts setTimeout(() => { commit('remove', alert); }, 10 * 1000); }, remove({ commit }, alert) { commit('remove', alert); } } export const mutations = { add(state, alert) { state.all.push(alert); }, remove(state, alert) { const index = state.all.indexOf(alert) state.all.splice(index, 1); } } export default { namespaced: true, state, actions, mutations }