modals.js 1.2 KB

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