From a798e236745a155338ca048a2438c0e0dfd60394 Mon Sep 17 00:00:00 2001 From: shokouhi Date: Mon, 14 Dec 2020 11:58:31 +0330 Subject: [PATCH] fix: open modal without vuex module --- .../js/Global/store/modules/modal/actions.js | 58 +++++++++++-------- .../js/Global/store/modules/modal/getters.js | 8 --- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/resources/js/Global/store/modules/modal/actions.js b/resources/js/Global/store/modules/modal/actions.js index 35382c2..00eae08 100644 --- a/resources/js/Global/store/modules/modal/actions.js +++ b/resources/js/Global/store/modules/modal/actions.js @@ -12,45 +12,55 @@ export default { if (state.modals.findIndex(x => x.name === data.name) === -1) { state.modals.push(data); let module = data.name.split("_"); - if (data.rel) { - rootState[module[1]].relation = data.rel; - state.rel.push(data.rel); + if (module.length > 2) { + if (data.rel) { + rootState[module[1]].relation = data.rel; + state.rel.push(data.rel); + } + if (data.model) { + rootState[module[1]].current_model = data.model; + state.model.push(data.model); + } + rootState[module[1]].page_type = data.page_type ? data.page_type : 'modal'; } - if (data.model) { - rootState[module[1]].current_model = data.model; - state.model.push(data.model); - } - rootState[module[1]].page_type = data.page_type ? data.page_type : 'modal'; + } } }, $_closeModal({ state, rootState }) { if (state.modals.length) { let last_data = [...state.modals].pop(); - let module = last_data.name.split("_")[1]; if (state.modals.length > 1) { state.modals[state.modals.length - 2]['last_modal_data'] = last_data; - } else { - rootState[module].page_type = ''; } + + if (last_data.name.split("_").length > 2) { - if(last_data.rel) { - state.rel.pop(); - if (state.rel.length) { - rootState[module].relation = state.rel[state.rel.length - 1]; - } else { - rootState[module].relation = {}; + let module = last_data.name.split("_")[1]; + + if(state.modals.length <= 1) { + rootState[module].page_type = ''; } - } - if(last_data.model) { - state.model.pop(); - if (state.model.length) { - rootState[module].current_model = state.model[state.model.length - 1]; - } else { - rootState[module].current_model = {}; + + if(last_data.rel) { + state.rel.pop(); + if (state.rel.length) { + rootState[module].relation = state.rel[state.rel.length - 1]; + } else { + rootState[module].relation = {}; + } + } + if(last_data.model) { + state.model.pop(); + if (state.model.length) { + rootState[module].current_model = state.model[state.model.length - 1]; + } else { + rootState[module].current_model = {}; + } } } + state.modals.pop(); } }, diff --git a/resources/js/Global/store/modules/modal/getters.js b/resources/js/Global/store/modules/modal/getters.js index 9e9c7fe..a8e7117 100644 --- a/resources/js/Global/store/modules/modal/getters.js +++ b/resources/js/Global/store/modules/modal/getters.js @@ -1,12 +1,4 @@ export default { - isModal: (state, getters, rootState) => modal => { - let modalArray = modal.split("/"); - if (modalArray.length == 2) { - return rootState[modalArray[0]]["modal"][modalArray[1]]; - } else { - return rootState.modal[modalArray[0]]; - } - }, getDialogProperties:(state) => state.dialogProperties, getDialogType:(state) => state.dialogType,