index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import index from './modules/index'
  4. import category from './modules/category'
  5. import thread from './modules/thread'
  6. import admin from './modules/admin'
  7. Vue.use(Vuex)
  8. export default new Vuex.Store({
  9. state: {
  10. meta: {
  11. name: 'Forum',
  12. categories: [
  13. {name: 'All categories', value: 'ALL'},
  14. {name: 'Technology', value: 'TECHNOLOGY'},
  15. {name: 'Food', value: 'FOOD'},
  16. {name: 'Programming', value: 'PROGRAMMING'},
  17. {name: 'Books', value: 'BOOKS'}
  18. ]
  19. },
  20. tabs: {
  21. account: 0,
  22. thread: 0,
  23. 'new-thread': 0
  24. },
  25. selectOptions: {
  26. filterOptions: 'NEW'
  27. },
  28. modals: {
  29. account: false,
  30. 'thread_editor--picture': false,
  31. 'thread_editor--link': false
  32. },
  33. editors: {
  34. thread: {
  35. value: '',
  36. visible: false
  37. },
  38. 'new-thread': {
  39. value: '',
  40. visible: true
  41. }
  42. }
  43. },
  44. getters: {
  45. categoriesWithoutAll (state) {
  46. var categories = JSON.parse(JSON.stringify(state.meta.categories));
  47. categories.shift();
  48. categories.unshift({
  49. name: 'Select a category',
  50. disabled: true
  51. });
  52. return categories;
  53. }
  54. },
  55. mutations: {
  56. setTab (state, payload) {
  57. state.tabs[payload.tab] = payload.index;
  58. },
  59. setEditor (state, payload) {
  60. state.editors[payload.name].value = payload.value;
  61. },
  62. showEditor (state, payload) {
  63. state.editors[payload.name].visible = payload.value;
  64. },
  65. setSelectOptions (state, payload) {
  66. state.selectOptions[payload.name] = payload.value;
  67. },
  68. showModal (state, modal) {
  69. state.modals[modal] = true;
  70. },
  71. hideModal (state, modal) {
  72. state.modals[modal] = false;
  73. }
  74. },
  75. modules: {
  76. index,
  77. category,
  78. thread,
  79. admin
  80. }
  81. })