editStation.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* eslint no-param-reassign: 0 */
  2. import Vue from "vue";
  3. export default {
  4. namespaced: true,
  5. state: {
  6. originalStation: {},
  7. station: {}
  8. },
  9. getters: {},
  10. actions: {
  11. editStation: ({ commit }, station) => commit("editStation", station),
  12. setGenres: ({ commit }, genres) => commit("setGenres", genres),
  13. setBlacklistedGenres: ({ commit }, blacklistedGenres) =>
  14. commit("setBlacklistedGenres", blacklistedGenres),
  15. clearStation: ({ commit }) => commit("clearStation")
  16. },
  17. mutations: {
  18. editStation(state, station) {
  19. state.originalStation = JSON.parse(JSON.stringify(station));
  20. state.station = JSON.parse(JSON.stringify(station));
  21. },
  22. setGenres(state, genres) {
  23. Vue.set(
  24. state.station,
  25. "genres",
  26. JSON.parse(JSON.stringify(genres))
  27. );
  28. },
  29. setBlacklistedGenres(state, blacklistedGenres) {
  30. Vue.set(
  31. state.station,
  32. "blacklistedGenres",
  33. JSON.parse(JSON.stringify(blacklistedGenres))
  34. );
  35. },
  36. clearStation(state) {
  37. state.originalStation = null;
  38. state.station = null;
  39. }
  40. }
  41. };