2019-04-03 00:25:12 +02:00
|
|
|
export const state = () => ({
|
2019-06-25 01:05:38 +02:00
|
|
|
locale: '',
|
2019-09-17 16:05:46 +02:00
|
|
|
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',
|
2019-12-04 00:50:15 +01:00
|
|
|
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,
|
2019-10-22 01:01:41 +02:00
|
|
|
enable_federation: false,
|
2019-12-04 00:50:15 +01:00
|
|
|
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
|
|
|
},
|
2020-02-16 21:03:50 +01: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) {
|
2019-06-21 23:52:18 +02:00
|
|
|
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
|
2020-02-16 21:03:50 +01:00
|
|
|
},
|
|
|
|
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') {
|
2021-09-28 12:55:54 +02:00
|
|
|
commit('setAnnouncements', req.announcements)
|
|
|
|
commit('update', req.meta)
|
|
|
|
}
|
2019-04-26 23:14:43 +02:00
|
|
|
},
|
2020-02-16 21:03:50 +01: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
|
|
|
},
|
2020-02-16 21:03:50 +01: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)
|
2019-06-21 23:52:18 +02:00
|
|
|
commit('setSetting', setting)
|
2019-09-11 19:12:24 +02:00
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|