modals.js 1.6 KB

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