modals.js 1.4 KB

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