export default { $_openModal: ({ rootState }, modal) => { let modalArray = modal.split("/"); if (modalArray.length == 2) { rootState[modalArray[0]]['modal'][modalArray[1]] = true; } else { rootState.modal[modalArray[0]] = true; } }, async $_openModalCallback ({ dispatch }, data) { dispatch(data.module + '/openModal' + data.type.charAt(0).toUpperCase() + data.type.slice(1), data, { root: true }); }, $_closeModalCallback: ({ dispatch }, data) => { dispatch(data.module + '/closeModal' + data.type.charAt(0).toUpperCase() + data.type.slice(1) , data, { root: true }); }, $_closeModal: ({ state, rootState }, modal) => { let modalArray = modal.split("/"); if (modalArray.length == 2) { rootState[modalArray[0]]['modal'][modalArray[1]] = false; } else { rootState.modal[modalArray[0]] = false; } state.properties = null; }, $_openModalStack({ state, rootState }, data) { // data: {name, rel, model, form_data, data, modal_pop_data, type} if (state.modals.findIndex(x => x.name == data.name) == -1) { state.modals.push(data); let module = data.name.split("_"); rootState[module[0]].relation = data.rel ? data.rel : {}; rootState[module[0]].currentModel = data.model ? data.model : {}; rootState[module[0]].page_type = data.page_type ? data.page_type : ''; } }, $_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[0]].relation = {}; rootState[module[0]].currentModel = {}; rootState[module[0]].page_type = ''; state.modals.pop(); } }, dialog:({state, commit}, properties) => { state.dialog = true; commit('SET_DIALOG_TYPE', properties.type); commit('SET_DIALOG_PROPERTIES', properties); }, };