gancio-upstream/store/index.js

81 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-04-03 00:25:12 +02:00
export const state = () => ({
2019-06-25 01:05:38 +02:00
locale: '',
user_locale: {},
2021-03-10 15:26:09 +01:00
filters: { tags: [], places: [], show_recurrent: false },
2019-04-03 00:25:12 +02:00
tags: [],
places: [],
2019-07-13 01:02:11 +02:00
settings: {
2019-10-20 14:22:55 +02:00
instance_timezone: 'Europe/Rome',
instance_name: '',
2019-07-13 01:02:11 +02:00
allow_registration: true,
allow_anon_event: true,
allow_recurrent_event: true,
recurrent_event_visible: false,
enable_federation: false,
enable_resources: false,
2020-03-18 10:11:24 +01:00
hide_boosts: true,
enable_trusted_instances: true,
2021-11-09 12:47:26 +01:00
trusted_instances: [],
footerLinks: []
2019-07-13 01:02:11 +02:00
},
announcements: []
2019-04-03 00:25:12 +02:00
})
export const mutations = {
2019-09-11 19:12:24 +02:00
update (state, { tags, places }) {
2019-04-03 00:25:12 +02:00
state.tags = tags
state.places = places
},
2019-09-11 19:12:24 +02:00
setSettings (state, settings) {
2019-06-06 23:54:32 +02:00
state.settings = settings
2021-05-18 20:26:05 +02:00
state.filters.show_recurrent = settings.recurrent_event_visible
2019-06-06 23:54:32 +02:00
},
2019-09-11 19:12:24 +02:00
setSetting (state, setting) {
state.settings[setting.key] = setting.value
},
2019-09-11 19:12:24 +02:00
setLocale (state, locale) {
2019-06-25 01:05:38 +02:00
state.locale = locale
2019-09-19 16:23:46 +02:00
},
2021-11-09 12:47:26 +01:00
setUserlocale (state, messages) {
state.user_locale = messages
},
2020-10-17 00:41:21 +02:00
setFilters (state, filters) {
state.filters.tags = [...filters.tags]
state.filters.places = [...filters.places]
2021-03-10 15:26:09 +01:00
state.filters.show_recurrent = filters.show_recurrent
},
setAnnouncements (state, announcements) {
state.announcements = announcements
2019-04-03 00:25:12 +02:00
}
}
export const actions = {
2020-01-15 23:51:09 +01:00
// this method is called server side only for each request for nuxt
// we use it to get configuration from db, set locale, etc...
2020-01-27 00:47:03 +01:00
nuxtServerInit ({ commit }, { req }) {
commit('setSettings', req.settings)
2022-01-26 09:51:42 +01:00
if (req.status === 'READY') {
commit('setAnnouncements', req.announcements)
commit('update', req.meta)
}
2019-04-26 23:14:43 +02:00
},
async updateAnnouncements ({ commit }) {
const announcements = await this.$axios.$get('/announcements')
commit('setAnnouncements', announcements)
},
2019-09-11 19:12:24 +02:00
async updateMeta ({ commit }) {
2019-04-23 15:45:52 +02:00
const { tags, places } = await this.$axios.$get('/event/meta')
2019-04-03 00:25:12 +02:00
commit('update', { tags, places })
},
2020-10-25 00:34:22 +02:00
setFilters ({ commit }, filters) {
2020-10-17 00:41:21 +02:00
commit('setFilters', filters)
2019-04-03 00:25:12 +02:00
},
setAnnouncements ({ commit }, announcements) {
commit('setAnnouncements', announcements)
},
2019-09-11 19:12:24 +02:00
async setSetting ({ commit }, setting) {
await this.$axios.$post('/settings', setting)
commit('setSetting', setting)
2019-09-11 19:12:24 +02:00
}
2019-04-03 00:25:12 +02:00
}