modalVisibility.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. editStation: false,
  16. report: false
  17. },
  18. admin: {
  19. editNews: false,
  20. editUser: false,
  21. editSong: false,
  22. editStation: false,
  23. editPlaylist: false,
  24. viewReport: false,
  25. viewPunishment: false
  26. }
  27. },
  28. currentlyActive: {}
  29. };
  30. const getters = {};
  31. const actions = {
  32. closeModal: ({ commit }, data) => {
  33. if (data.modal === "register") {
  34. lofig.get("recaptcha.enabled").then(recaptchaEnabled => {
  35. if (recaptchaEnabled) window.location.reload();
  36. });
  37. }
  38. commit("closeModal", data);
  39. },
  40. openModal: ({ commit }, data) => {
  41. commit("openModal", data);
  42. },
  43. closeCurrentModal: ({ commit }) => {
  44. commit("closeCurrentModal");
  45. }
  46. };
  47. const mutations = {
  48. closeModal(state, data) {
  49. const { sector, modal } = data;
  50. state.modals[sector][modal] = false;
  51. },
  52. openModal(state, data) {
  53. const { sector, modal } = data;
  54. state.modals[sector][modal] = true;
  55. state.currentlyActive = { sector, modal };
  56. },
  57. closeCurrentModal(state) {
  58. const { sector, modal } = state.currentlyActive;
  59. state.modals[sector][modal] = false;
  60. state.currentlyActive = {};
  61. }
  62. };
  63. export default {
  64. namespaced: true,
  65. state,
  66. getters,
  67. actions,
  68. mutations
  69. };