forked from vikunja/frontend
konrad
588b4f507a
Fix redirect to home Move redirect to home to no auth component Move setup stuff to separate functions Renew token in authenticated component Use vue's router object Move auth type checks to computed properties Move after route stuff to authenticated content component More Cleanup Cleanup Hide the navigation on mobile in the navigation component Load namespaces from inside the navigation component Fix logout Move not authenticated content to separate component Fix favoriting lists Move link share authenticated stuff to separate component Move authenticated stuff to separate component Move side navigation to separate component Move top navigation bar to separate component Co-authored-by: kolaente <k@knt.li> Reviewed-on: vikunja/frontend#283 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
121 lines
3.0 KiB
JavaScript
121 lines
3.0 KiB
JavaScript
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
import {
|
|
CURRENT_LIST,
|
|
ERROR_MESSAGE,
|
|
HAS_TASKS,
|
|
IS_FULLPAGE,
|
|
KEYBOARD_SHORTCUTS_ACTIVE,
|
|
LOADING,
|
|
MENU_ACTIVE,
|
|
ONLINE,
|
|
} from './mutation-types'
|
|
import config from './modules/config'
|
|
import auth from './modules/auth'
|
|
import namespaces from './modules/namespaces'
|
|
import kanban from './modules/kanban'
|
|
import tasks from './modules/tasks'
|
|
import lists from './modules/lists'
|
|
import attachments from './modules/attachments'
|
|
|
|
import ListService from '../services/list'
|
|
import {setTitle} from '@/helpers/setTitle'
|
|
|
|
Vue.use(Vuex)
|
|
|
|
export const store = new Vuex.Store({
|
|
modules: {
|
|
config,
|
|
auth,
|
|
namespaces,
|
|
kanban,
|
|
tasks,
|
|
lists,
|
|
attachments,
|
|
},
|
|
state: {
|
|
loading: false,
|
|
errorMessage: '',
|
|
online: true,
|
|
isFullpage: false,
|
|
// This is used to highlight the current list in menu for all list related views
|
|
currentList: {id: 0},
|
|
background: '',
|
|
hasTasks: false,
|
|
menuActive: true,
|
|
keyboardShortcutsActive: false,
|
|
},
|
|
mutations: {
|
|
[LOADING](state, loading) {
|
|
state.loading = loading
|
|
},
|
|
[ERROR_MESSAGE](state, error) {
|
|
state.errorMessage = error
|
|
},
|
|
[ONLINE](state, online) {
|
|
state.online = online
|
|
},
|
|
[IS_FULLPAGE](state, fullpage) {
|
|
state.isFullpage = fullpage
|
|
},
|
|
[CURRENT_LIST](state, currentList) {
|
|
|
|
setTitle(currentList.title)
|
|
|
|
// Not sure if this is the right way to do it but hey, it works
|
|
if (
|
|
// List changed
|
|
currentList.id !== state.currentList.id ||
|
|
// The current list got a new background and didn't have one previously
|
|
(
|
|
currentList.backgroundInformation &&
|
|
!state.currentList.backgroundInformation
|
|
) ||
|
|
// The current list got a new background and had one previously
|
|
(
|
|
currentList.backgroundInformation &&
|
|
currentList.backgroundInformation.unsplashId &&
|
|
state.currentList &&
|
|
state.currentList.backgroundInformation &&
|
|
state.currentList.backgroundInformation.unsplashId &&
|
|
currentList.backgroundInformation.unsplashId !== state.currentList.backgroundInformation.unsplashId
|
|
) ||
|
|
// The new list has a background which is not an unsplash one and did not have one previously
|
|
(
|
|
currentList.backgroundInformation &&
|
|
currentList.backgroundInformation.type &&
|
|
state.currentList &&
|
|
state.currentList.backgroundInformation &&
|
|
state.currentList.backgroundInformation.type
|
|
)
|
|
) {
|
|
if (currentList.backgroundInformation) {
|
|
const listService = new ListService()
|
|
listService.background(currentList)
|
|
.then(b => {
|
|
state.background = b
|
|
})
|
|
.catch(e => {
|
|
console.error('Error getting background image for list', currentList.id, e)
|
|
})
|
|
} else {
|
|
state.background = null
|
|
}
|
|
}
|
|
|
|
state.currentList = currentList
|
|
},
|
|
[HAS_TASKS](state, hasTasks) {
|
|
state.hasTasks = hasTasks
|
|
},
|
|
[MENU_ACTIVE](state, menuActive) {
|
|
state.menuActive = menuActive
|
|
},
|
|
toggleMenu(state) {
|
|
state.menuActive = !state.menuActive
|
|
},
|
|
[KEYBOARD_SHORTCUTS_ACTIVE](state, active) {
|
|
state.keyboardShortcutsActive = active
|
|
},
|
|
},
|
|
}) |