modals.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* eslint no-param-reassign: 0 */
  2. const state = {
  3. modals: {
  4. header: {
  5. login: false,
  6. register: false
  7. },
  8. home: {
  9. createCommunityStation: false
  10. },
  11. station: {
  12. addSongToQueue: false,
  13. editPlaylist: false,
  14. createPlaylist: false,
  15. addSongToPlaylist: false,
  16. editStation: false,
  17. report: false
  18. },
  19. admin: {
  20. editNews: false,
  21. editUser: false,
  22. editSong: false,
  23. viewReport: false,
  24. viewPunishment: false
  25. }
  26. },
  27. currentlyActive: {}
  28. };
  29. const getters = {};
  30. const actions = {
  31. closeModal: ({ commit }, data) => {
  32. commit("closeModal", data);
  33. },
  34. openModal: ({ commit }, data) => {
  35. commit("openModal", data);
  36. },
  37. closeCurrentModal: ({ commit }) => {
  38. commit("closeCurrentModal");
  39. }
  40. };
  41. const mutations = {
  42. closeModal(state, data) {
  43. const { sector, modal } = data;
  44. state.modals[sector][modal] = false;
  45. },
  46. openModal(state, data) {
  47. const { sector, modal } = data;
  48. state.modals[sector][modal] = true;
  49. state.currentlyActive = { sector, modal };
  50. },
  51. closeCurrentModal(state) {
  52. const { sector, modal } = state.currentlyActive;
  53. state.modals[sector][modal] = false;
  54. state.currentlyActive = {};
  55. }
  56. };
  57. export default {
  58. namespaced: true,
  59. state,
  60. getters,
  61. actions,
  62. mutations
  63. };