mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-17 17:29:37 +00:00
Sorting and filtering
This commit is contained in:
parent
a89d2e71cc
commit
7532b756a7
14 changed files with 450 additions and 42 deletions
|
|
@ -1,11 +1,18 @@
|
|||
|
||||
export const state = () => ({
|
||||
orderBy: 'title',
|
||||
orderDesc: false
|
||||
settings: {
|
||||
orderBy: 'book.title',
|
||||
orderDesc: false,
|
||||
filterBy: 'all'
|
||||
},
|
||||
|
||||
listeners: []
|
||||
})
|
||||
|
||||
export const getters = {
|
||||
|
||||
getFilterOrderKey: (state) => {
|
||||
return Object.values(state.settings).join('-')
|
||||
}
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
|
|
@ -14,7 +21,19 @@ export const actions = {
|
|||
|
||||
export const mutations = {
|
||||
setSettings(state, settings) {
|
||||
state.orderBy = settings.orderBy
|
||||
state.orderDesc = settings.orderDesc
|
||||
state.settings = {
|
||||
...settings
|
||||
}
|
||||
state.listeners.forEach((listener) => {
|
||||
listener.meth()
|
||||
})
|
||||
},
|
||||
addListener(state, listener) {
|
||||
var index = state.listeners.findIndex(l => l.id === listener.id)
|
||||
if (index >= 0) state.listeners.splice(index, 1, listener)
|
||||
else state.listeners.push(listener)
|
||||
},
|
||||
removeListener(state, listenerId) {
|
||||
state.listeners = state.listeners.filter(l => l.id !== listenerId)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue