modals.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. if (data.modal === "register") window.location.reload();
  33. commit("closeModal", data);
  34. },
  35. openModal: ({ commit }, data) => {
  36. commit("openModal", data);
  37. },
  38. closeCurrentModal: ({ commit }) => {
  39. commit("closeCurrentModal");
  40. }
  41. };
  42. const mutations = {
  43. closeModal(state, data) {
  44. const { sector, modal } = data;
  45. state.modals[sector][modal] = false;
  46. },
  47. openModal(state, data) {
  48. const { sector, modal } = data;
  49. state.modals[sector][modal] = true;
  50. state.currentlyActive = { sector, modal };
  51. },
  52. closeCurrentModal(state) {
  53. const { sector, modal } = state.currentlyActive;
  54. state.modals[sector][modal] = false;
  55. state.currentlyActive = {};
  56. }
  57. };
  58. export default {
  59. namespaced: true,
  60. state,
  61. getters,
  62. actions,
  63. mutations
  64. };