filebrowser/frontend/src/store/mutations.js

84 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-02-01 12:17:04 +00:00
import * as i18n from '@/i18n'
import moment from 'moment'
const mutations = {
closeHovers: state => {
state.show = null
2021-03-03 17:46:37 +00:00
state.showConfirm = null
2018-02-01 12:17:04 +00:00
},
toggleShell: (state) => {
state.showShell = !state.showShell
},
2018-02-01 12:17:04 +00:00
showHover: (state, value) => {
if (typeof value !== 'object') {
state.show = value
return
}
state.show = value.prompt
state.showConfirm = value.confirm
},
2021-03-03 17:46:37 +00:00
showError: (state) => {
2018-02-01 12:17:04 +00:00
state.show = 'error'
},
2021-03-03 17:46:37 +00:00
showSuccess: (state) => {
2018-02-01 12:17:04 +00:00
state.show = 'success'
},
setLoading: (state, value) => { state.loading = value },
setReload: (state, value) => { state.reload = value },
setUser: (state, value) => {
if (value === null) {
state.user = null
return
}
2018-02-01 12:17:04 +00:00
let locale = value.locale
if (locale === '') {
locale = i18n.detectLocale()
}
moment.locale(locale)
i18n.default.locale = locale
state.user = value
},
setJWT: (state, value) => (state.jwt = value),
multiple: (state, value) => (state.multiple = value),
addSelected: (state, value) => (state.selected.push(value)),
removeSelected: (state, value) => {
let i = state.selected.indexOf(value)
if (i === -1) return
state.selected.splice(i, 1)
},
resetSelected: (state) => {
state.selected = []
},
updateUser: (state, value) => {
if (typeof value !== 'object') return
for (let field in value) {
if (field === 'locale') {
moment.locale(value[field])
i18n.default.locale = value[field]
}
2018-02-01 12:17:04 +00:00
state.user[field] = value[field]
}
},
updateRequest: (state, value) => {
state.oldReq = state.req
2018-02-01 12:17:04 +00:00
state.req = value
},
updateClipboard: (state, value) => {
state.clipboard.key = value.key
state.clipboard.items = value.items
state.clipboard.path = value.path
2018-02-01 12:17:04 +00:00
},
resetClipboard: (state) => {
state.clipboard.key = ''
state.clipboard.items = []
2021-03-03 17:46:37 +00:00
}
2018-02-01 12:17:04 +00:00
}
export default mutations