update library tags handling
This commit is contained in:
@@ -24,7 +24,8 @@ export default {
|
||||
// LibraryOptions state
|
||||
mode: undefined,
|
||||
nodeDepartId: undefined,
|
||||
search: ''
|
||||
search: '',
|
||||
tags: []
|
||||
},
|
||||
|
||||
mutations: {
|
||||
@@ -62,7 +63,11 @@ export default {
|
||||
// ╰─╯╵ ╵ ╶┴╴╰─╯╵╰╯╶─╯
|
||||
|
||||
'SET_TAGS_OPTIONS' (state, tags) {
|
||||
state.tagsOptions = tags.map(tag => ({ value: tag.id, text: tag.name }))
|
||||
state.tagsOptions = Array.from(new Set(tags.map(tag => tag.name)))
|
||||
},
|
||||
|
||||
'UPDATE_TAGS' (state, tags) {
|
||||
state.tags = tags
|
||||
},
|
||||
|
||||
'SET_MODE' (state, mode) {
|
||||
@@ -145,10 +150,10 @@ export default {
|
||||
// ╰─╯╵ ╵ ╶┴╴╰─╯╵╰╯╶─╯
|
||||
|
||||
'GET_ALL_TAGS' ({ state, commit }) {
|
||||
if (state.tags !== undefined) return state.tags
|
||||
if (state.tagsOptions.length) return state.tagsOptions
|
||||
return api.query(AllTags).then(data => {
|
||||
commit('SET_TAGS_OPTIONS', data.tags)
|
||||
return state.tags
|
||||
return state.tagsOptions
|
||||
})
|
||||
},
|
||||
|
||||
@@ -177,6 +182,7 @@ export default {
|
||||
mode: state => state.mode,
|
||||
nodeDepartId: state => state.nodeDepartId,
|
||||
search: state => state.search,
|
||||
tags: state => state.tags,
|
||||
|
||||
// LibraryOptions options
|
||||
tagsOptions: state => state.tagsOptions,
|
||||
|
||||
Reference in New Issue
Block a user