export default { $_openModalStack({ state, rootState }, data) { // data: {name, rel, model, form_data, data, modal_pop_data, type} data.name = 'modal_' + data.name; if (state.modals.findIndex(x => x.name == data.name) == -1) { state.modals.push(data); let module = data.name.split("_"); rootState[module[1]].relation = data.rel ? data.rel : {}; rootState[module[1]].current_model = data.model ? data.model : {}; rootState[module[1]].page_type = data.page_type ? data.page_type : 'modal'; } }, $_closeModalStack({ state, rootState }) { if (state.modals.length) { let last_data = [...state.modals].pop(); if (state.modals.length > 1) { state.modals[state.modals.length - 2]['last_modal_data'] = last_data; } let module = last_data.name.split("_"); rootState[module[1]].relation = {}; rootState[module[1]].current_model = {}; rootState[module[1]].page_type = ''; state.modals.pop(); } }, $_dialog:({commit, dispatch}, properties) => { properties['name'] = 'modal_dialog'; dispatch('$_openModalStack', properties); commit('SET_DIALOG_TYPE', properties.type); commit('SET_DIALOG_PROPERTIES', properties); }, $_helper:({dispatch}, slug) => { let data = {}; data['name'] = 'modal_helper'; data['slug'] = slug; dispatch('$_openModalStack', data); }, };