@codeperate/app-asset
Version:
Codeperate App Asset
41 lines (40 loc) • 999 B
JavaScript
export const CdpModalModel = {
state: {
modals: [],
},
reducers: {
clear(state, payload) {
for (const num of payload)
state.modals.splice(num, 1);
return state;
},
pushModal(state, payload) {
state.modals.push(payload);
return state;
},
popModal(state) {
state.modals.pop();
return state;
},
popAllModal(state) {
state.modals = [];
return state;
},
closeModal(state) {
if (state.modals[state.modals.length - 1])
state.modals[state.modals.length - 1].close = true;
return state;
},
closeAllModal(state) {
for (const modal of state.modals)
modal.close = true;
return state;
},
popModalByTag(state, payload) {
for (let i = 0; i < state.modals.length; i++)
if (Object.values(state.modals[i].content).includes(payload))
state.modals.splice(i, 1);
return state;
},
},
};